codetheweb / tuyapi

🌧 An easy-to-use API for devices that use Tuya's cloud services. Documentation: https://codetheweb.github.io/tuyapi.
MIT License
2.07k stars 341 forks source link

ZMAI-90 returns DPs without useful info #566

Closed Heler closed 2 years ago

Heler commented 2 years ago

Hello! I bought ZMAI-90 WiFi Smart Meter. When I try to receive DPs from the device by using code of tuyapi's ReadMe - I get it:

Connected to device! DATA from device: { dps: { '1': 20, '10': 0, '12': false, '13': 0, '16': true } } Disconnected from device.

DP 1 - it is energy consumption DP16 - it is a state of relay

The values of other DPs are static. How can I receive other info? (Current Watt, Current A, Volatge)

P.S. "tuyadebug" shows the same result.

codetheweb commented 2 years ago

Sometimes there's data shown in the app that's unavailable over the local protocol. There's also "hidden" DPS keys that only report state if you specifically ask for them (not a good way to find these except through fuzzing).

Heler commented 2 years ago

Sometimes there's data shown in the app that's unavailable over the local protocol. There's also "hidden" DPS keys that only report state if you specifically ask for them (not a good way to find these except through fuzzing).

How can I request a specific DP? I will try to get data through fuzzing.

codetheweb commented 2 years ago

Something like .get({dps: 2}).

Heler commented 2 years ago
    device.get({dps: 1})
    device.get({dps: 2})
    device.get({dps: 3})
    device.get({dps: 4})
    device.get({dps: 5})
    device.get({dps: 6})
    device.get({dps: 7})
    device.get({dps: 8})
    device.get({dps: 9})
    device.get({dps: 10})
    device.get({dps: 11})
    device.get({dps: 12})
    device.get({dps: 13})
    device.get({dps: 14})
    device.get({dps: 15})
    device.get({dps: 16})
    device.get({dps: 17})
    device.get({dps: 18})
    device.get({dps: 19})
    device.get({dps: 20})
    device.get({dps: 21})
    device.get({dps: 22})
    device.get({dps: 23})
    device.get({dps: 24})

The result:

Connected to device!
DATA from device:  { dps: { '1': 20, '10': 0, '12': false, '13': 0, '16': true } }
DATA from device:  { dps: { '1': 20, '10': 0, '12': false, '13': 0, '16': true } }
DATA from device:  { dps: { '1': 20, '10': 0, '12': false, '13': 0, '16': true } }
DATA from device:  { dps: { '1': 20, '10': 0, '12': false, '13': 0, '16': true } }
DATA from device:  { dps: { '1': 20, '10': 0, '12': false, '13': 0, '16': true } }
DATA from device:  { dps: { '1': 20, '10': 0, '12': false, '13': 0, '16': true } }
DATA from device:  { dps: { '1': 20, '10': 0, '12': false, '13': 0, '16': true } }
DATA from device:  { dps: { '1': 20, '10': 0, '12': false, '13': 0, '16': true } }
DATA from device:  { dps: { '1': 20, '10': 0, '12': false, '13': 0, '16': true } }
DATA from device:  { dps: { '1': 20, '10': 0, '12': false, '13': 0, '16': true } }
DATA from device:  { dps: { '1': 20, '10': 0, '12': false, '13': 0, '16': true } }
DATA from device:  { dps: { '1': 20, '10': 0, '12': false, '13': 0, '16': true } }
DATA from device:  { dps: { '1': 20, '10': 0, '12': false, '13': 0, '16': true } }
DATA from device:  { dps: { '1': 20, '10': 0, '12': false, '13': 0, '16': true } }
DATA from device:  { dps: { '1': 20, '10': 0, '12': false, '13': 0, '16': true } }
DATA from device:  { dps: { '1': 20, '10': 0, '12': false, '13': 0, '16': true } }
Disconnected from device.
codetheweb commented 2 years ago

My bad, try .refresh({requestedDPS: [...list of IDs]}) instead. (See the docs for more details.)

Heler commented 2 years ago

device.refresh(requestedDPS=[20,21]);

The result:

Connected to device!
DP_REFRESH data from device:  { dps: { '6': 'COIAAAAAAAA=' }, t: 1644179276 }
DP_REFRESH data from device:  { dps: { '17': 'AQAAPAMAAPUEAAC0CAAAHg==' }, t: 1644179277 }
Disconnected from device.

Thank you! ;-)

codetheweb commented 2 years ago

Glad it worked!