jasonacox / tinytuya

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

Help debugging Wifi Smart Meter , reporting 0 values on DSP when cloud reports correctly #458

Closed fl1ck3r closed 4 months ago

fl1ck3r commented 4 months ago

Hi all,

I am quite new with Tuya devices so apologies if this question is poorly stated.

I have recently received a Wifi Smart meter device, using it to control my geyser of my house. (amazon link to device)

I have connected with it successfully, and I am able to get the current voltage as well as toggle the device switch. However I would love to be able to log and track the consumption data, hence I want to get the Power as well as the Current consumption.

I followed the guide to get the codes on the Device logs on IOT cloud, and have have confirmed them as follows:

Current:18 Power:19 Electricity consumption:17

However running note that my device is protocol v 3.4, hence running the following: `import tinytuya

d = tinytuya.OutletDevice('DEVICE_ID_HERE', 'IP_ADDRESS_HERE', 'LOCAL_KEY_HERE') d.set_version(3.4) data = d.status() print('Device status: %r' % data) `

Outputs:

python3 tuya_test.py Device status: {'dps': {'1': True, '9': 0, '17': 186, '18': 0, '19': 0, '20': 2138, '21': 2, '22': 0, '23': 0, '24': 0, '25': 0, '26': 0, '38': 'on', '40': 'relay', '41': False, '42': ''}}

Note the 0 values for the relevant codes I am looking for. I have confirmed with the Tuya App, as well as a current clamp, that during periods when I expect current draw and power to be reported , I don't get any.

Any advice or suggestions how I can debug this would be greatly appreciated.

jasonacox commented 4 months ago

Hi there!

You might need to add:

d.updatedps(['18','19','20'], nowait=True)

Also, try the monitor script to see if the device only periodically updates for current/power:

https://github.com/jasonacox/tinytuya/blob/master/examples/monitor.py

fl1ck3r commented 4 months ago

updatedps worked perfectly.

Thank you so much! :)