tixi / Domoticz-Tuya-SmartPlug-Plugin

Domoticz Python Plugin for Tuya Smart Plug
MIT License
22 stars 24 forks source link

Power/Ampere/Current Support #5

Open loglux opened 5 years ago

loglux commented 5 years ago

I have a tuya smart plug with energy meter. https://www.amazon.co.uk/gp/product/B07K24QZHN/ref=ppx_yo_dt_b_asin_title_o00__o00_s00?ie=UTF8&psc=1

I managed to get work this plugin in Domoticz but it can only turn off and on and doesn't provide information from the meter.

The get_dps.py request returns info from the meter, I guess:

`domoticz@housespririt:~/domoticz/plugins/Domoticz-Tuya-SmartPlug-Plugin$ sudo python3 get_dps.py 192.168.10.172 11444708600194c04232

Plug State Information: {'dps': {'1': False, '5': 0, '2': 0, '6': 2385, '4': 0}, 'devId': '11444708600194c04232'}

Plug DPS List: 1 domoticz@housespririt:~/domoticz/plugins/Domoticz-Tuya-SmartPlug-Plugin$`

tixi commented 5 years ago

When the plug is on should be more useful.

loglux commented 5 years ago

I'll try to plug it again under the real load and see again what happens.

loglux commented 5 years ago

Just a laptop

domoticz@housespririt:~/domoticz/plugins/Domoticz-Tuya-SmartPlug-Plugin$ sudo python3 get_dps.py 192.168.10.172 11444708600194c04232

Plug State Information:
{'dps': {'5': 0, '1': False, '2': 0, '4': 0, '6': 2403}, 'devId': '11444708600194c04232'}

Plug DPS List:
1
domoticz@housespririt:~/domoticz/plugins/Domoticz-Tuya-SmartPlug-Plugin$ sudo python3 get_dps.py 192.168.10.172 11444708600194c04232

Plug State Information:
{'devId': '11444708600194c04232', 'dps': {'1': True, '5': 224, '6': 2400, '2': 0, '4': 160}}

Plug DPS List:
1
domoticz@housespririt:~/domoticz/plugins/Domoticz-Tuya-SmartPlug-Plugin$ sudo python3 get_dps.py 192.168.10.172 11444708600194c04232

Plug State Information:
{'devId': '11444708600194c04232', 'dps': {'1': True, '6': 2400, '4': 181, '2': 0, '5': 267}}

Plug DPS List:
1
domoticz@housespririt:~/domoticz/plugins/Domoticz-Tuya-SmartPlug-Plugin$ sudo python3 get_dps.py 192.168.10.172 11444708600194c04232

Plug State Information:
{'dps': {'2': 0, '1': True, '5': 236, '4': 169, '6': 2400}, 'devId': '11444708600194c04232'}

Plug DPS List:
1
domoticz@housespririt:~/domoticz/plugins/Domoticz-Tuya-SmartPlug-Plugin$
loglux commented 5 years ago

about 2KW Oil Radiator:

domoticz@housespririt:~/domoticz/plugins/Domoticz-Tuya-SmartPlug-Plugin$ sudo python3 get_dps.py 192.168.10.172 11444708600194c04232

Plug State Information:
{'devId': '11444708600194c04232', 'dps': {'4': 8739, '6': 2373, '1': True, '5': 20433, '2': 0}}

Plug DPS List:
1
domoticz@housespririt:~/domoticz/plugins/Domoticz-Tuya-SmartPlug-Plugin$ sudo python3 get_dps.py 192.168.10.172 11444708600194c04232

Plug State Information:
{'dps': {'6': 2373, '5': 20433, '2': 0, '1': True, '4': 8739}, 'devId': '11444708600194c04232'}

Plug DPS List:
1
domoticz@housespririt:~/domoticz/plugins/Domoticz-Tuya-SmartPlug-Plugin$ sudo python3 get_dps.py 192.168.10.172 11444708600194c04232

Plug State Information:
{'dps': {'6': 2373, '4': 8739, '2': 0, '5': 20433, '1': True}, 'devId': '11444708600194c04232'}

Plug DPS List:
1
domoticz@housespririt:~/domoticz/plugins/Domoticz-Tuya-SmartPlug-Plugin$ sudo python3 get_dps.py 192.168.10.172 11444708600194c04232

Plug State Information:
{'dps': {'1': True, '6': 2373, '5': 20433, '4': 8739, '2': 0}, 'devId': '11444708600194c04232'}

Plug DPS List:
1
domoticz@housespririt:~/domoticz/plugins/Domoticz-Tuya-SmartPlug-Plugin$ sudo python3 get_dps.py 192.168.10.172 11444708600194c04232

Plug State Information:
{'dps': {'1': True, '5': 20433, '2': 0, '6': 2373, '4': 8739}, 'devId': '11444708600194c04232'}

Plug DPS List:
1
domoticz@housespririt:~/domoticz/plugins/Domoticz-Tuya-SmartPlug-Plugin$ sudo python3 get_dps.py 192.168.10.172 11444708600194c04232

Plug State Information:
{'dps': {'1': True, '2': 0, '4': 8739, '5': 20433, '6': 2373}, 'devId': '11444708600194c04232'}

Plug DPS List:
1
domoticz@housespririt:~/domoticz/plugins/Domoticz-Tuya-SmartPlug-Plugin$
loglux commented 5 years ago

So, '6' is Voltage - 2385 '5' is Power - 20334 '4' is obviously Current - 8686

Of course, we must take into considiration that there is must be a coma, which is missing here.

20334 (Voltage) / 2385 (Power) = 8.525786163522013 (Current) 20334 / 8686 = 2.341008519456597 (Voltage)

2385 * 8686 = 20716110 (Power)

dorenberg commented 5 years ago

I have a lonsonho plug where DPS is:

104 = current in mA 105 = power in W (has to be divided by 10) 106 = voltage (has to be divided by 10)

I don;t know how to check for the cumulative usage of the plug in kWh for the day and in total. So maybe good to make the input variable.

dorenberg commented 5 years ago

historical information is also found in the json output. 0.02 is in kWh of today. 0.43 is total. Can we use this too for domoticz?

{ "result": { "thisDay": "0.02", "sum": "0.43", "years": { "2019": { "02": "0.43" } } }, "t": 1549792047291, "success": true, "status": "ok" } --