Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The plugin does not work #7

Open
thommas001 opened this issue Oct 4, 2024 · 21 comments
Open

The plugin does not work #7

thommas001 opened this issue Oct 4, 2024 · 21 comments

Comments

@thommas001
Copy link

Hi,

I can pull all devices on my account but I cannot do much more. This is what I am getting in the log file:

2024-10-04 21:01:33.976 Error: TinyTuyaLocal: Call to function 'onCommand' failed, exception details:
2024-10-04 21:01:33.987 Error: TinyTuyaLocal: Traceback (most recent call last):
2024-10-04 21:01:33.987 Error: TinyTuyaLocal: File "/home/pi/domoticz/plugins/Domoticz-TinyTUYA-Local-Plugin/plugin.py", line 142, in onCommand
2024-10-04 21:01:33.987 Error: TinyTuyaLocal: _plugin.onCommand(DeviceID, Unit, Command, Level, Color)
2024-10-04 21:01:33.987 Error: TinyTuyaLocal: File "/home/pi/domoticz/plugins/Domoticz-TinyTUYA-Local-Plugin/plugin.py", line 101, in onCommand
2024-10-04 21:01:33.987 Error: TinyTuyaLocal: SendCommand(DeviceID, Unit, True if Command not in ['Off', 'Closed', False] else False, category)
2024-10-04 21:01:33.987 Error: TinyTuyaLocal: File "/home/pi/domoticz/plugins/Domoticz-TinyTUYA-Local-Plugin/plugin.py", line 564, in SendCommand
2024-10-04 21:01:33.987 Error: TinyTuyaLocal: item = selected_device['mapping'][str(Unit)]
2024-10-04 21:01:33.987 Error: TinyTuyaLocal: ~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^
2024-10-04 21:01:33.987 Error: TinyTuyaLocal: KeyError: '4'
2024-10-04 21:01:43.110 Error: TinyTuyaLocal: handleThread: string indices must be integers, not 'str' line 355

@Xenomes
Copy link
Owner

Xenomes commented Oct 4, 2024

I just pushed a new version. Can you test it and see if the error still occurs?

@thommas001
Copy link
Author

It did help with the error. Many thanks.
Still, it seems the communication is one way only - I cannot control the switch from Domoticz (any on/off actions are reverted within 5-10 secs) but changes in Tuya app are reflected in Domoticz. I will test it for a couple of days to come with feedback.

@fielux
Copy link

fielux commented Oct 5, 2024

Testing with the version downloaded this morning.

I got the following error:

Error: WiFi RF Receiver Garage: handleThread: '2' line 356

Few minutes later:

Error: CheckAuthToken(xxx) : auth token mismatch

any idea? Thx

@Xenomes
Copy link
Owner

Xenomes commented Oct 5, 2024

It did help with the error. Many thanks.
Still, it seems the communication is one way only - I cannot control the switch from Domoticz (any on/off actions are reverted within 5-10 secs) but changes in Tuya app are reflected in Domoticz. I will test it for a couple of days to come with feedback.

Okay, that could be a issue, wil try to test more.

@Xenomes
Copy link
Owner

Xenomes commented Oct 5, 2024

Testing with the version downloaded this morning.

I got the following error:

Error: WiFi RF Receiver Garage: handleThread: '2' line 356

Few minutes later:

Error: CheckAuthToken(xxx) : auth token mismatch

any idea? Thx

Could you share the line from the device file from the wifi rf where id 2 is, mask any key if shown.

@fielux
Copy link

fielux commented Oct 5, 2024

devices.json
Here you are. thx for the IMMEDIATE reply

@Xenomes
Copy link
Owner

Xenomes commented Oct 5, 2024

Device 2 is just a Boolean, same as Device 1. There should be no difference.

@fielux
Copy link

fielux commented Oct 5, 2024

Not sure I got your answer :(. Why the 2 errors above?

@Xenomes
Copy link
Owner

Xenomes commented Oct 5, 2024

Can you run this in Python? And post the output? Oh, you need to add you key of the device in the line. see the device file.

import tinytuya
tuya = tinytuya.Device(dev_id='bfc0e16500cadca117rpzv',address='192.168.1.192',local_key='',version='3.4')
tuya.detect_available_dps()
tuya.status()

@fielux
Copy link

fielux commented Oct 7, 2024

Here you are (apologies for delay)

Python 3.11.2 (main, Aug 26 2024, 07:20:54) [GCC 12.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.

import tinytuya
tuya = tinytuya.Device(dev_id='bfc0e16500cadca117rpzv',address='192.168.1.19 2',local_key='XXX',version='3.4')
tuya.detect_available_dps()
{'1': None, '2': None, '9': None, '10': None, '38': None, '42': None, '43': None , '44': None, '47': None}
tuya.status()
{'dps': {'1': False, '2': False, '9': 0, '10': 0, '38': 'memory', '42': '', '43': '', '44': 'AQABAwAB', '47': 'sync'}}

BTW tonight it reported several errors on log:

2024-10-07 04:04:59.670 Error: WiFi RF Receiver Garage: handleThread: 'dps' line 356
2024-10-07 04:06:09.226 Error: WiFi RF Receiver Garage hardware (37) thread seems to have ended unexpectedly
2024-10-07 04:06:23.229 Error: WiFi RF Receiver Garage hardware (37) thread seems to have ended unexpectedly
2024-10-07 04:06:37.232 Error: WiFi RF Receiver Garage hardware (37) thread seems to have ended unexpectedly
2024-10-07 04:06:45.579 Error: WiFi RF Receiver Garage: handleThread: 'dps' line 356
2024-10-07 04:06:45.579 Error: WiFi RF Receiver Garage: handleThread: 'dps' line 356
2024-10-07 04:07:47.246 Error: WiFi RF Receiver Garage hardware (37) thread seems to have ended unexpectedly
2024-10-07 04:08:01.249 Error: WiFi RF Receiver Garage hardware (37) thread seems to have ended unexpectedly
2024-10-07 04:08:15.252 Error: WiFi RF Receiver Garage hardware (37) thread seems to have ended unexpectedly
2024-10-07 04:08:29.255 Error: WiFi RF Receiver Garage hardware (37) thread seems to have ended unexpectedly
2024-10-07 04:08:32.939 Error: WiFi RF Receiver Garage: handleThread: 'dps' line 356
2024-10-07 04:08:32.940 Error: WiFi RF Receiver Garage: handleThread: 'dps' line 356
2024-10-07 04:09:39.269 Error: WiFi RF Receiver Garage hardware (37) thread seems to have ended unexpectedly
2024-10-07 04:09:53.272 Error: WiFi RF Receiver Garage hardware (37) thread seems to have ended unexpectedly
2024-10-07 04:10:07.531 Error: WiFi RF Receiver Garage hardware (37) thread seems to have ended unexpectedly
2024-10-07 04:10:20.299 Error: WiFi RF Receiver Garage: handleThread: 'dps' line 356
2024-10-07 04:10:20.300 Error: WiFi RF Receiver Garage: handleThread: 'dps' line 356
2024-10-07 04:11:31.546 Error: WiFi RF Receiver Garage hardware (37) thread seems to have ended unexpectedly
2024-10-07 04:11:45.549 Error: WiFi RF Receiver Garage hardware (37) thread seems to have ended unexpectedly
2024-10-07 04:11:59.552 Error: WiFi RF Receiver Garage hardware (37) thread seems to have ended unexpectedly
2024-10-07 04:12:10.539 Error: WiFi RF Receiver Garage: handleThread: 'dps' line 356
2024-10-07 04:12:10.540 Error: WiFi RF Receiver Garage: handleThread: 'dps' line 356

@Xenomes
Copy link
Owner

Xenomes commented Oct 7, 2024

{'dps': {'1': False, '2': False, '9': 0, '10': 0, '38': 'memory', '42': '', '43': '', '44': 'AQABAwAB', '47': 'sync'}}
This is perfect.

2024-10-07 04:12:10.540 Error: WiFi RF Receiver Garage: handleThread: 'dps' line 356

Here is the call for the device ID. I will implement a fix so that if the DPS is empty, it will skip and not throw an error.

@Xenomes
Copy link
Owner

Xenomes commented Oct 7, 2024

Build a fix, please test again! 😁

@fielux
Copy link

fielux commented Oct 8, 2024

Test in progress :)

@fielux
Copy link

fielux commented Oct 12, 2024

At the moment, the issue has not occurred again. Super!!! I have noticed that if the device loses the connection, Domoticz no longer tries to reconnect it. In the logs, I found the following error: 2024-10-12 10:36:42.090 Error: WiFi RF Receiver Garage: Device :xxx is Offline!

@Xenomes
Copy link
Owner

Xenomes commented Oct 15, 2024

Perfect!

I found the following error: 2024-10-12 10:36:42.090 Error: WiFi RF Receiver Garage: Device :xxx is Offline!

It could be that the device wasn’t registered as online. The Wi-Fi connection or network traffic could be anything.

@fielux
Copy link

fielux commented Oct 15, 2024

That’s exactly the case. What I’m saying is that domoticz does not try to reconnect when this happens

@Xenomes
Copy link
Owner

Xenomes commented Oct 15, 2024

I did the test.... Here is a gif.
Offline

@fielux
Copy link

fielux commented Oct 19, 2024

Strange. Here is an example… my (shixxy) modem rebooted tonight.
domoticz properly logged the problem

2024-10-19 04:14:03.446 Error: WiFi RF Receiver
Garage: Device :xxx is Offline!

As you can see the device is still marked as offline in Domoticz at 16.23PM

image

@Xenomes
Copy link
Owner

Xenomes commented Oct 19, 2024

Can you run this again when the device is in Offline modus..

import tinytuya
tuya = tinytuya.Device(dev_id='bfc0e16500cadca117rpzv',address='192.168.1.192',local_key='',version='3.4')
tuya.detect_available_dps()
tuya.status()

@fielux
Copy link

fielux commented Oct 20, 2024

I noticed something interesting… if triggered by an event in Domoticz, the button that was previously offline is actually responsive, and then, after being activated, it appears online.

@Xenomes
Copy link
Owner

Xenomes commented Oct 21, 2024

Okay, that is interesting indeed...
edit:
If the status does not contain 'dps', then the update will not occur.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants