Python Plugin: TUYA

Python and python framework

Moderator: leecollings

dgilbert2
Posts: 84
Joined: Wednesday 16 August 2017 8:08
Target OS: Raspberry Pi / ODroid
Domoticz version: 2023.1
Location: UK
Contact:

Re: Python Plugin: TUYA

Post by dgilbert2 »

Xenomes wrote: Saturday 24 September 2022 16:32 Hi, That part of the plugin not complete, I don't have a tuya temp device so i was depended for data from a other user witch stopped replaying. For updating you need to add code below here:
I'm making some progress but have reached a dead end at the moment with the command that it sent to the TUYA API from climate.py, ie instead of setting the setpoint temperature, the controller itself goes into an error mode.

The command sent by climate.py to adjust the setpoint temperature is:

Code: Select all

self.api.device_control(self.obj_id, "temperatureSet", {"value": float(temperature)})
but its looking like for my controller, that "temperatureSet" is the wrong instruction. Does anyone have a full list of these TUYA API instructions so I can try and find the right one?
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 »

In the https://github.com/PaulAnnekov/tuyaha/b ... climate.py

Code: Select all

    def current_temperature(self):
        """Return current temperature for the device"""
        curr_temp = self._set_decimal(
            self.data.get("current_temperature"), self._ct_divider
        )
        # when current temperature is not available, target temperature is returned
        if curr_temp is None:
            return self.target_temperature()
        return curr_temp
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
dgilbert2
Posts: 84
Joined: Wednesday 16 August 2017 8:08
Target OS: Raspberry Pi / ODroid
Domoticz version: 2023.1
Location: UK
Contact:

Re: Python Plugin: TUYA

Post by dgilbert2 »

Xenomes wrote: Tuesday 27 September 2022 19:51 In the https://github.com/PaulAnnekov/tuyaha/b ... climate.py
Thank you for the link which I've looked at in detail. Unfortunately I'm still struggling getting the SetPoint to work, i.e. I can read the "temperature" fine, but cannot change it in the API. In the code below from climate.py, even by manually setting the temperature (SetPoint), e.g. to 150 (my controller is x10 the actual temperature) the controller displays strange characters until I use the Smartlife App to change the setpoint to another value. So the code definitely is sending data to the API but I can only assume that its not what it was expecting. Any more clues please?

Code: Select all

    def set_temperature(self, temperature):
        """Set new target temperature."""
        self.api.device_control(self.obj_id, "temperatureSet", {"value": 150})
JimmyH1969
Posts: 153
Joined: Tuesday 28 June 2016 16:38
Target OS: Windows
Domoticz version: Beta
Location: Amersfoort NL
Contact:

Re: Python Plugin: TUYA

Post by JimmyH1969 »

Hi, I just bought the Warm Christmas Lights from the action. It shows up in the Tuya App, but not in Domoticz. Any change i can control them from Domoticz?
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 »

JimmyH1969 wrote: Tuesday 08 November 2022 20:26 Any change i can control them from Domoticz?
I think these lights are using the new api. I am experimenting with a other type of controlling the tuya devices. I will contact you on pm for a export of some tuya data. If you want to of course 😉
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
JimmyH1969
Posts: 153
Joined: Tuesday 28 June 2016 16:38
Target OS: Windows
Domoticz version: Beta
Location: Amersfoort NL
Contact:

Re: Python Plugin: TUYA

Post by JimmyH1969 »

Xenomes wrote: Tuesday 08 November 2022 21:48
JimmyH1969 wrote: Tuesday 08 November 2022 20:26 Any change i can control them from Domoticz?
I think these lights are using the new api. I am experimenting with a other type of controlling the tuya devices. I will contact you on pm for a export of some tuya data. If you want to of course 😉
Of course i will :D
User avatar
FearNaBoinne
Posts: 144
Joined: Tuesday 30 April 2019 10:08
Target OS: Linux
Domoticz version: 2021.1
Location: Sector 0
Contact:

Re: Python Plugin: TUYA

Post by FearNaBoinne »

I am testing with Action LSC smokesensors. They're not showing up. Would you be able to add these with the right information?
RasPi, Raspbian , Domoticz v2021.1, Z-Wave Stick, RFLink, RFXtrx433e, Hue, Tuya (Tasmota/Mosquitto with Discovery), ESP(easy), MySensors.org, OTGW
User avatar
rolandtwilt
Posts: 74
Joined: Monday 05 October 2020 18:55
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python Plugin: TUYA

Post by rolandtwilt »

and suddenly.................. the plugin doesn't work anymore.
Reinstalled, added hardware, transferred data from the app.....and it doesn't do anything
No error message in domoticz log and the blinds can be used via the Tuya app.
The USB stick (=router) also works, what's wrong?
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 »

rolandtwilt wrote: Saturday 12 November 2022 10:57 and suddenly.................. the plugin doesn't work anymore.
Reinstalled, added hardware, transferred data from the app.....and it doesn't do anything
No error message in domoticz log and the blinds can be used via the Tuya app.
The USB stick (=router) also works, what's wrong?
Did you update to the new version 2022.2? The plugin is not ready to use the new blind control system. I will update the plugin later this day, but i can't test it, I don't have Tuya blinds 😆
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 »

The update is create, can someone with blinds or covers test it.

Code: Select all

cd domoticz/plugins/Domoticz-TUYA-Plugin
git pull
git checkout update-for-domoticz-2022.2
Restart Domoticz
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
rolandtwilt
Posts: 74
Joined: Monday 05 October 2020 18:55
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python Plugin: TUYA

Post by rolandtwilt »

it works like a charm! thank you very much!
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 »

rolandtwilt wrote: Saturday 12 November 2022 15:20 it works like a charm! thank you very much!
Perfect! Then i will push it to the main branch, thanks for reporting and testing!
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
rolandtwilt
Posts: 74
Joined: Monday 05 October 2020 18:55
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python Plugin: TUYA

Post by rolandtwilt »

my pleasure! Does this plugin also work on Tuya LED strips?
User avatar
FearNaBoinne
Posts: 144
Joined: Tuesday 30 April 2019 10:08
Target OS: Linux
Domoticz version: 2021.1
Location: Sector 0
Contact:

Re: Python Plugin: TUYA

Post by FearNaBoinne »

FearNaBoinne wrote: Friday 11 November 2022 17:17 I am testing with Action LSC smokesensors. They're not showing up. Would you be able to add these with the right information?
RasPi, Raspbian , Domoticz v2021.1, Z-Wave Stick, RFLink, RFXtrx433e, Hue, Tuya (Tasmota/Mosquitto with Discovery), ESP(easy), MySensors.org, OTGW
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 »

FearNaBoinne wrote: Sunday 13 November 2022 21:08 I am testing with Action LSC smokesensors. They're not showing up. Would you be able to add these with the right information?
I am almost sure that these devices are using the newer api. For sure you can run the debug_discover.py from the tools directory to see if there is json data available for the smoke detectors. ps. don't forget the edit file for the tuya credentials.
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
FearNaBoinne
Posts: 144
Joined: Tuesday 30 April 2019 10:08
Target OS: Linux
Domoticz version: 2021.1
Location: Sector 0
Contact:

Re: Python Plugin: TUYA

Post by FearNaBoinne »

Xenomes wrote: Sunday 13 November 2022 22:34 I am almost sure that these devices are using the newer api. For sure you can run the debug_discover.py from the tools directory to see if there is json data available for the smoke detectors. ps. don't forget the edit file for the tuya credentials.

Code: Select all

Getting credentials
Got credentials
{   'access_token': 'EUheu1668*********GD0bNLB9EcgSBIT',
    'expires_in': 864000,
    'refresh_token': 'EUheu1668*********GD0bNvGJ0gcogAd',
    'token_type': 'bearer'}
Getting devices
Got devices
{   'header': {'code': 'SUCCESS', 'payloadVersion': 1},
    'payload': {'devices': [], 'scenes': []}}
!!! NOW REMOVE THIS FILE, SO YOUR CREDENTIALS (username, password) WON'T LEAK !!!
RasPi, Raspbian , Domoticz v2021.1, Z-Wave Stick, RFLink, RFXtrx433e, Hue, Tuya (Tasmota/Mosquitto with Discovery), ESP(easy), MySensors.org, OTGW
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 »

FearNaBoinne wrote: Monday 14 November 2022 13:17

Code: Select all

'payload': {'devices': [], 'scenes': []}}
The json string of devices is empty so no support from api v1. Question do you have a IOT account at Tuya?
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
FearNaBoinne
Posts: 144
Joined: Tuesday 30 April 2019 10:08
Target OS: Linux
Domoticz version: 2021.1
Location: Sector 0
Contact:

Re: Python Plugin: TUYA

Post by FearNaBoinne »

Xenomes wrote: Monday 14 November 2022 13:26
FearNaBoinne wrote: Monday 14 November 2022 13:17

Code: Select all

'payload': {'devices': [], 'scenes': []}}
The json string of devices is empty so no support from api v1. Question do you have a IOT account at Tuya?
I'm not certain... It's been a while since I did work with Tuya, and remember looking at it, but cannot remember if I went through with that... I will check!
I have not. I applied for one, let's see...
RasPi, Raspbian , Domoticz v2021.1, Z-Wave Stick, RFLink, RFXtrx433e, Hue, Tuya (Tasmota/Mosquitto with Discovery), ESP(easy), MySensors.org, OTGW
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 »

FearNaBoinne wrote: Monday 14 November 2022 15:57 I have not. I applied for one, let's see...
Can you edit and run this script?

Code: Select all

wget https://raw.githubusercontent.com/Xenomes/Domoticz-TinyTUYA-Plugin/dev/tools/debug_discovery.py
It creates a dump.json can you PM the file?
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
FearNaBoinne
Posts: 144
Joined: Tuesday 30 April 2019 10:08
Target OS: Linux
Domoticz version: 2021.1
Location: Sector 0
Contact:

Re: Python Plugin: TUYA

Post by FearNaBoinne »

Xenomes wrote: Monday 14 November 2022 22:39
FearNaBoinne wrote: Monday 14 November 2022 15:57 I have not. I applied for one, let's see...
Can you edit and run this script?

Code: Select all

wget https://raw.githubusercontent.com/Xenomes/Domoticz-TinyTUYA-Plugin/dev/tools/debug_discovery.py
It creates a dump.json can you PM the file?
I will as soon as I get approved...
RasPi, Raspbian , Domoticz v2021.1, Z-Wave Stick, RFLink, RFXtrx433e, Hue, Tuya (Tasmota/Mosquitto with Discovery), ESP(easy), MySensors.org, OTGW
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest