jasonacox / tinytuya

Python API for Tuya WiFi smart devices using a direct local area network (LAN) connection or the cloud (TuyaCloud API).
MIT License
879 stars 159 forks source link

Zigbee childs error #361

Open knob2001 opened 1 year ago

knob2001 commented 1 year ago

Hi.

I'm trying to add a child as the example:

zigbee1 = tinytuya.OutletDevice(access_key_from_tuya_secret_key, cid_from_devices_json, parent=gw)

The Zigbee GW is working just fine (GW IP found) but there is no payload. I don't know if that means the device is not reachable. {'Error': 'Unexpected Payload from Device', 'Err': '904', 'Payload': None}

BTW, I don't understand this "Every dev_id must be unique!". dev_id is the same as cid? checking inside the html post form from tuya I think I have the correct DeviceId... but that's the same as the cid. :)

Thanks!

knob2001 commented 1 year ago

Ok. It was the version. Updating it to 3.4 instead now it seems to talk to the device. But the error now says: (False, {'Error': 'Invalid JSON Response from Device', 'Err': '900', 'Payload': 'devid not found'})

Keep digging :)

jasonacox commented 1 year ago

Can you paste the code you are using?

Also, what do you get when you run?

python3 -m tinytuya scan
uzlonewolf commented 1 year ago

Hi @knob2001

zigbee1 = tinytuya.OutletDevice(access_key_from_tuya_secret_key, cid_from_devices_json, parent=gw)

I don't know if you just omitted it when posting the above, but the cid must be passed as cid=cid_from_devices_json (the cid= part is important).

I don't understand this "Every dev_id must be unique!". dev_id is the same as cid?

For Zigbee devices the dev_id is mostly ignored. It's only used to direct responses to the correct child device, so you can put anything you want there as long as every device has a different value. The cid is good to use as it's (probably) unique.

uzlonewolf commented 1 year ago

Hi @knob2001, are you still having issues with this?

knob2001 commented 1 year ago

Hi!

Sorry for not answering earlier :) I'm dealing with other projects. But I'm pretty sure it was my fault. The device is a temperature sensor, so the raw data is formatted differently from what the JSON parser expected. I've seen that there are some libraries for various Tuya devices... I need to sit down and check the data coming out from the sensor to find some compatible external library (or write it myself)