Xenomes / Domoticz-TUYA-Plugin

Implements the special Tuya Home Assistant API.
22 stars 8 forks source link

Tuya devices suddenly unavailable #50

Closed manjh closed 7 months ago

manjh commented 11 months ago

out of the blue, yesterday my Tuya devices were unavailable in Domoticz. Tried to switch from the Tuya app, worked fine. Also tried the obvious: disable/enable plugin, reboot Domoticz. When I tried to upgrade the app, I folowed the steps but ran into an error:

sudo git pull Your configuration specifies to merge with the ref 'refs/heads/manjh' from the remote, but no such ref was fetched.

Xenomes commented 11 months ago

Hi, that is strange that the connection is lost to tuya. For update u need to go back to the Master. git checkout Master And then do a pull. The connection I will test is to night (7 hours from now ).

manjh commented 11 months ago

The good news is that everything related to my Tuya devices suddenly started to work again. The bad news is that I have no clue about the cause... does not give me a warm feeling. Problems that "go away" on their own, may also come back in the future...

I strongly suspect the Tuya cloud server, but cannot prove it. I wish I could control the devices directly without any outside dependencies!

Xenomes commented 11 months ago

Hi manjh, I Tested the Plugin and it works indeed, This old API could be going offline but i cant find any plans for that. For offline control you can try https://github.com/jasonacox/tinytuya/tree/master/server but you need some configuration/programing.

Xenomes commented 11 months ago

Hi manjh, I had a idea to convert the Tinytuya plugin to use local control of the Tinytuya but that is a challenge. So i started a new one for local control. https://github.com/Xenomes/Domoticz-TinyTUYA-Local-Plugin At the moment only on/off control.

manjh commented 11 months ago

That looks great! I would be very happy to test, if I can be of use.

Currently I use 7 Tuya lamps (dim/tone), 6 smart plugs, and 1 electric panel heater.

Will it be a problem if I install your version along to the current Tuya plugin? Or should I disable it first?

thanks

Xenomes schreef op 19-07-2023 21:37:

Hi manjh, I had a idea to convert the Tinytuya plugin to use local control of the Tinytuya but that is a challenge. So i started a new one for local control. https://github.com/Xenomes/Domoticz-TinyTUYA-Local-Plugin At the moment only on/off control.

-- Reply to this email directly, view it on GitHub [1], or unsubscribe [2]. You are receiving this because you authored the thread.Message ID: @.***>

Links:

[1] https://github.com/Xenomes/Domoticz-TUYA-Plugin/issues/50#issuecomment-1642651353 [2] https://github.com/notifications/unsubscribe-auth/AB25MUERHD6PSORZPCVXBRTXRAZOPANCNFSM6AAAAAA2MRYE5Q

Xenomes commented 11 months ago

Nice! Yes you should be able to use the plugin together. All the mentioned devices support on/off, so that should work.

If you want to create a test domoticz, his is the way i did it: ssh to you Domoticz host create a domoticztest in you home folder. copy ./updaterelease from domoticz to domoticztest folder. run ./updaterelease in domoticztest folder. clone the plugin in the right folder. start ./domoticz -www 8070 (or other port) and you can connect to this clean Domoticz, with ctrl + c you can stop the program.

manjh commented 11 months ago

OK, so I finally got around to installing this interesting new plugin, apologies for the delay.

Installed it following the instructions, and ended with a file with information about 15 devices.

Then restarted Domoticz, and added the plugin on the HW page.

Following this, I get these errors on the log:

2023-08-07 14:24:10.829 TinyTUYA: Worker thread started. 2023-08-07 14:24:10.829 Status: TinyTUYA: Entering work loop. 2023-08-07 14:24:10.829 Status: TinyTUYA: Started. 2023-08-07 14:24:10.962 Error: TinyTUYA: (tinytuyalocal) failed to load 'plugin.py', Python Path used was '/home/pi/domoticz/plugins/Domoticz-TinyTUYA-Local-Plugin/:/usr/lib/python37.zip:/usr/lib/python3.7:/usr/lib/python3.7/lib-dynload:/usr/local/lib/python3.7/dist-packages:/usr/lib/python3/dist-packages:/usr/lib/python3.7/dist-packages'. 2023-08-07 14:24:10.997 Error: TinyTUYA: Traceback (most recent call last): 2023-08-07 14:24:10.997 Error: TinyTUYA: File "/home/pi/domoticz/plugins/Domoticz-TinyTUYA-Local-Plugin/plugin.py", line 39, in 2023-08-07 14:24:10.997 Error: TinyTUYA: import tinytuya

Am I missing something?

Xenomes schreef op 19-07-2023 21:37:

Hi manjh, I had a idea to convert the Tinytuya plugin to use local control of the Tinytuya but that is a challenge. So i started a new one for local control. https://github.com/Xenomes/Domoticz-TinyTUYA-Local-Plugin At the moment only on/off control.

-- Reply to this email directly, view it on GitHub [1], or unsubscribe [2]. You are receiving this because you authored the thread.Message ID: @.***>

Links:

[1] https://github.com/Xenomes/Domoticz-TUYA-Plugin/issues/50#issuecomment-1642651353 [2] https://github.com/notifications/unsubscribe-auth/AB25MUERHD6PSORZPCVXBRTXRAZOPANCNFSM6AAAAAA2MRYE5Q

manjh commented 11 months ago

I tried the whole installation from the start again, in case I made a mistake.

Same result. What's weird: I am able to run the tinytuya module as described to run a local scan, it gives me a file with info about my devices so it works OK. But when the plugin tries to start in Domoticz, the error is

2023-08-10 14:54:12.304 Error: LocalTUYA: Traceback (most recent call last): 2023-08-10 14:54:12.304 Error: LocalTUYA: File "/home/pi/domoticz/plugins/Domoticz-TinyTUYA-Local-Plugin/plugin.py", line 39, in 2023-08-10 14:54:12.304 Error: LocalTUYA: import tinytuya 2023-08-10 14:54:12.304 Error: LocalTUYA: ModuleNotFoundError: No module named 'tinytuya'

Xenomes schreef op 19-07-2023 21:37:

Hi manjh, I had a idea to convert the Tinytuya plugin to use local control of the Tinytuya but that is a challenge. So i started a new one for local control. https://github.com/Xenomes/Domoticz-TinyTUYA-Local-Plugin At the moment only on/off control.

-- Reply to this email directly, view it on GitHub [1], or unsubscribe [2]. You are receiving this because you authored the thread.Message ID: @.***>

Links:

[1] https://github.com/Xenomes/Domoticz-TUYA-Plugin/issues/50#issuecomment-1642651353 [2] https://github.com/notifications/unsubscribe-auth/AB25MUERHD6PSORZPCVXBRTXRAZOPANCNFSM6AAAAAA2MRYE5Q

Xenomes commented 11 months ago

Hi manjh, Did you install tinytuya with or without sudo. Then install or update the tinytuya with the other one. The description was with so try without sudo.

manjh commented 11 months ago

Not sure what I used, but the description shows "python -m pip install tinytuya".

Should I de-install first, or just run it again with sudo?

Xenomes schreef op 10-08-2023 20:15:

Hi manjh, Did you install tinytuya with or without sudo. Then install or update the tinytuya with the other one. The description was with so try without sudo.

-- Reply to this email directly, view it on GitHub [1], or unsubscribe [2]. You are receiving this because you authored the thread.Message ID: @.***>

Links:

[1] https://github.com/Xenomes/Domoticz-TUYA-Plugin/issues/50#issuecomment-1673688424 [2] https://github.com/notifications/unsubscribe-auth/AB25MUDBCBLZQO52XBK2V6DXUUQNHANCNFSM6AAAAAA2MRYE5Q

manjh commented 11 months ago

OK, just to make sure I de-installed using both sudo and without. Then tried installing it again and tested. Same result: module not found.

Hans

Xenomes schreef op 10-08-2023 20:15:

Hi manjh, Did you install tinytuya with or without sudo. Then install or update the tinytuya with the other one. The description was with so try without sudo.

-- Reply to this email directly, view it on GitHub [1], or unsubscribe [2]. You are receiving this because you authored the thread.Message ID: @.***>

Links:

[1] https://github.com/Xenomes/Domoticz-TUYA-Plugin/issues/50#issuecomment-1673688424 [2] https://github.com/notifications/unsubscribe-auth/AB25MUDBCBLZQO52XBK2V6DXUUQNHANCNFSM6AAAAAA2MRYE5Q

Xenomes commented 11 months ago

OK, you can install it together, the module is then available under the sudo user. In my guide it says 'sudo pip3 install requests==2.23.0 charset-normalizer==3.0.1 tinytuya -U' Domoticz runs under the sudo user and pip3 is to force Python3 if the python2 is also installed. Can you try that command line?

manjh commented 11 months ago

No luck:

2023-08-11 09:37:28.586 LocalTUYA: Worker thread started. 2023-08-11 09:37:28.586 Status: LocalTUYA: Entering work loop. 2023-08-11 09:37:28.586 Status: LocalTUYA: Started. 2023-08-11 09:37:28.669 Error: LocalTUYA: (tinytuyalocal) failed to load 'plugin.py', Python Path used was '/home/pi/domoticz/plugins/Domoticz-TinyTUYA-Local-Plugin/:/usr/lib/python37.zip:/usr/lib/python3.7:/usr/lib/python3.7/lib-dynload:/usr/local/lib/python3.7/dist-packages:/usr/lib/python3/dist-packages:/usr/lib/python3.7/dist-packages'. 2023-08-11 09:37:28.699 Error: LocalTUYA: Traceback (most recent call last): 2023-08-11 09:37:28.699 Error: LocalTUYA: File "/home/pi/domoticz/plugins/Domoticz-TinyTUYA-Local-Plugin/plugin.py", line 39, in 2023-08-11 09:37:28.699 Error: LocalTUYA: import tinytuya 2023-08-11 09:37:28.699 Error: LocalTUYA: ModuleNotFoundError: No module named 'tinytuya'

Xenomes schreef op 10-08-2023 21:44:

OK, you can install it together, the module is then available under the sudo user. In my guide it says 'sudo pip3 install requests==2.23.0 charset-normalizer==3.0.1 tinytuya -U' Domoticz runs under the sudo user and pip3 is to force Python3 if the python2 is also installed. Can you try that command line?

-- Reply to this email directly, view it on GitHub [1], or unsubscribe [2]. You are receiving this because you authored the thread.Message ID: @.***>

Links:

[1] https://github.com/Xenomes/Domoticz-TUYA-Plugin/issues/50#issuecomment-1673810894 [2] https://github.com/notifications/unsubscribe-auth/AB25MUDLCGE73UU4PI6QPEDXUU2Y7ANCNFSM6AAAAAA2MRYE5Q

Xenomes commented 11 months ago

Can you check the version of Python in the Domoticz info? I see in your log python3.7.

manjh commented 11 months ago

I noticed something like that: in my Zigbee plugin I can see complaints that 3.7 is no longer supported.

But this shows up on the console:

python --version Python 3.10.12

Xenomes schreef op 11-08-2023 13:08:

Can you check the version of Python in the Domoticz info? I see in your log python3.7.

-- Reply to this email directly, view it on GitHub [1], or unsubscribe [2]. You are receiving this because you authored the thread.Message ID: @.***>

Links:

[1] https://github.com/Xenomes/Domoticz-TUYA-Plugin/issues/50#issuecomment-1674577271 [2] https://github.com/notifications/unsubscribe-auth/AB25MUDYN53VC44ISRY46UDXUYHDPANCNFSM6AAAAAA2MRYE5Q

manjh commented 11 months ago

I noticed something, perhaps it is OK, but I seem to remember that python and python3 gave me different versions in the past.

Now I get this:

python --version Python 3.10.12

python3 --version Python 3.10.12

Xenomes schreef op 11-08-2023 13:08:

Can you check the version of Python in the Domoticz info? I see in your log python3.7.

-- Reply to this email directly, view it on GitHub [1], or unsubscribe [2]. You are receiving this because you authored the thread.Message ID: @.***>

Links:

[1] https://github.com/Xenomes/Domoticz-TUYA-Plugin/issues/50#issuecomment-1674577271 [2] https://github.com/notifications/unsubscribe-auth/AB25MUDYN53VC44ISRY46UDXUYHDPANCNFSM6AAAAAA2MRYE5Q

manjh commented 10 months ago

It was getting complicated, so I decided to grab a fresh Pi4 with new OS on an SSD. Installed Domoticz (and ran into some problems with arm4, solved that).

Then installed the TinyTUYA local plugin.

Missing steps from the install guide: need to install PIP (is not present on R-OS), and install TinyTuya. Also needs some attention about which directory to be in when scanning.

After all this, restarted Domoticz and added the plugin to the HW.

Log shows:

2023-08-14 11:41:03.038 LocalTUYA: Worker thread started. 2023-08-14 11:41:03.577 LocalTUYA: TinyTUYA 0.1 plugin started 2023-08-14 11:41:03.577 LocalTUYA: TinyTuyaVersion:1.12.9 2023-08-14 11:41:03.585 LocalTUYA: Update devices in Domoticz 2023-08-14 11:41:03.038 Status: LocalTUYA: Started. 2023-08-14 11:41:03.038 Status: LocalTUYA: Entering work loop. 2023-08-14 11:41:03.038 Status: NotificationSystem: thread started... 2023-08-14 11:41:03.039 Status: EventSystem: reset all events... 2023-08-14 11:41:03.040 Status: EventSystem: reset all device statuses... 2023-08-14 11:41:03.118 Status: Python EventSystem: Initializing event module. 2023-08-14 11:41:03.118 Status: EventSystem: Started 2023-08-14 11:41:03.118 Status: EventSystem: Queue thread started... 2023-08-14 11:41:03.440 Status: PluginSystem: 1 plugins started. 2023-08-14 11:41:03.576 Status: LocalTUYA: Initialized version 0.1, author 'Xenomes' 2023-08-14 11:41:03.727 Error: LocalTUYA: handleThread: '1' 2023-08-14 11:41:13.092 LocalTUYA: Update devices in Domoticz 2023-08-14 11:41:13.240 Error: LocalTUYA: handleThread: '1' 2023-08-14 11:41:23.057 LocalTUYA: Update devices in Domoticz 2023-08-14 11:41:23.269 Error: LocalTUYA: handleThread: '1' 2023-08-14 11:41:28.405 Status: User: admin (IP: 10.0.0.106) initiated a switch command (1/raam 1/On) 2023-08-14 11:41:31.579 Status: User: admin (IP: 10.0.0.106) initiated a switch command (1/raam 1/On) 2023-08-14 11:41:38.717 LocalTUYA: Update devices in Domoticz 2023-08-14 11:41:38.925 Error: LocalTUYA: handleThread: '1' 2023-08-14 11:41:48.091 LocalTUYA: Update devices in Domoticz 2023-08-14 11:41:48.238 Error: LocalTUYA: handleThread: '1' 2023-08-14 11:41:58.055 LocalTUYA: Update devices in Domoticz 2023-08-14 11:41:58.267 Error: LocalTUYA: handleThread: '1' 2023-08-14 11:42:08.084 LocalTUYA: Update devices in Domoticz 2023-08-14 11:42:08.202 Error: LocalTUYA: handleThread: '1' 2023-08-14 11:42:18.068 LocalTUYA: Update devices in Domoticz 2023-08-14 11:42:18.231 Error: LocalTUYA: handleThread: '1'

I can see 1 device out of 15 or so, but it does not react to a switch command.

Guess we're not all there yet..

Hans

Xenomes schreef op 11-08-2023 13:08:

Can you check the version of Python in the Domoticz info? I see in your log python3.7.

-- Reply to this email directly, view it on GitHub [1], or unsubscribe [2]. You are receiving this because you authored the thread.Message ID: @.***>

Links:

[1] https://github.com/Xenomes/Domoticz-TUYA-Plugin/issues/50#issuecomment-1674577271 [2] https://github.com/notifications/unsubscribe-auth/AB25MUDYN53VC44ISRY46UDXUYHDPANCNFSM6AAAAAA2MRYE5Q

Xenomes commented 10 months ago

Are you running Domoticz in Docker? Usually, the highest version is used in Domoticz.

manjh commented 10 months ago

No docker.

I installed a fresh R-OS on an SSD, and installed Domoticz over that as per the instructions in the Wiki.

Hans

Xenomes schreef op 15-08-2023 19:19:

Are you running Domoticz in Docker? Usually, the highest version is used in Domoticz.

-- Reply to this email directly, view it on GitHub [1], or unsubscribe [2]. You are receiving this because you authored the thread.Message ID: @.***>

Links:

[1] https://github.com/Xenomes/Domoticz-TUYA-Plugin/issues/50#issuecomment-1679319793 [2] https://github.com/notifications/unsubscribe-auth/AB25MUEEVUPFD4YRN75G6LTXVOVSZANCNFSM6AAAAAA2MRYE5Q