Re: [REQUEST] Plugin for Tuya
Posted: Tuesday 19 February 2019 18:01
Yes, problem solved!!!! Thanks for the help!
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
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.
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.")
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.")
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!
Hi,
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.