Python Plugin: TUYA

Python and python framework

Moderator: leecollings

Post Reply
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 17 March 2021 22:18 But there is no way to change the color temperature. In the devices tab of Domoticz, the lamps show up as RGB, which is wrong.
Hi Manjh, what is the version of the plug-in you are using?
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 »

How can I find the version number?
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 »

Xenomes wrote: Thursday 18 March 2021 20:13
manjh wrote: Wednesday 17 March 2021 22:18 But there is no way to change the color temperature. In the devices tab of Domoticz, the lamps show up as RGB, which is wrong.
Hi Manjh, what is the version of the plug-in you are using?
Ah, found it in the setup. Tuyaha, version 0.0.6. Downloaded yesterday.
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 »

OK, then you are using the other plug-in. Can you try https://github.com/Xenomes/Domoticz-TUYA-Plugin there are more lights selections.
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: Thursday 18 March 2021 21:33 OK, then you are using the other plug-in. Can you try https://github.com/Xenomes/Domoticz-TUYA-Plugin there are more lights selections.
AH, so I am using the wrong plugin... Should I remove Tuyaha first?
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 21:34 AH, so I am using the wrong plugin... Should I remove Tuyaha first?
the other plug-in has Tuyaha as a git pull, my one has a pip3 install
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: Thursday 18 March 2021 21:36
manjh wrote: Thursday 18 March 2021 21:34 AH, so I am using the wrong plugin... Should I remove Tuyaha first?
the other plug-in has Tuyaha as a git pull, my one has a pip3 install
OK, that was easy.
With your plugin, I can now see a color-circle, but a second one with only warm/cold white. So I can now change the color and dimmer level.
One thing: the device still comes up as RGB. Is that how it was meant to be?
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 21:43 OK, that was easy.
With your plugin, I can now see a color-circle, but a second one with only warm/cold white. So I can now change the color and dimmer level.
One thing: the device still comes up as RGB. Is that how it was meant to be?
Can you run the debug_discovery.py from the tools directory?
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: Thursday 18 March 2021 21:47
manjh wrote: Thursday 18 March 2021 21:43 OK, that was easy.
With your plugin, I can now see a color-circle, but a second one with only warm/cold white. So I can now change the color and dimmer level.
One thing: the device still comes up as RGB. Is that how it was meant to be?
Can you run the debug_discovery.py from the tools directory?
I get:

Code: Select all

Traceback (most recent call last):
File "debug_discovery.py", ;ine 2, in <module>
import requests
ImportError: No module named requests
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 21:59 I get:

Code: Select all

Traceback (most recent call last):
File "debug_discovery.py", ;ine 2, in <module>
import requests
ImportError: No module named requests
Did you install 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
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:00
manjh wrote: Thursday 18 March 2021 21:59 I get:

Code: Select all

Traceback (most recent call last):
File "debug_discovery.py", ;ine 2, in <module>
import requests
ImportError: No module named requests
Did you install requests?
Yes, I followed the instructions to the letter! :D
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 »

I re-ran the pip3 command, and get two lines saying "already satisfied".

I should note: the devices work just fine. But it seems funny to get a full color selector for a device that is white-only... :cry:
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 »

Then you run python ./debug_discovery.py try python3 ./debug_discovery.py
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: Thursday 18 March 2021 22:06 Then you run python ./debug_discovery.py try python3 ./debug_discovery.py
Ah, that's different.

Code: Select all

Getting credentials
Got credentials
{   'errorMsg': 'Get accesstoken failed. Invalid parms.',
    'responseStatus': 'error'}
Traceback (most recent call last):
  File "./debug_discovery.py", line 35, in <module>
    payload = {"accessToken": auth_response["access_token"]}
KeyError: 'access_token'
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:09 Ah, that's different.

Code: Select all

Getting credentials
Got credentials
{   'errorMsg': 'Get accesstoken failed. Invalid parms.',
    'responseStatus': 'error'}
Traceback (most recent call last):
  File "./debug_discovery.py", line 35, in <module>
    payload = {"accessToken": auth_response["access_token"]}
KeyError: 'access_token'
That is better, edit the file and fill in the information between CHANGE THIS
Last edited by Xenomes on Thursday 18 March 2021 22:14, edited 1 time in total.
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 »

FYI: in the Domoticz log I can see this:

Code: Select all

2021-03-18 22:11:49.254 (Tuya devices) DEV name=LSC 2 state=True id=6276453110521cc9ecd9 online=True
2021-03-18 22:11:49.254 (Tuya devices) DEV name=LSC 1 state=True id=53425342f4cfa209631c online=True
LSC 1 and 2 are the two lamps that I have.
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 »

Xenomes wrote: Thursday 18 March 2021 22:12
manjh wrote: Thursday 18 March 2021 22:09 Ah, that's different.

Code: Select all

Getting credentials
Got credentials
{   'errorMsg': 'Get accesstoken failed. Invalid parms.',
    'responseStatus': 'error'}
Traceback (most recent call last):
  File "./debug_discovery.py", line 35, in <module>
    payload = {"accessToken": auth_response["access_token"]}
KeyError: 'access_token'
That is better, edit the file and fill in the information between CHANGE THIS
Sorry, I must have missed this in the plugin instructions.
Which file should I edit?
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:15 Sorry, I must have missed this in the plugin instructions.
Which file should I edit?
debug_discovery.py
the tool gives a json string so i can see the what device outputs, then i can update the plugin so a device without rgb has no colour wheel.
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: Thursday 18 March 2021 22:19
manjh wrote: Thursday 18 March 2021 22:15 Sorry, I must have missed this in the plugin instructions.
Which file should I edit?
debug_discovery.py
the tool gives a json string so i can see the what device outputs, then i can update the plugin so a device without rgb has no colour wheel.
OK, got it.

Code: Select all

Getting credentials
Got credentials
{   'access_token': 'EUheu1616000992439YNMrdQKReKU4r4S',
    'expires_in': 864000,
    'refresh_token': 'EUheu1616000992439YNMrdAFLvKdAtuy',
    'token_type': 'bearer'}
Getting devices
Got devices
{   'header': {'code': 'SUCCESS', 'payloadVersion': 1},
    'payload': {   'devices': [   {   'data': {   'brightness': '130',
                                                  'color_mode': 'white',
                                                  'color_temp': 1000,
                                                  'online': True,
                                                  'state': 'true'},
                                      'dev_type': 'light',
                                      'ha_type': 'light',
                                      'icon': 'https://images.tuyaeu.com/smart/icon/ay1541056239985fDGjj/15919273389f9d925c99f.png',
                                      'id': '6276453110521cc9ecd9',
                                      'name': 'LSC 2'},
                                  {   'data': {   'brightness': '10',
                                                  'color_mode': 'white',
                                                  'color_temp': 1000,
                                                  'online': True,
                                                  'state': 'true'},
                                      'dev_type': 'light',
                                      'ha_type': 'light',
                                      'icon': 'https://images.tuyaeu.com/smart/icon/ay1541056239985fDGjj/15919273389f9d925c99f.png',
                                      'id': '53425342f4cfa209631c',
                                      'name': 'LSC 1'}],
                   'scenes': []}}

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: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.
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: Google [Bot] and 1 guest