rospogrigio / localtuya

local handling for Tuya devices
GNU General Public License v3.0
2.83k stars 545 forks source link

Can't get a full DPs from device (ZMAi-90 Energy Meter) #310

Open JayChun opened 3 years ago

JayChun commented 3 years ago

Hello! Thanks to contribute the component. It is really simple and easy to do local tuya! I tried to set it up yesterday for energy meter, the model name is ZMAi-90 from AliExpress (https://www.aliexpress.com/item/4000353269379.html)

Smart Life App shows 4 kinds of sensor data and on/off switch.

But Local Tuya in HA integration shows only 2 kind of DPs - 1 sensor(kWh) and 1 switch.

Additionally I have tried to do Tuya Convert, but the convert couldn't find the device. (or the device doesn't allow the convert's vtrust-flash AP) (refer to this https://www.creationfactory.co/2019/12/reverse-engineering-zmai-90-din-rail.html?m=1)

Is there any solution for using a full DPs via Local Tuya?

ultratoto14 commented 3 years ago

Can you close your tuya app and home assistant and get a full DPS dump using this

JayChun commented 3 years ago

Can you close your tuya app and home assistant and get a full DPS dump using this

Thanks for your response. firstly I shut down HA and mobile phone also power off. And i tried it, but the Test.py also shows just 2 DPs as below.

pi@raspberrypi:~/Downloads/tuyadebug $ ./test.py eb38c23432bdb83c2acltk 192.168.0.32 aab3d9c35623bb0d INFO:localtuya:localtuya version 1.0.0 INFO:localtuya:Python 3.7.3 (default, Apr 3 2019, 05:39:12) [GCC 8.2.0] on linux INFO:localtuya:Using pytuya version '8.1.0' INFO:localtuya:Detecting list of available DPS of device eb38c23432bdb83c2acltk [192.168.0.32], protocol 3.3. DEBUG:localtuya.pytuya:Sending command status (device type: type_0a) DEBUG:localtuya.pytuya:paylod=b'{"gwId":"eb38c23432bdb83c2acltk","devId":"eb38c23432bdb83c2acltk"}' DEBUG:localtuya.pytuya:DATA RECEIVED! DEBUG:localtuya.pytuya:decode payload=b'\xdeYS]\x85}\xeaH@\xa2\x94p\xd2CPZ\x8ed3\xbbm\x8f\xf0Ul/Xzb\xde\xd9' DEBUG:localtuya.pytuya:decrypted result='{"dps":{"1":59,"16":true}}' AVAILABLE DPS ARE [{'1': 59, '16': True}] INFO:localtuya:COMPLETE response from device eb38c23432bdb83c2acltk [192.168.0.32].

deviceInfo returned OK

TuyaDebug (Tuya DPs dump) [1.0.0]

Device eb38c23432bdb83c2acltk at 192.168.0.32 key aab3d9c35623bb0d protocol 3.3 dev_type type_0a: DPS [1] VALUE [59] DPS [16] VALUE [True] `

But a bit strange thing is that I saw another DPs yesterday as below screenshot even the DPs disappeared quickly from HA

image

I don't know "10", but I know exactly "18", it is "imeilmsi" number which is shown at device Setting in Smart Life app.

sangood commented 3 years ago

Thanks ,I have this Energy Meter too. I only get the Crypto raw data ,localtuya can't convert data "CVsAAAAAAAA=" . It contains voltage/current/power .

I can get dps from app:

"dps" : {

"17" : "AQAAPAMAAQgEAACW", #alarm_set_2

"1" : 0, #total_forward_energy

"16" : true, #switch

"6" : "CVsAAAAAAAA=", # voltage/current/power .

"10" : 0, #fault

"18" : "111111111111" #meter_id

},

{"mode":"ro","code":"total_forward_energy","name":"正向总有功电量","property":{"unit":"kW·h","min":0,"max":99999999,"scale":2,"step":1,"type":"value"},"id":1,"type":"obj","desc":""},{"mode":"ro","code":"phase_a","name":"A相电压,电流及功率","id":6,"type":"raw","desc":""},{"mode":"ro","code":"fault","name":"告警事件","property":{"label":["ov_cr","unbalance_alarm","ov_vol","undervoltage_alarm","miss_phase_alarm","outage_alarm","magnetism_alarm","terminal_alarm","cover_alarm","credit_alarm","battery_alarm","meter_hardware_alarm","no_balance_alarm"],"type":"bitmap","maxlen":13},"id":10,"type":"obj","desc":""},{"mode":"rw","code":"switch","name":"电表拉合闸","property":{"type":"bool"},"id":16,"type":"obj","desc":""},{"mode":"rw","code":"alarm_set_2","name":"告警设置","id":17,"type":"raw","desc":""},{"mode":"ro","code":"meter_id","name":"设备号显示 ","property":{"type":"string","maxlen":255},"id":18,"type":"obj","desc":""}

ultratoto14 commented 3 years ago

Maybe it's related to #87

andrkaz commented 3 years ago

Hi. I also have ZMAI-90. No news about decoding this string? "6" : "CVsAAAAAAAA=", # voltage/current/power .

JayChun commented 3 years ago

@andrkaz I also checked the log, but maybe there is still nothing updated.

DEBUG (MainThread) [custom_components.localtuya.pytuya] [eb3...ltk] Decrypted payload: {"dps":{"6":"CKQACA8AANs="},"t":1614219534}

sbcdave commented 3 years ago

I've been digging around trying to find a solution for retrieving the voltage from this device and found this thread. I'm using codetheweb/tuya-cli at the moment to register the device and then using their get operation to pull data from it. I also found kWH in DPs:1, 0 in DPs:10 (might be relay control), true in DPs:16 (might be relay control), and 111111111111 in DPs:18 (imei..)

Anyone have any suggestions how I can get this data out of 6, it just says undefined for me. I'd like to try to decypher it and see if I can find the voltage. CVsAAAAAAAA didn't look very promising, but CKQACA8AANs does

Thanks for any info

sbcdave commented 3 years ago

Anyone know what encoding is used when putting those 11 digit strings into the json?

Symbol84 commented 3 years ago

No news on a solution to this problem zmai-90 ?

pety12321 commented 3 years ago

https://github.com/codetheweb/tuyapi/discussions/440

andrkaz commented 3 years ago

codetheweb/tuyapi#440

Thanks. Dont understand how use this in Home Assistant

sanyatuning commented 3 years ago

Hi! I've created a PR https://github.com/rospogrigio/localtuya/pull/473 based on https://github.com/codetheweb/tuyapi/discussions/440 This is not a perfect solution, till you can't configure with the UI, but I don't really understand why. Does anyone know why the hack some "dps" not visible in the UI (config flow)?