Python Plugin: TUYA

Python and python framework

Moderator: leecollings

Chimeras
Posts: 2
Joined: Thursday 03 June 2021 14:56
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python Plugin: TUYA

Post by Chimeras »

Does anyone now if the Tuya Smart IR (WIFI to IR) is also controllable via this Domoticz plugin.
I would like to control my airco with this module, but it would be an extra if this is possible directly via Domoticz instead of the Smart Life app.
User avatar
Xenomes
Posts: 379
Joined: Tuesday 27 November 2018 19:05
Target OS: Linux
Domoticz version: 2024.7
Location: Netherlands
Contact:

Re: Python Plugin: TUYA

Post by Xenomes »

Chimeras wrote: Thursday 03 June 2021 14:58 Does anyone now if the Tuya Smart IR (WIFI to IR) is also controllable via this Domoticz plugin.
I would like to control my airco with this module, but it would be an extra if this is possible directly via Domoticz instead of the Smart Life app.
If it is connected to the Smart Life app you can configure and run the "debug_discovery.py" in the tools directory. you can see if it is detected. The climate part of the plug-in is still in development. I don't have the device so I am do it on feedback of others.
HP T630 (32GB SSD/8GB Mem) - Ubuntu 22.04.4 LTS (64Bit) - Domoticz 2024.7 with Machinon theme - RFLink - KaKu - Sonoff - Tasmota - Shelly - MQTT2Zigbee - OpenTherm Gateway - Tinytuya - IR Blaster - P1 Smart Meter - NPN Watermeter - Google Assistant
Chimeras
Posts: 2
Joined: Thursday 03 June 2021 14:56
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python Plugin: TUYA

Post by Chimeras »

Thanks. I just ran the script, but the devices are not shown. They are connected to the Smart life app however.
Can I be of assistence to provide you with some more information to be able to support devices like these?

I just found out that when I add a "Tap-to-Run" scene in the Smart Life app, these scenes are being showed. This gives me a workaround, but it's not optimal.
manjh
Posts: 708
Joined: Saturday 27 February 2016 12:49
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: NL
Contact:

Re: Python Plugin: TUYA

Post by manjh »

I'm using the plugin for a while now, with 9 LSC lamps. Ran into a few problems, sometimes the lamps are unusable after a restart of my R-Pi. It is easy to fix: simply go to the hardware page, disable the plugin, and the enable it again. This brings everything back to life.
But it is inconvenient since I have to be logged on to do this. Would it be possible to automate this in the plugin? If no lights are received, simply reset and try again?
Hans
User avatar
Xenomes
Posts: 379
Joined: Tuesday 27 November 2018 19:05
Target OS: Linux
Domoticz version: 2024.7
Location: Netherlands
Contact:

Re: Python Plugin: TUYA

Post by Xenomes »

Chimeras wrote: Saturday 05 June 2021 23:12 Thanks. I just ran the script, but the devices are not shown. They are connected to the Smart life app however.
Can I be of assistence to provide you with some more information to be able to support devices like these?

I just found out that when I add a "Tap-to-Run" scene in the Smart Life app, these scenes are being showed. This gives me a workaround, but it's not optimal.
If the "debug_discovery.py" device section in the json is empty the device is not supported by the older Tuya /homeassistant API see https://github.com/PaulAnnekov/tuyaha#h ... our-device
There is a new one in the make but I don't know if its compatible with current plug-in.
HP T630 (32GB SSD/8GB Mem) - Ubuntu 22.04.4 LTS (64Bit) - Domoticz 2024.7 with Machinon theme - RFLink - KaKu - Sonoff - Tasmota - Shelly - MQTT2Zigbee - OpenTherm Gateway - Tinytuya - IR Blaster - P1 Smart Meter - NPN Watermeter - Google Assistant
User avatar
Xenomes
Posts: 379
Joined: Tuesday 27 November 2018 19:05
Target OS: Linux
Domoticz version: 2024.7
Location: Netherlands
Contact:

Re: Python Plugin: TUYA

Post by Xenomes »

manjh wrote: Tuesday 08 June 2021 22:50 I'm using the plugin for a while now, with 9 LSC lamps. Ran into a few problems, sometimes the lamps are unusable after a restart of my R-Pi. It is easy to fix: simply go to the hardware page, disable the plugin, and the enable it again. This brings everything back to life.
But it is inconvenient since I have to be logged on to do this. Would it be possible to automate this in the plugin? If no lights are received, simply reset and try again?
I don't have this issue, what is the version of your plugin and Tuyaha?

edit:
If you restart you PI often, maybe a virtual button with this command and off course one with true.

Code: Select all

/json.htm?type=command&param=updatehardware&htype=<type>&name=<name>&enabled=false&idx=<hardware idx>
source:https://www.domoticz.com/wiki/Domoticz_ ... e_hardware
HP T630 (32GB SSD/8GB Mem) - Ubuntu 22.04.4 LTS (64Bit) - Domoticz 2024.7 with Machinon theme - RFLink - KaKu - Sonoff - Tasmota - Shelly - MQTT2Zigbee - OpenTherm Gateway - Tinytuya - IR Blaster - P1 Smart Meter - NPN Watermeter - Google Assistant
manjh
Posts: 708
Joined: Saturday 27 February 2016 12:49
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: NL
Contact:

Re: Python Plugin: TUYA

Post by manjh »

Xenomes wrote: Wednesday 09 June 2021 11:05
manjh wrote: Tuesday 08 June 2021 22:50 I'm using the plugin for a while now, with 9 LSC lamps. Ran into a few problems, sometimes the lamps are unusable after a restart of my R-Pi. It is easy to fix: simply go to the hardware page, disable the plugin, and the enable it again. This brings everything back to life.
But it is inconvenient since I have to be logged on to do this. Would it be possible to automate this in the plugin? If no lights are received, simply reset and try again?
I don't have this issue, what is the version of your plugin and Tuyaha?

edit:
If you restart you PI often, maybe a virtual button with this command and off course one with true.

Code: Select all

/json.htm?type=command&param=updatehardware&htype=<type>&name=<name>&enabled=false&idx=<hardware idx>
source:https://www.domoticz.com/wiki/Domoticz_ ... e_hardware
Good, this is a nice pragmatic approach. My only problem is how do I get this into a switch? I tried the on/off action, but the text turns red and I cannot save. Alternative is to put it into a lua script and have the switch trigger that. But in both cases: how?
Preferably, how do I issue a json command from LUA?
Hans
User avatar
Xenomes
Posts: 379
Joined: Tuesday 27 November 2018 19:05
Target OS: Linux
Domoticz version: 2024.7
Location: Netherlands
Contact:

Re: Python Plugin: TUYA

Post by Xenomes »

manjh wrote: Wednesday 09 June 2021 16:54 Good, this is a nice pragmatic approach. My only problem is how do I get this into a switch? I tried the on/off action, but the text turns red and I cannot save. Alternative is to put it into a lua script and have the switch trigger that. But in both cases: how?
Preferably, how do I issue a json command from LUA?
U need to put http://<127.0.0.1 or IP>:<port>/json.htm?type=command&param=updatehardware&htype=<type>&name=<name>&enabled=false&idx=<hardware idx>

You need to change IP, port, type, name and hardware idx in your setting, and that url you can put in the on/off switch.
HP T630 (32GB SSD/8GB Mem) - Ubuntu 22.04.4 LTS (64Bit) - Domoticz 2024.7 with Machinon theme - RFLink - KaKu - Sonoff - Tasmota - Shelly - MQTT2Zigbee - OpenTherm Gateway - Tinytuya - IR Blaster - P1 Smart Meter - NPN Watermeter - Google Assistant
manjh
Posts: 708
Joined: Saturday 27 February 2016 12:49
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: NL
Contact:

Re: Python Plugin: TUYA

Post by manjh »

Xenomes wrote: Wednesday 09 June 2021 17:18
manjh wrote: Wednesday 09 June 2021 16:54 Good, this is a nice pragmatic approach. My only problem is how do I get this into a switch? I tried the on/off action, but the text turns red and I cannot save. Alternative is to put it into a lua script and have the switch trigger that. But in both cases: how?
Preferably, how do I issue a json command from LUA?
U need to put http://<127.0.0.1 or IP>:<port>/json.htm?type=command&param=updatehardware&htype=<type>&name=<name>&enabled=false&idx=<hardware idx>

You need to change IP, port, type, name and hardware idx in your setting, and that url you can put in the on/off switch.
OK, that helps. I am now able to disable the Tuya hardware line. But I have not been able to enable it again... I thought I could get away with changing the "enabled=false" into "enabled=true", but that does not work.
I checked the wiki, it shows a different json command to enable the hardware, including port and loglevel. But neither of these can be seen in the hardware overview...
These are the commands I now have:

Code: Select all

http://127.0.0.1:8080/json.htm?type=command&param=updatehardware&htype=TUYA&name=Tuya_devices&enabled=true&idx=22
http://127.0.0.1:8080/json.htm?type=command&param=updatehardware&htype=TUYA&name=Tuya_devices&enabled=false&idx=22
Hans
User avatar
Xenomes
Posts: 379
Joined: Tuesday 27 November 2018 19:05
Target OS: Linux
Domoticz version: 2024.7
Location: Netherlands
Contact:

Re: Python Plugin: TUYA

Post by Xenomes »

manjh wrote: Wednesday 09 June 2021 18:01 OK, that helps. I am now able to disable the Tuya hardware line. But I have not been able to enable it again... I thought I could get away with changing the "enabled=false" into "enabled=true", but that does not work.
I checked the wiki, it shows a different json command to enable the hardware, including port and loglevel. But neither of these can be seen in the hardware overview...
These are the commands I now have:

Code: Select all

http://127.0.0.1:8080/json.htm?type=command&param=updatehardware&htype=TUYA&name=Tuya_devices&enabled=true&idx=22
http://127.0.0.1:8080/json.htm?type=command&param=updatehardware&htype=TUYA&name=Tuya_devices&enabled=false&idx=22
The enable command bricked my system! .... I think it not a great idea ... please ignore it!

edit:
It removed all data in the hardware, had to recreate it with sqllite
HP T630 (32GB SSD/8GB Mem) - Ubuntu 22.04.4 LTS (64Bit) - Domoticz 2024.7 with Machinon theme - RFLink - KaKu - Sonoff - Tasmota - Shelly - MQTT2Zigbee - OpenTherm Gateway - Tinytuya - IR Blaster - P1 Smart Meter - NPN Watermeter - Google Assistant
manjh
Posts: 708
Joined: Saturday 27 February 2016 12:49
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: NL
Contact:

Re: Python Plugin: TUYA

Post by manjh »

Xenomes wrote: Wednesday 09 June 2021 21:30
manjh wrote: Wednesday 09 June 2021 18:01 OK, that helps. I am now able to disable the Tuya hardware line. But I have not been able to enable it again... I thought I could get away with changing the "enabled=false" into "enabled=true", but that does not work.
I checked the wiki, it shows a different json command to enable the hardware, including port and loglevel. But neither of these can be seen in the hardware overview...
These are the commands I now have:

Code: Select all

http://127.0.0.1:8080/json.htm?type=command&param=updatehardware&htype=TUYA&name=Tuya_devices&enabled=true&idx=22
http://127.0.0.1:8080/json.htm?type=command&param=updatehardware&htype=TUYA&name=Tuya_devices&enabled=false&idx=22
The enable command bricked my system! .... I think it not a great idea ... please ignore it!

edit:
It removed all data in the hardware, had to recreate it with sqllite
Same here. The Tuya hardware line suddenly had a totally different type. I had to remove it, and re-install. Not a big deal, except that it also removed all nine LSC lamps that I had added, including all references in scenes and so on. Took me some time to get it back together. :?
So: this is not worth the risk... when it happens again, I will simply disable and re-enable the hardware line. Safe and quick.
Hans
User avatar
Xenomes
Posts: 379
Joined: Tuesday 27 November 2018 19:05
Target OS: Linux
Domoticz version: 2024.7
Location: Netherlands
Contact:

Re: Python Plugin: TUYA

Post by Xenomes »

manjh wrote: Thursday 10 June 2021 17:10 Same here. The Tuya hardware line suddenly had a totally different type. I had to remove it, and re-install. Not a big deal, except that it also removed all nine LSC lamps that I had added, including all references in scenes and so on. Took me some time to get it back together. :?
So: this is not worth the risk... when it happens again, I will simply disable and re-enable the hardware line. Safe and quick.
We found a bug 😅, why didn't you restore a backup? But I find it still strange that you have to restart the plug-in, on my live and test system I can start Domoticz and the plug-in start a minute later without any problem/error.

Edit:
The bug is fixed in the beta.
HP T630 (32GB SSD/8GB Mem) - Ubuntu 22.04.4 LTS (64Bit) - Domoticz 2024.7 with Machinon theme - RFLink - KaKu - Sonoff - Tasmota - Shelly - MQTT2Zigbee - OpenTherm Gateway - Tinytuya - IR Blaster - P1 Smart Meter - NPN Watermeter - Google Assistant
technoholic
Posts: 18
Joined: Monday 23 November 2015 12:37
Target OS: Windows
Domoticz version:
Contact:

Re: Python Plugin: TUYA

Post by technoholic »

My diffuser has been working flawlessly since you helped me Xenomes, until right now and it's just stopped being controllable or appearing in the system, it can't find the device it seems

2021-06-10 22:00:16.579 Error: Tuya: (Tuya) Command for DeviceID=bf2c8d53f615c4c2d0twpi but device is offline.
DEV name=Smart Aroma Diffuser state=False id=bf2c8d53f615c4c2d0twpi online=False
2021-06-10 22:01:01.014 Tuya: (Tuya) Pushing 'onHeartbeatCallback' on to queue
2021-06-10 22:01:01.077 (Tuya) Processing 'onHeartbeatCallback' message
2021-06-10 22:01:01.077 Tuya: (Tuya) Calling message handler 'onHeartbeat'.

Any ideas at all?

Tahnks
manjh
Posts: 708
Joined: Saturday 27 February 2016 12:49
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: NL
Contact:

Re: Python Plugin: TUYA

Post by manjh »

Xenomes wrote: Thursday 10 June 2021 19:55
manjh wrote: Thursday 10 June 2021 17:10 Same here. The Tuya hardware line suddenly had a totally different type. I had to remove it, and re-install. Not a big deal, except that it also removed all nine LSC lamps that I had added, including all references in scenes and so on. Took me some time to get it back together. :?
So: this is not worth the risk... when it happens again, I will simply disable and re-enable the hardware line. Safe and quick.
We found a bug 😅, why didn't you restore a backup? But I find it still strange that you have to restart the plug-in, on my live and test system I can start Domoticz and the plug-in start a minute later without any problem/error.

Edit:
The bug is fixed in the beta.
Restoring is not simple, I first have to copy the latest image from my NAS, then bring down the Pi and remove the SSD, then burn the image onto the SSD and start the whole circus up again. After that restore the latest Domoticz and Node-Red data.
If it is necessary, then yes: I'll do it. But in this case simply removing and adding the plugin was OK, with a little work to add all lamps again.

As for the reason: this has happened twice, cannot see any root cause.

Yesterday evening another strange thing: when we went to bed I started my "lights off" scene. All lights went out except the Tuya lamps. Log showed "device not available". Restarting the plugin did not help.
So I switched the lamps off using the Tuya app on my phone and went to bed.
This morning, everything was back to normal... problem went away on it's own!
Hans
manjh
Posts: 708
Joined: Saturday 27 February 2016 12:49
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: NL
Contact:

Re: Python Plugin: TUYA

Post by manjh »

technoholic wrote: Thursday 10 June 2021 23:03 My diffuser has been working flawlessly since you helped me Xenomes, until right now and it's just stopped being controllable or appearing in the system, it can't find the device it seems

2021-06-10 22:00:16.579 Error: Tuya: (Tuya) Command for DeviceID=bf2c8d53f615c4c2d0twpi but device is offline.
DEV name=Smart Aroma Diffuser state=False id=bf2c8d53f615c4c2d0twpi online=False
2021-06-10 22:01:01.014 Tuya: (Tuya) Pushing 'onHeartbeatCallback' on to queue
2021-06-10 22:01:01.077 (Tuya) Processing 'onHeartbeatCallback' message
2021-06-10 22:01:01.077 Tuya: (Tuya) Calling message handler 'onHeartbeat'.

Any ideas at all?

Tahnks
This was last night, around 22:00! Later that night I had similar problems switching my Tuya lamps off. Could it be a problem in the Tuya server somehow?
Hans
technoholic
Posts: 18
Joined: Monday 23 November 2015 12:37
Target OS: Windows
Domoticz version:
Contact:

Re: Python Plugin: TUYA

Post by technoholic »

Yes it must have been, as it's working today again, and also the app wasn't working yesterday either so must have been a server issue
User avatar
Xenomes
Posts: 379
Joined: Tuesday 27 November 2018 19:05
Target OS: Linux
Domoticz version: 2024.7
Location: Netherlands
Contact:

Re: Python Plugin: TUYA

Post by Xenomes »

manjh wrote: Friday 11 June 2021 10:38
technoholic wrote: Thursday 10 June 2021 23:03 My diffuser has been working flawlessly since you helped me Xenomes, until right now and it's just stopped being controllable or appearing in the system, it can't find the device it seems

2021-06-10 22:00:16.579 Error: Tuya: (Tuya) Command for DeviceID=bf2c8d53f615c4c2d0twpi but device is offline.
DEV name=Smart Aroma Diffuser state=False id=bf2c8d53f615c4c2d0twpi online=False
2021-06-10 22:01:01.014 Tuya: (Tuya) Pushing 'onHeartbeatCallback' on to queue
2021-06-10 22:01:01.077 (Tuya) Processing 'onHeartbeatCallback' message
2021-06-10 22:01:01.077 Tuya: (Tuya) Calling message handler 'onHeartbeat'.

Any ideas at all?

Tahnks
This was last night, around 22:00! Later that night I had similar problems switching my Tuya lamps off. Could it be a problem in the Tuya server somehow?
Maybe they updated the API 🤣 (sarcasm)
HP T630 (32GB SSD/8GB Mem) - Ubuntu 22.04.4 LTS (64Bit) - Domoticz 2024.7 with Machinon theme - RFLink - KaKu - Sonoff - Tasmota - Shelly - MQTT2Zigbee - OpenTherm Gateway - Tinytuya - IR Blaster - P1 Smart Meter - NPN Watermeter - Google Assistant
User avatar
Xenomes
Posts: 379
Joined: Tuesday 27 November 2018 19:05
Target OS: Linux
Domoticz version: 2024.7
Location: Netherlands
Contact:

Re: Python Plugin: TUYA

Post by Xenomes »

manjh wrote: Friday 11 June 2021 10:37 Restoring is not simple, I first have to copy the latest image from my NAS, then bring down the Pi and remove the SSD, then burn the image onto the SSD and start the whole circus up again. After that restore the latest Domoticz and Node-Red data.
If it is necessary, then yes: I'll do it. But in this case simply removing and adding the plugin was OK, with a little work to add all lamps again.

As for the reason: this has happened twice, cannot see any root cause.

Yesterday evening another strange thing: when we went to bed I started my "lights off" scene. All lights went out except the Tuya lamps. Log showed "device not available". Restarting the plugin did not help.
So I switched the lamps off using the Tuya app on my phone and went to bed.
This morning, everything was back to normal... problem went away on it's own!
no I meant the restore a db file.
stop domoticz
rename domiticz.db to domiticz.db.bak
remove domoticz.db-shm and domoticz.db-wal
copy db from backups/hourly/.. to ./domiticz.db
start domoticz
domoticz restored 🎉🎉🎉
HP T630 (32GB SSD/8GB Mem) - Ubuntu 22.04.4 LTS (64Bit) - Domoticz 2024.7 with Machinon theme - RFLink - KaKu - Sonoff - Tasmota - Shelly - MQTT2Zigbee - OpenTherm Gateway - Tinytuya - IR Blaster - P1 Smart Meter - NPN Watermeter - Google Assistant
User avatar
Varazir
Posts: 360
Joined: Friday 20 February 2015 22:23
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Contact:

Re: Python Plugin: TUYA

Post by Varazir »

I have bought a Cleverio AF-F100 and installed this plugin.
The plugin finds it as a fan and can turn it off and on but the fan has more features.
Is there a way I can add them ?
Raspberry PI 2 with RaZberry Controller 2016 ZWave+ and CC2531(zigbee)
Several IKEA devices/z-wave devices
User avatar
Xenomes
Posts: 379
Joined: Tuesday 27 November 2018 19:05
Target OS: Linux
Domoticz version: 2024.7
Location: Netherlands
Contact:

Re: Python Plugin: TUYA

Post by Xenomes »

Varazir wrote: Tuesday 15 June 2021 18:43 I have bought a Cleverio AF-F100 and installed this plugin.
The plugin finds it as a fan and can turn it off and on but the fan has more features.
Is there a way I can add them ?
Maybe there are more functions to control, can you configure and run the "debug_discovery.py" in the tool directory and list the json output here.
HP T630 (32GB SSD/8GB Mem) - Ubuntu 22.04.4 LTS (64Bit) - Domoticz 2024.7 with Machinon theme - RFLink - KaKu - Sonoff - Tasmota - Shelly - MQTT2Zigbee - OpenTherm Gateway - Tinytuya - IR Blaster - P1 Smart Meter - NPN Watermeter - Google Assistant
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest