Python Plugin: TUYA

Python and python framework

Moderator: leecollings

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 18 March 2021 22:25
manjh wrote: Thursday 18 March 2021 22:22 OK, got it. SHould I post the output here, or do you want it some other way?
If you give the device output that is enough, you can mask any info you want.
Done.
Time for a compliment: your support and (very fast) response is highly appreciated!
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 18 March 2021 22:29 Done.
Time for a compliment: your support and (very fast) response is highly appreciated!
Do my best, Tuya is not the greatest in supporting hardware. But these devices can work under the plug-in. You can put the json there in the forum.
I will pick it up tomorrow, I am going to bed.
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 »

Output is in the post a little higher in this forum.
Good night... :P
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 18 March 2021 22:36 Output is in the post a little higher in this forum.
Found it 👍🏻 i see the problem i need to think how to solve the issue.
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
Vomera
Posts: 184
Joined: Wednesday 06 September 2017 9:11
Target OS: Linux
Domoticz version:
Contact:

Re: Python Plugin: TUYA

Post by Vomera »

I hope it solves also my 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 »

Vomera wrote: Friday 19 March 2021 8:12 I hope it solves also my issue 😆
After the communication in the PM. What kind of issue you have, same as manjh?
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
Vomera
Posts: 184
Joined: Wednesday 06 September 2017 9:11
Target OS: Linux
Domoticz version:
Contact:

Re: Python Plugin: TUYA

Post by Vomera »

Didnt you get my last pm's ?
I send you a bunch of loggings and screenhots :D
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 »

Vomera wrote: Friday 19 March 2021 10:35 Didnt you get my last pm's ?
I send you a bunch of loggings and screenhots :D
Nope, the last one is that you going to try my modified 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
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: Friday 19 March 2021 7:51
manjh wrote: Thursday 18 March 2021 22:36 Output is in the post a little higher in this forum.
Found it 👍🏻 i see the problem i need to think how to solve the issue.
OK, good. Let me know if there is anything I can do, for instance test a modified plugin.
Hans
Vomera
Posts: 184
Joined: Wednesday 06 September 2017 9:11
Target OS: Linux
Domoticz version:
Contact:

Re: Python Plugin: TUYA

Post by Vomera »

Xenomes wrote: Friday 19 March 2021 18:40
Vomera wrote: Friday 19 March 2021 10:35 Didnt you get my last pm's ?
I send you a bunch of loggings and screenhots :D
Nope, the last one is that you going to try my modified plug-in.
ow haha :P nope, i can only trial and error, but i cant write the language haha
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 »

simon_rb wrote: Sunday 07 March 2021 22:00 It takes about 5 mins for changes to reflect in Domoticz if a switch is physically switched or switched using the Smart Life app. Not really an issues if thats the usual delay. Just checking my setup is correct.
Hi simon_rb,

I updated the script, it updates every minute now.
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 »

Xenomes wrote: Friday 19 March 2021 7:51
manjh wrote: Thursday 18 March 2021 22:36 Output is in the post a little higher in this forum.
Found it 👍🏻 i see the problem i need to think how to solve the issue.
The payload is exactly the same, I could do if the light is on white mode the only brightness and temperature and if it is colour then colour, brightness and temperature. Then with a instruction in the readme for RGBWW light before detection set the light on a colour.
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
simon_rb
Posts: 612
Joined: Wednesday 07 August 2013 19:09
Target OS: -
Domoticz version:
Location: UK
Contact:

Re: Python Plugin: TUYA

Post by simon_rb »

Xenomes wrote: Sunday 21 March 2021 21:22 Hi simon_rb,

I updated the script, it updates every minute now.
Hey there Xenomes,

I just updated and its a so much better! Thank you :D
Vomera
Posts: 184
Joined: Wednesday 06 September 2017 9:11
Target OS: Linux
Domoticz version:
Contact:

Re: Python Plugin: TUYA

Post by Vomera »

Vomera wrote: Friday 19 March 2021 19:21
Xenomes wrote: Friday 19 March 2021 18:40
Vomera wrote: Friday 19 March 2021 10:35 Didnt you get my last pm's ?
I send you a bunch of loggings and screenhots :D
Nope, the last one is that you going to try my modified plug-in.
ow haha :P nope, i can only trial and error, but i cant write the language haha
Tried to flash the unit with tasmota, but its says i have the newest firmware on it, and cant flash it.
So i cant use it with domoticz.. :lol:

I bought this one:

https://nl.aliexpress.com/item/10050015 ... 4c4dh1P9nf

Image
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 »

Vomera wrote: Monday 22 March 2021 19:28 Tried to flash the unit with tasmota, but its says i have the newest firmware on it, and cant flash it.
Which tool did you use to try flashing it with Tasmota?
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
Vomera
Posts: 184
Joined: Wednesday 06 September 2017 9:11
Target OS: Linux
Domoticz version:
Contact:

Re: Python Plugin: TUYA

Post by Vomera »

The tool on
https://www.twoenter.nl/blog/domotica/ ... a-convert/
Is it your blog? Because they mention also your plugin tool
Irate
Posts: 2
Joined: Friday 26 March 2021 16:15
Target OS: NAS (Synology & others)
Domoticz version: 2020.2
Location: France
Contact:

Re: Python Plugin: TUYA

Post by Irate »

I have installed the plugin by Xenomes but... some problems with Python3.8
I have a NAS, python 3.8
In my Log, i receive this message
2021-03-26 16:34:46.818 Error: (tuya) failed to load 'plugin.py', Python Path used was '/usr/local/domoticz/var/plugins/Domoticz-TUYA-Plugin-master/:
/var/packages/py3k/target/usr/local/lib/python38.zip:
/var/packages/py3k/target/usr/local/lib/python3.8:
/var/packages/py3k/target/usr/local/lib/python3.8/lib-dynload:
/var/packages/py3k/target/usr/local/lib/python3.8/site-packages'.
But on the NAS, the links are
//volume1/@appstore/domoticz/var/plugins/Domoticz-TUYA-Plugin-master
/volume1/@appstore/py3k/usr/local/lib/python3.8
/volume1/@appstore/py3k/usr/local/lib/python3.8/lib-dynload
/volume1/@appstore/py3k/usr/local/lib/python3.8/site-packages
How to restore the right paths ?
What is my mistake ?
NAS DS716II - Docker - RFX - RFLINK - Mysensors - ZWave
Domoticz 2021.1
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 »

Sorry I don't have a NAS. running and testing on RPI.
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
tontze
Posts: 317
Joined: Thursday 12 January 2017 15:30
Target OS: Linux
Domoticz version: Beta Ch
Location: Finland
Contact:

Re: Python Plugin: TUYA

Post by tontze »

Hm, im trying to use your plugin, but cant seem to get it working .. Here is output of the debug_discovery.py

Code: Select all

Getting credentials
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/requests/models.py", line 382, in prepare_url
    scheme, auth, host, port, path, query, fragment = parse_url(url)
  File "/usr/lib/python3/dist-packages/urllib3/util/url.py", line 392, in parse_url
    return six.raise_from(LocationParseError(source_url), None)
  File "<string>", line 3, in raise_from
urllib3.exceptions.LocationParseError: Failed to parse: https://px1.tuyaeu.com/homeassistant/auth.do

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/tontze/domoticz/plugins/Domoticz-TUYA-Plugin/tools/./debug_discovery.py", line 20, in <module>
    auth_response = requests.post(
  File "/usr/lib/python3/dist-packages/requests/api.py", line 119, in post
    return request('post', url, data=data, json=json, **kwargs)
  File "/usr/lib/python3/dist-packages/requests/api.py", line 61, in request
    return session.request(method=method, url=url, **kwargs)
  File "/usr/lib/python3/dist-packages/requests/sessions.py", line 528, in request
    prep = self.prepare_request(req)
  File "/usr/lib/python3/dist-packages/requests/sessions.py", line 456, in prepare_request
    p.prepare(
  File "/usr/lib/python3/dist-packages/requests/models.py", line 316, in prepare
    self.prepare_url(url, params)
  File "/usr/lib/python3/dist-packages/requests/models.py", line 384, in prepare_url
    raise InvalidURL(*e.args)
requests.exceptions.InvalidURL: Failed to parse: https://px1.tuyaeu.com/homeassistant/auth.do
Domoticz log :

Code: Select all

  2021-03-27 11:44:41.191 Status: Python Plugin System: (Tuya) Started.
2021-03-27 11:44:41.191 Status: Python Plugin System: (Tuya) Entering work loop.
2021-03-27 11:44:41.778 Status: Python Plugin System: (Tuya) Initialized version 1.0.5, author 'Wagner Oliveira'
2021-03-27 11:44:41.789 Error: Python Plugin System: (Tuya) handleThread: Failed to parse: https://px1.tuyaeu.com/homeassistant/auth.do line 196
2021-03-27 11:44:51.093 Python Plugin System: (Tuya) onHeartbeat called time=1616838291.092976
2021-03-27 11:44:51.094 Python Plugin System: (Tuya) in handlethread
2021-03-27 11:44:51.096 Error: Python Plugin System: (Tuya) handleThread: Failed to parse: https://px1.tuyaeu.com/homeassistant/access.do?grant_type=refresh_token&refresh_token= line 199  
-----------------------------------------
Smartthings
zigbee2mqtt
RFLink 433mhz / Nrf 2.4Ghz
Mi Light
esp8266MiLight Hub
OpenHab/HomeAssistant/Domoticz
HP T610 & Debian 5.10.19-1 x86_64[/b]
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 »

tontze wrote: Saturday 27 March 2021 10:39 Hm, im trying to use your plugin, but cant seem to get it working .. Here is output.
It is missing the requests.
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 0 guests