Xenomes / Domoticz-TinyTUYA-Plugin

A bridge between Tinytuya and Domoticz
11 stars 6 forks source link

After update 1.5.3 #40

Closed Fnasy closed 1 year ago

Fnasy commented 1 year ago

Hi, I performed the latest update and I get the following errors. Can you tell me how to fix it? Could it be from my script which influences the thermostat via an API (in order to regulate the thermostat according to the energy produced)? Any advice is welcome as I'm stuck. Thank you in advance for your help.

regards. Thierry

Error: Thermostats: handleThread: 'has_more' Error: Thermostats: Call to function 'onCommand' failed, exception details: Error: Thermostats: Traceback (most recent call last): Error: Thermostats: File "/home/pi/domoticz/plugins/Domoticz-TinyTUYA-Plugin/plugin.py", line 376, in onCommand Error: Thermostats: _plugin.onCommand(DeviceID, Unit, Command, Level, Color) Error: Thermostats: File "/home/pi/domoticz/plugins/Domoticz-TinyTUYA-Plugin/plugin.py", line 133, in onCommand Error: Thermostats: function = properties[DeviceID]['functions'] Error: Thermostats: KeyError: '40041254a4cf12af3bba'

Xenomes commented 1 year ago

Update the script, can you test if you error is gone?

Fnasy commented 1 year ago

Version 1.5.4

Hello, Yes, there are no more errors. Unfortunately, I noticed the following:

1: the measured temperatures are no longer updated in Domoticz. 2: the script works in the direction Domoticz towards APP but no longer in the other direction. 3: small detail: the limits are not respected which can desynchronize Domoticz and the APP. Example if the thermostat is set below the lower limit (5°) the update is not done in the APP. (not really important, but good to know).

Maybe it could be a good idea to test a return to version 1.4.8 which worked flawlessly and check if it was my API that was causing the problem). is this possible? I let you judge.

Regards Thierry

Xenomes commented 1 year ago

The only big change 1.4.8 to 1.5.4 is that the faulty TinyTuya 1.11.0 => 1.11.2 execution from the script is removed. Can you check the version of your installed liberty TinyTuya? sudo pip3 show tinytuya | grep Version The current plugin is tested with version1.12.4 if you are on this version can you send me the dump,json you can create it by edit and running the debug.discovery.py from the tools directory. you can email it to xenomes@outlook.com

Ps. min/max is included in the next version.

Fnasy commented 1 year ago

I have version : Version: 1.12.5

Xenomes commented 1 year ago

OK, i did not test the plugin with this version. Can you send me the dump,json then i can do a better check what is going wrong.

Fnasy commented 1 year ago

Here it is. DumpJson1.pdf

Xenomes commented 1 year ago

Hi tested your json of device ending on 2af3bba all the 5 created devices react on change from the json. So what I can see is that is is communication bidirectional. For the min/max you can checkout the Develop 1.5.5

Fnasy commented 1 year ago

After complete reinstallation I notice that the thermostat values ​​are only updated once in the direction APP --> Domoticz. After if I reset the plugin by changing the debug mode the values ​​are updated but only once. It seems that apart from the reset the data is not updated in Domoticz. This explains why I no longer receive the measured temperatures.

Xenomes commented 1 year ago

The change in the app can take up to a minute to be changed in Domoticz. because it use a pull system, so one time a minute the status is pulled from the tuya server. A send command is a push that is direct executed.

Fnasy commented 1 year ago

Hi, I tried for some minutes, hours and even one night. :-) It still doesn't work APP--> Domoticz. I can only recuperate the data when I am starting the plugin by resetting it changing the debug mode. Attached, you will find a trace of the Python debug mode. Hope it helps.

Thierry

Debug.pdf

Fnasy commented 1 year ago

Maybe a confusion between "set_temp" and "temp_set"

Thermostats: searchCodeActualFunction unable to find set_temp in

Xenomes commented 1 year ago

I tried for some minutes, hours and even one night. :-)

Then i had been updated 😆

I did some tests, but is can replicated it. See my test in the gif. See you a other behavior?

Animatie

Fnasy commented 1 year ago

Then i had been updated 😆

Sorry I am at GMT-7..

Yes, in my case, Tuya does not update Domoticz. (it worked before). But if I launch the plugin again (by changing the debug mode) the update is done only once.

It's annoying because I rely on the temperatures to adjust the thermostats according to the power generated by the photovoltaic panels.

Xenomes commented 1 year ago

I have upload the current code to the Develop, can you do a pull and change to the Develop?

cd ~/domoticz/plugins/Domoticz-TinyTUYA-Plugin
git pull
git checkout Develop
Fnasy commented 1 year ago

Ok. Done

Xenomes commented 1 year ago

Don't forget to restart domoticz, How are the controls reacting now?

Fnasy commented 1 year ago

This is new. I’ll check on Tuya.Iot

Thermostats: Cloud _gettoken() failed: 'sign invalid'

-- Cet e-mail a été vérifié par le logiciel antivirus d'AVG. www.avg.com

Fnasy commented 1 year ago

Ok. Token fixed.

Debug :

2023-04-27 12:46:48.398 Thermostats: onStop called

2023-04-27 12:46:48.698 Thermostats: Worker thread started.

2023-04-27 12:46:48.397 Status: Thermostats: Stop directive received.

2023-04-27 12:46:48.657 Status: Thermostats: Exiting work loop.

2023-04-27 12:46:48.698 Status: Thermostats: Stopping threads.

2023-04-27 12:46:48.698 Status: Thermostats: Stopped.

2023-04-27 12:46:48.698 Status: Thermostats: Entering work loop.

2023-04-27 12:46:48.698 Status: Thermostats: Started.

2023-04-27 12:46:48.398 Error: Thermostats: Call to function 'onStop' failed, exception details:

2023-04-27 12:46:48.405 Error: Thermostats: Traceback (most recent call last):

2023-04-27 12:46:48.405 Error: Thermostats: File "/home/pi/domoticz/plugins/Domoticz-TinyTUYA-Plugin/plugin.py", line 381, in onStop

2023-04-27 12:46:48.405 Error: Thermostats: _plugin.onStop()

2023-04-27 12:46:48.405 Error: Thermostats: File "/home/pi/domoticz/plugins/Domoticz-TinyTUYA-Plugin/plugin.py", line 100, in onStop

2023-04-27 12:46:48.405 Error: Thermostats: for dev in devs:

2023-04-27 12:46:48.405 Error: Thermostats: NameError: name 'devs' is not defined

2023-04-27 12:46:49.862 Thermostats: TinyTUYA plugin started

2023-04-27 12:46:49.862 Thermostats: 'TinyTuyaVersion':'1.12.5'

2023-04-27 12:46:49.862 Thermostats: Debug logging mask set to: CONNECTION

2023-04-27 12:46:49.851 Status: Thermostats: Initialized version 1.5.5, author 'Xenomes'

2023-04-27 12:46:49.870 Error: Thermostats: handleThread: Invalid return character or leading space in header: secret

2023-04-27 12:47:01.072 Error: Thermostats: Call to function 'onCommand' failed, exception details:

2023-04-27 12:47:01.076 Error: Thermostats: Traceback (most recent call last):

2023-04-27 12:47:01.076 Error: Thermostats: File "/home/pi/domoticz/plugins/Domoticz-TinyTUYA-Plugin/plugin.py", line 393, in onCommand

2023-04-27 12:47:01.076 Error: Thermostats: _plugin.onCommand(DeviceID, Unit, Command, Level, Color)

2023-04-27 12:47:01.076 Error: Thermostats: File "/home/pi/domoticz/plugins/Domoticz-TinyTUYA-Plugin/plugin.py", line 122, in onCommand

2023-04-27 12:47:01.076 Error: Thermostats: if Error is not None:

2023-04-27 12:47:01.076 Error: Thermostats: NameError: name 'Error' is not defined

-- Cet e-mail a été vérifié par le logiciel antivirus d'AVG. www.avg.com

Xenomes commented 1 year ago

The onStop i a known error trying to find a work around for that.

But this one is new for me 'Error: Thermostats: handleThread: Invalid return character or leading space in header: secret'

Fnasy commented 1 year ago

I entered the secret code again and this error disappeared. But the behavior of APP --> Domoticz remains the same. No update except on initialization.

Xenomes commented 1 year ago

Can you change the 'Search DeviceID' to an other?

Fnasy commented 1 year ago

I did it but unfortunately still the same problem.

Xenomes commented 1 year ago

So strange, When the script start is use the same part of the script to do the first update and then is is trigger every 60 sec.

Xenomes commented 1 year ago

I found the problem! With the cleanup i remove a line for the live data version but for test data it still works. Can you checkout the latest version.

Fnasy commented 1 year ago

Yes it works… !!!!! You are the best.

Xenomes commented 1 year ago

Ok great! With all the testing i also saw that tuya has changed some data format.