Page 21 of 26

Re: Python Plugin: TUYA

Posted: Tuesday 27 September 2022 19:15
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?

Re: Python Plugin: TUYA

Posted: Tuesday 27 September 2022 19:51
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

Re: Python Plugin: TUYA

Posted: Wednesday 28 September 2022 19:50
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})

Re: Python Plugin: TUYA

Posted: Tuesday 08 November 2022 20:26
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?

Re: Python Plugin: TUYA

Posted: Tuesday 08 November 2022 21:48
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 😉

Re: Python Plugin: TUYA

Posted: Wednesday 09 November 2022 20:16
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

Re: Python Plugin: TUYA

Posted: Friday 11 November 2022 17:17
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?

Re: Python Plugin: TUYA

Posted: Saturday 12 November 2022 10:57
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?

Re: Python Plugin: TUYA

Posted: Saturday 12 November 2022 11:08
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 😆

Re: Python Plugin: TUYA

Posted: Saturday 12 November 2022 11:34
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

Re: Python Plugin: TUYA

Posted: Saturday 12 November 2022 15:20
by rolandtwilt
it works like a charm! thank you very much!

Re: Python Plugin: TUYA

Posted: Saturday 12 November 2022 15:22
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!

Re: Python Plugin: TUYA

Posted: Sunday 13 November 2022 15:25
by rolandtwilt
my pleasure! Does this plugin also work on Tuya LED strips?

Re: Python Plugin: TUYA

Posted: Sunday 13 November 2022 21:08
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?

Re: Python Plugin: TUYA

Posted: Sunday 13 November 2022 22:34
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.

Re: Python Plugin: TUYA

Posted: Monday 14 November 2022 13:17
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 !!!

Re: Python Plugin: TUYA

Posted: Monday 14 November 2022 13:26
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?

Re: Python Plugin: TUYA

Posted: Monday 14 November 2022 15:57
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...

Re: Python Plugin: TUYA

Posted: Monday 14 November 2022 22:39
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?

Re: Python Plugin: TUYA

Posted: Tuesday 15 November 2022 17:41
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...