Would someone please help me understand how to interact with zigbee devices behind a gateway? #295
Answered
by
uzlonewolf
originalstocksy
asked this question in
Q&A
-
Hello, I'm using tinytuya 1.11.0 installed from pip. I have it working just fine with wifi devices, but I'm having trouble controlling my zigbee sockets. The gateway (Samotech SM310) and the sockets show up in devices.json after scanning: {
"name": "Top of china cabinet",
"id": "id-of-socket",
"key": "key-for-socket",
"mac": "",
"category": "kg",
"product_name": "\u4e8c\u8def\u89e6\u63a7\u5f00\u5173",
"product_id": "Gks88NvVJPbdmeE3",
"biz_type": 0,
"model": "",
"sub": true,
"icon": "https://images.tuyaeu.com/smart/icon/1538118837m86ohjdrxnb_0.png",
"uuid": "bf03095ea5e69e431bl8xi",
"node_id": "7cb94c77c7c10000",
"parent": "id-of-gateway"
},
{
"name": "Smart Zigbee Gateway",
"id": "id-of-gateway",
"key": "key-for-gateway",
"mac": "d4:a6:51:39:xx:yy",
"uuid": "45a8f8ad124e40bc",
"sn": "100005219000C9",
"category": "wg2",
"product_name": "SM310 Zigbee Hub",
"product_id": "adbdhajqr2ckfp4h",
"biz_type": 0,
"model": "SM310",
"sub": false,
"icon": "https://images.tuyaeu.com/smart/icon/ay1536786155500Jr2QM/0d59e8f43a614e224e7d16cfe701c1b7.jpg"
}, I've cobbled together a little bit of code based on the example: gw = tinytuya.Device('id-of-gateway', address='172.16.x.y', local_key='key-for-gateway', persist=True, version=3.3)
d = tinytuya.OutletDevice('id-of-socket, parent=gw)
d.set_version(3.3) # IMPORTANT to set this regardless of version
d.set_socketPersistent(True) # Optional: Keep socket open for multiple commands
data = d.status()
# Show status of first controlled switch on device
print('Dictionary %r' % data)
print(gw.status())
d.turn_on() however it doesn't do what I'm expecting:
At this point I'm a little bit stuck. What could I try? Thanks, |
Beta Was this translation helpful? Give feedback.
Answered by
uzlonewolf
Mar 10, 2023
Replies: 1 comment 2 replies
-
Try setting d = tinytuya.OutletDevice('id-of-socket', cid='7cb94c77c7c10000', parent=gw) |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
originalstocksy
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Try setting
cid
to thenode_id
from devices.json.