[REQUEST] Plugin for Tuya
Moderator: leecollings
-
- Posts: 110
- Joined: Monday 22 June 2015 20:18
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.10982
- Location: Veghel, The Netherlands
- Contact:
Re: [REQUEST] Plugin for Tuya
Yes, problem solved!!!! Thanks for the help!
-
- Posts: 110
- Joined: Monday 22 June 2015 20:18
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.10982
- Location: Veghel, The Netherlands
- Contact:
Re: [REQUEST] Plugin for Tuya
Is there an option to include the power / voltage / usage of the plug? I am really trying to find out.
-
- Posts: 4
- Joined: Thursday 21 February 2019 23:06
- Target OS: -
- Domoticz version:
- Contact:
Re: [REQUEST] Plugin for Tuya
i have one error from plugin...
Code: Select all
2019-02-22 00:14:34.323 Status: (Tuya) Stopping threads.
2019-02-22 00:14:34.333 Status: (Tuya) Exiting work loop.
2019-02-22 00:14:34.333 Status: (Tuya) Stopped.
2019-02-22 00:14:44.816 Status: (Tuya) Started.
2019-02-22 00:14:44.996 Status: (Tuya) Entering work loop.
2019-02-22 00:14:44.996 Status: (Tuya) Initialized version 3.0.0, author 'tixi'
2019-02-22 00:14:44.998 (Tuya) Debug logging mask set to: NONE
2019-02-22 00:14:45.019 (Tuya) Tuya SmartPlug Device #1 created.
2019-02-22 00:14:45.021 (Tuya) Tuya SmartPlug Device #2 created.
2019-02-22 00:14:45.022 (Tuya) Tuya SmartPlug Device #3 created.
2019-02-22 00:14:45.023 (Tuya) Tuya SmartPlug Device #7 created.
2019-02-22 00:14:45.031 (Tuya) Tuya SmartPlug Device #8 created.
2019-02-22 00:14:45.034 (Tuya) Tuya SmartPlug Device #9 created.
2019-02-22 00:14:45.036 (Tuya) Tuya SmartPlug Device #10 created.
2019-02-22 00:14:45.037 (Tuya) Tuya SmartPlug Device #11 created.
2019-02-22 00:14:45.038 Error: (Tuya) 'onStart' failed 'AttributeError':'module 'pytuya' has no attribute 'OutletDevice''.
2019-02-22 00:14:45.038 Error: (Tuya) ----> Line 498 in /home/alex/domoticz/plugins/Domoticz-Tuya-SmartPlug-Plugin/plugin.py, function onStart
2019-02-22 00:14:45.038 Error: (Tuya) ----> Line 366 in /home/alex/domoticz/plugins/Domoticz-Tuya-SmartPlug-Plugin/plugin.py, function onStart
2019-02-22 00:15:04.502 Error: (Tuya) 'onHeartbeat' failed 'AttributeError':''NoneType' object has no attribute 'Connected''.
2019-02-22 00:15:04.503 Error: (Tuya) ----> Line 522 in /home/alex/domoticz/plugins/Domoticz-Tuya-SmartPlug-Plugin/plugin.py, function onHeartbeat
2019-02-22 00:15:04.503 Error: (Tuya) ----> Line 472 in /home/alex/domoticz/plugins/Domoticz-Tuya-SmartPlug-Plugin/plugin.py, function onHeartbeat
2019-02-22 00:15:04.503 Error: (Tuya) ----> Line 260 in /home/alex/domoticz/plugins/Domoticz-Tuya-SmartPlug-Plugin/plugin.py, function __command_to_execute
2019-02-22 00:15:24.515 Error: (Tuya) 'onHeartbeat' failed 'AttributeError':''NoneType' object has no attribute 'Connected''.
2019-02-22 00:15:24.515 Error: (Tuya) ----> Line 522 in /home/alex/domoticz/plugins/Domoticz-Tuya-SmartPlug-Plugin/plugin.py, function onHeartbeat
2019-02-22 00:15:24.515 Error: (Tuya) ----> Line 472 in /home/alex/domoticz/plugins/Domoticz-Tuya-SmartPlug-Plugin/plugin.py, function onHeartbeat
2019-02-22 00:15:24.515 Error: (Tuya) ----> Line 260 in /home/alex/domoticz/plugins/Domoticz-Tuya-SmartPlug-Plugin/plugin.py, function __command_to_execute
2019-02-22 00:15:44.525 Error: (Tuya) 'onHeartbeat' failed 'AttributeError':''NoneType' object has no attribute 'Connected''.
2019-02-22 00:15:44.525 Error: (Tuya) ----> Line 522 in /home/alex/domoticz/plugins/Domoticz-Tuya-SmartPlug-Plugin/plugin.py, function onHeartbeat
2019-02-22 00:15:44.525 Error: (Tuya) ----> Line 472 in /home/alex/domoticz/plugins/Domoticz-Tuya-SmartPlug-Plugin/plugin.py, function onHeartbeat
2019-02-22 00:15:44.525 Error: (Tuya) ----> Line 260 in /home/alex/domoticz/plugins/Domoticz-Tuya-SmartPlug-Plugin/plugin.py, function __command_to_execute
-
- Posts: 34
- Joined: Tuesday 23 February 2016 9:14
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.9700
- Location: NL
- Contact:
Re: [REQUEST] Plugin for Tuya
Hi,
@dorenberg where did get the json outout of the plug ?
@dorenberg where did get the json outout of the plug ?
-
- Posts: 110
- Joined: Monday 22 June 2015 20:18
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.10982
- Location: Veghel, The Netherlands
- Contact:
Re: [REQUEST] Plugin for Tuya
using the android app "packet capture". In the app you can find packages with the json output.
Have used it to obtain the keys, but all the other information can also be found then.
Have used it to obtain the keys, but all the other information can also be found then.
-
- Posts: 52
- Joined: Monday 10 September 2018 23:49
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: [REQUEST] Plugin for Tuya
Hello,
Some ideas for the KWh:
- you can create a virtual device and then update it with the json api with a curl command
- This command should be inserted in line 425
- To get the needed information state['5'] should work (you may have to divide the value)
5 here correspond to the dps entry 5, depending on your device the value may be different.
Some ideas for the KWh:
- you can create a virtual device and then update it with the json api with a curl command
- This command should be inserted in line 425
- To get the needed information state['5'] should work (you may have to divide the value)
5 here correspond to the dps entry 5, depending on your device the value may be different.
- sincze
- Posts: 1299
- Joined: Monday 02 June 2014 22:46
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2024.4
- Location: Netherlands / Breda Area
- Contact:
Re: [REQUEST] Plugin for Tuya
tixi7 wrote: ↑Saturday 23 February 2019 23:50 Some ideas for the KWh:
- you can create a virtual device and then update it with the json api with a curl command
- This command should be inserted in line 425
- To get the needed information state['5'] should work (you may have to divide the value)
5 here correspond to the dps entry 5, depending on your device the value may be different.
The information is in state indeed. Why not create those additional devices from within the plugin as well just as with the "Switch" when defining a plug?
something like:
Code: Select all
Domoticz.Device(Name="Tuya SmartPlug Switch #" + str(val), Unit=val, TypeName="Switch",Image=8).Create()
Domoticz.Device(Name="Tuya SmartPlug Voltage #" + str(val), Unit=val, TypeName="Voltage").Create()
Domoticz.Device(Name="Tuya SmartPlug Ampere #" + str(val), Unit=val, TypeName="Current/Ampere").Create()
Domoticz.Device(Name="Tuya SmartPlug Usage#" + str(val), Unit=val, TypeName="Usage").Create()
Domoticz.Log("Tuya SmartPlug Device #" + str(val) +" created.")
Pass2php
LAN: RFLink, P1, OTGW, MySensors
USB: RFXCom, ZWave, Sonoff 3
MQTT: ZIgbee2MQTT,
ZWAVE: Zwave-JS-UI
WIFI: Mi-light, Tasmota, Xiaomi Shelly
Solar: Omnik, PVOutput
Video: Kodi, Harmony HUB, Chromecast
Sensors: You name it I got 1.
LAN: RFLink, P1, OTGW, MySensors
USB: RFXCom, ZWave, Sonoff 3
MQTT: ZIgbee2MQTT,
ZWAVE: Zwave-JS-UI
WIFI: Mi-light, Tasmota, Xiaomi Shelly
Solar: Omnik, PVOutput
Video: Kodi, Harmony HUB, Chromecast
Sensors: You name it I got 1.
-
- Posts: 52
- Joined: Monday 10 September 2018 23:49
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: [REQUEST] Plugin for Tuya
Inside the plugin will be better, but i have no time and no device for that. so i put a sketch of solution that is easier to add.sincze wrote: ↑Sunday 24 February 2019 23:19
Why not create those additional devices from within the plugin as well just as with the "Switch" when defining a plug?
something like:And then fill them without using an external json api curl.. call ?Code: Select all
Domoticz.Device(Name="Tuya SmartPlug Switch #" + str(val), Unit=val, TypeName="Switch",Image=8).Create() Domoticz.Device(Name="Tuya SmartPlug Voltage #" + str(val), Unit=val, TypeName="Voltage").Create() Domoticz.Device(Name="Tuya SmartPlug Ampere #" + str(val), Unit=val, TypeName="Current/Ampere").Create() Domoticz.Device(Name="Tuya SmartPlug Usage#" + str(val), Unit=val, TypeName="Usage").Create() Domoticz.Log("Tuya SmartPlug Device #" + str(val) +" created.")
If you have time to add it inside the plugin, go ahead!
- sincze
- Posts: 1299
- Joined: Monday 02 June 2014 22:46
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2024.4
- Location: Netherlands / Breda Area
- Contact:
Re: [REQUEST] Plugin for Tuya
No worries. You did an amazing job to design the plugin without the hardware.tixi7 wrote: ↑Monday 25 February 2019 7:49Inside the plugin will be better, but i have no time and no device for that. so i put a sketch of solution that is easier to add.sincze wrote: ↑Sunday 24 February 2019 23:19
Why not create those additional devices from within the plugin as well just as with the "Switch" when defining a plug?
something like:And then fill them without using an external json api curl.. call ?Code: Select all
Domoticz.Device(Name="Tuya SmartPlug Switch #" + str(val), Unit=val, TypeName="Switch",Image=8).Create() Domoticz.Device(Name="Tuya SmartPlug Voltage #" + str(val), Unit=val, TypeName="Voltage").Create() Domoticz.Device(Name="Tuya SmartPlug Ampere #" + str(val), Unit=val, TypeName="Current/Ampere").Create() Domoticz.Device(Name="Tuya SmartPlug Usage#" + str(val), Unit=val, TypeName="Usage").Create() Domoticz.Log("Tuya SmartPlug Device #" + str(val) +" created.")
If you have time to add it inside the plugin, go ahead!
Many thanks for that. My 'native'' domoticz language is PHP so have to figure out how to do that in python as well.
Pass2php
LAN: RFLink, P1, OTGW, MySensors
USB: RFXCom, ZWave, Sonoff 3
MQTT: ZIgbee2MQTT,
ZWAVE: Zwave-JS-UI
WIFI: Mi-light, Tasmota, Xiaomi Shelly
Solar: Omnik, PVOutput
Video: Kodi, Harmony HUB, Chromecast
Sensors: You name it I got 1.
LAN: RFLink, P1, OTGW, MySensors
USB: RFXCom, ZWave, Sonoff 3
MQTT: ZIgbee2MQTT,
ZWAVE: Zwave-JS-UI
WIFI: Mi-light, Tasmota, Xiaomi Shelly
Solar: Omnik, PVOutput
Video: Kodi, Harmony HUB, Chromecast
Sensors: You name it I got 1.
-
- Posts: 34
- Joined: Tuesday 23 February 2016 9:14
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.9700
- Location: NL
- Contact:
Re: [REQUEST] Plugin for Tuya
We can also test an other plug. I don't know if it has the same numbers. Not quiet sure. Need to test it tonight.
-
- Posts: 110
- Joined: Monday 22 June 2015 20:18
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.10982
- Location: Veghel, The Netherlands
- Contact:
Re: [REQUEST] Plugin for Tuya
If I need to send over the plug to someone for testing purposes, let me know. That will make life much easier. (Based in The Netherlands)
-
- Posts: 34
- Joined: Tuesday 23 February 2016 9:14
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.9700
- Location: NL
- Contact:
Re: [REQUEST] Plugin for Tuya
Hi,
If you do a sudo python3 get_dps.py what is the output of the plug ?
I'm curious about the output.
This is mine.
Plug State Information:
{'dps': {'2': 0, '4': 243, '6': 2392, '5': 42, '1': True}, 'devId': '00621010cc50e3c3d408'}
Then we can see of the DPS is the same.
-
- Posts: 110
- Joined: Monday 22 June 2015 20:18
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.10982
- Location: Veghel, The Netherlands
- Contact:
Re: [REQUEST] Plugin for Tuya
Plug State Information:
{'devId': '12716401807d3a7b5c6b', 'dps': {'6': '00ff0000000000', '4': 255, '106' : 2272, '101': True, '1': True, '2': 'colour', '10': 'ffff0505ff000000ff00ffff00 ff00ff0000ff000000', '7': 'ffff500100ff00', '104': 0, '9': 'ffff5001ff0000', '8' : 'ffff8003ff000000ff000000ff000000000000000000', '3': 180, '5': '171918009c1919 ', '105': 0}}
This is the output. So 104 105 and 106
{'devId': '12716401807d3a7b5c6b', 'dps': {'6': '00ff0000000000', '4': 255, '106' : 2272, '101': True, '1': True, '2': 'colour', '10': 'ffff0505ff000000ff00ffff00 ff00ff0000ff000000', '7': 'ffff500100ff00', '104': 0, '9': 'ffff5001ff0000', '8' : 'ffff8003ff000000ff000000ff000000000000000000', '3': 180, '5': '171918009c1919 ', '105': 0}}
This is the output. So 104 105 and 106
-
- Posts: 34
- Joined: Tuesday 23 February 2016 9:14
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.9700
- Location: NL
- Contact:
Re: [REQUEST] Plugin for Tuya
Is this from a powerplug or light?
-
- Posts: 110
- Joined: Monday 22 June 2015 20:18
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.10982
- Location: Veghel, The Netherlands
- Contact:
Re: [REQUEST] Plugin for Tuya
This is a powerplug with an led light.
Aliexpress lonsonho. 16a 2 pin EU plug with power measurement
Aliexpress lonsonho. 16a 2 pin EU plug with power measurement
-
- Posts: 34
- Joined: Tuesday 23 February 2016 9:14
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.9700
- Location: NL
- Contact:
Re: [REQUEST] Plugin for Tuya
Ah I see it has a night light.
- sincze
- Posts: 1299
- Joined: Monday 02 June 2014 22:46
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2024.4
- Location: Netherlands / Breda Area
- Contact:
Re: [REQUEST] Plugin for Tuya
Based upon the info provided by @jslegers (he has 2 different types of plugs) the following data can be retrieved and keys seem consistent. Next step would be to create the appropriate devices and have the plugin push the data to them.jslegers wrote: ↑Monday 25 February 2019 11:58Hi,
If you do a sudo python3 get_dps.py what is the output of the plug ?
I'm curious about the output.
This is mine.
Plug State Information:
{'dps': {'2': 0, '4': 243, '6': 2392, '5': 42, '1': True}, 'devId': '00621010cc50e3c3d408'}
Then we can see of the DPS is the same.
At least the ordinary plugs should then be working.
Pass2php
LAN: RFLink, P1, OTGW, MySensors
USB: RFXCom, ZWave, Sonoff 3
MQTT: ZIgbee2MQTT,
ZWAVE: Zwave-JS-UI
WIFI: Mi-light, Tasmota, Xiaomi Shelly
Solar: Omnik, PVOutput
Video: Kodi, Harmony HUB, Chromecast
Sensors: You name it I got 1.
LAN: RFLink, P1, OTGW, MySensors
USB: RFXCom, ZWave, Sonoff 3
MQTT: ZIgbee2MQTT,
ZWAVE: Zwave-JS-UI
WIFI: Mi-light, Tasmota, Xiaomi Shelly
Solar: Omnik, PVOutput
Video: Kodi, Harmony HUB, Chromecast
Sensors: You name it I got 1.
-
- Posts: 110
- Joined: Monday 22 June 2015 20:18
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.10982
- Location: Veghel, The Netherlands
- Contact:
Re: [REQUEST] Plugin for Tuya
Maybe these dps values for the power consumption and voltage can be set as input boxes in the plugin?
- sincze
- Posts: 1299
- Joined: Monday 02 June 2014 22:46
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2024.4
- Location: Netherlands / Breda Area
- Contact:
Re: [REQUEST] Plugin for Tuya
You mean something like this:
Pass2php
LAN: RFLink, P1, OTGW, MySensors
USB: RFXCom, ZWave, Sonoff 3
MQTT: ZIgbee2MQTT,
ZWAVE: Zwave-JS-UI
WIFI: Mi-light, Tasmota, Xiaomi Shelly
Solar: Omnik, PVOutput
Video: Kodi, Harmony HUB, Chromecast
Sensors: You name it I got 1.
LAN: RFLink, P1, OTGW, MySensors
USB: RFXCom, ZWave, Sonoff 3
MQTT: ZIgbee2MQTT,
ZWAVE: Zwave-JS-UI
WIFI: Mi-light, Tasmota, Xiaomi Shelly
Solar: Omnik, PVOutput
Video: Kodi, Harmony HUB, Chromecast
Sensors: You name it I got 1.
-
- Posts: 110
- Joined: Monday 22 June 2015 20:18
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.10982
- Location: Veghel, The Netherlands
- Contact:
Re: [REQUEST] Plugin for Tuya
exactly what I meant!! Nearly there!
Who is online
Users browsing this forum: No registered users and 1 guest