Skip to content

Zigbee Gateway will Only accept one enabled child at a time when using tuya-local #1054

Open
@felipejfc

Description

@felipejfc

Describe the bug
I have two ZB gateways at home, one of them works great, I have like 8 devices attached to it, no problem. The other one, a newer one using Zigbee 3.5, will only allow for one enabled device at a time. If I connect a device and enable it, it will work, second device I try to add will not go though.
Interestingly, not even a manual tinytuya script, directly from python will work. e.g. I have this script for testing:

import tinytuya

gwid="eb8368a08a9e5938044seh"
addr="10.1.0.143"
lk="'xxxxxxxxxxxxxxx"
dcid="a4c13867806ec8e8"
did="eb2056fdab6476a3e9r0uf"

tinytuya.set_debug(True)

gw = tinytuya.Device(gwid,address=addr,local_key=lk,version=3.5)
api = tinytuya.Device(did,cid=dcid,parent=gw)

print(api.status())

If I turn off tuya-local or disable the only device attached to this gateway in Homeassistant, this script will work. If I turn on one child of this device in Homeassistant, the very same script will fail with the following debug messages:

home python3 test.py 
DEBUG:TinyTuya [1.12.10]

DEBUG:Python 3.11.4 (main, Jul 25 2023, 17:36:13) [Clang 14.0.3 (clang-1403.0.22.14.1)] on darwin
DEBUG:Using PyCrypto (3, 17)
DEBUG:status() entry (dev_type is default)
DEBUG:final payload_dict for 'eb2056fdab6476a3e9r0uf' ('v3.5'/'default'): {1: {'command': {'gwId': '', 'devId': '', 'uid': '', 't': ''}}, 7: {'command': {'protocol': 5, 't': 'int', 'data': {'cid': ''}}, 'command_override': 13}, 8: {'command': {'gwId': '', 'devId': ''}}, 9: {'command': {'gwId': '', 'devId': ''}}, 10: {'command': {}, 'command_override': 16}, 13: {'command': {'protocol': 5, 't': 'int', 'data': {'cid': ''}}}, 16: {'command': {}}, 18: {'command': {'dpId': [18, 19, 20]}}, 64: {'command': {'reqType': '', 'data': {}}}}
DEBUG:building command 10 payload=b'{"cid":"a4c13867806ec8e8"}'
DEBUG:sending payload quick
DEBUG:final payload: b'0123456789abcdef'
DEBUG:payload encrypted=b'00006699000000000001000000030000002c303132333435363738396162f94a2663ef30c4c95d985f721b9cb42fc62e391184bc73fd209a4b13bcf9784300009966'
DEBUG:_recv_all(): no data? b''
DEBUG:received null payload (None), fetch new one - 1 retries remaining
DEBUG:_recv_all(): no data? b''
DEBUG:_recv_all(): no data? b''
DEBUG:received null payload (None) but out of recv retries, giving up
DEBUG:session key negotiation failed on step 1
DEBUG:ERROR Check device key or version - 914 - payload: null
DEBUG:status() received data={'Error': 'Check device key or version', 'Err': '914', 'Payload': None}
{'Error': 'Check device key or version', 'Err': '914', 'Payload': None}

It's like either the GW, or tinytuya/tuya-local can only accept one session at a time? Any insights/tips to debug/fix this?

To Reproduce
The Gateway in question is this one: Aliexpress link, Tuya IoT recognizes it as: G01Y001

Expected behavior
To be able to control multiple child from the gateway.

Metadata

Metadata

Assignees

No one assigned

    Labels

    device behaviourThe device itself causes this behaviourenhancementNew feature or request

    Projects

    Status

    📶Connection handling

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions