rospogrigio / localtuya

local handling for Tuya devices
GNU General Public License v3.0
2.93k stars 563 forks source link

mini switch #927

Open gussicc opened 2 years ago

gussicc commented 2 years ago

Hello im using mini switch, working in smart life, but failed in HA

error.

Este error se originó en una integración personalizada.

Logger: custom_components.localtuya.config_flow Source: custom_components/localtuya/pytuya/init.py:247 Integration: LocalTuya integration (documentation, issues) First occurred: 18:34:50 (1 occurrences) Last logged: 18:34:50

Unexpected exception Traceback (most recent call last): File "/usr/local/lib/python3.9/asyncio/locks.py", line 417, in acquire await fut asyncio.exceptions.CancelledError

During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/usr/local/lib/python3.9/asyncio/tasks.py", line 490, in wait_for return fut.result() asyncio.exceptions.CancelledError

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "/config/custom_components/localtuya/config_flow.py", line 533, in async_step_configure_device self.dps_strings = await validate_input(self.hass, user_input) File "/config/custom_components/localtuya/config_flow.py", line 242, in validate_input detected_dps = await interface.detect_available_dps() File "/config/custom_components/localtuya/pytuya/init.py", line 539, in detect_available_dps data = await self.status() File "/config/custom_components/localtuya/pytuya/init.py", line 481, in status status = await self.exchange(STATUS) File "/config/custom_components/localtuya/pytuya/init.py", line 460, in exchange msg = await self.dispatcher.wait_for(seqno) File "/config/custom_components/localtuya/pytuya/init.py", line 247, in wait_for await asyncio.wait_for(self.listeners[seqno].acquire(), timeout=timeout) File "/usr/local/lib/python3.9/asyncio/tasks.py", line 492, in wait_for raise exceptions.TimeoutError() from exc asyncio.exceptions.TimeoutError

goobags commented 2 years ago

I am having a similar error adding a new device. First device added since 4.0.0. I have disabled the Cloud API and restarted, but fails to add. I have not used this particular device with HA before.

Can see it in the Smart Life app with my other devices. I can also see it in the Tuya IoT Platform. I have the device ID and key to add via localtuya

`This error originated from a custom integration.

Logger: custom_components.localtuya.config_flow Source: custom_components/localtuya/pytuya/init.py:247 Integration: LocalTuya (documentation, issues) First occurred: 8:31:42 PM (1 occurrences) Last logged: 8:31:42 PM

Unexpected exception Traceback (most recent call last): File "/usr/local/lib/python3.9/asyncio/locks.py", line 417, in acquire await fut asyncio.exceptions.CancelledError

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/local/lib/python3.9/asyncio/tasks.py", line 490, in wait_for return fut.result() asyncio.exceptions.CancelledError

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "/config/custom_components/localtuya/config_flow.py", line 533, in async_step_configure_device self.dps_strings = await validate_input(self.hass, user_input) File "/config/custom_components/localtuya/config_flow.py", line 242, in validate_input detected_dps = await interface.detect_available_dps() File "/config/custom_components/localtuya/pytuya/init.py", line 539, in detect_available_dps data = await self.status() File "/config/custom_components/localtuya/pytuya/init.py", line 481, in status status = await self.exchange(STATUS) File "/config/custom_components/localtuya/pytuya/init.py", line 460, in exchange msg = await self.dispatcher.wait_for(seqno) File "/config/custom_components/localtuya/pytuya/init.py", line 247, in wait_for await asyncio.wait_for(self.listeners[seqno].acquire(), timeout=timeout) File "/usr/local/lib/python3.9/asyncio/tasks.py", line 492, in wait_for raise exceptions.TimeoutError() from exc asyncio.exceptions.TimeoutError

`

gussicc commented 2 years ago

Up please!

dncodes commented 2 years ago

Hi i have the same problem. Error added Aubess Smart Switch 1-gang. ( buy on https://aliexpress.com/item/1005003718157000.html ). Work fine in Tuya Smart app. Other devices type also work fine.

Debug log:

2022-07-09 02:40:38 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf4...mfy] Started heartbeat loop 2022-07-09 02:40:38 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf4...mfy] Sending command heartbeat (device type: type_0a) 2022-07-09 02:40:38 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf4...mfy] Send payload: b'{}' 2022-07-09 02:40:38 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf4...mfy] Waiting for sequence number -100 2022-07-09 02:40:38 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf4...mfy] Sending command status (device type: type_0a) 2022-07-09 02:40:38 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf4...mfy] Send payload: b'{"gwId":"bf42622859030db84femfy","devId":"bf42622859030db84femfy"}' 2022-07-09 02:40:38 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf4...mfy] Waiting for sequence number 1 2022-07-09 02:40:38 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf4...mfy] Connection lost: None 2022-07-09 02:40:43 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf4...mfy] Heartbeat failed due to timeout, disconnecting 2022-07-09 02:40:43 ERROR (MainThread) [custom_components.localtuya.pytuya] [bf4...mfy] Failed to get status: Traceback (most recent call last): File "/usr/local/lib/python3.9/asyncio/locks.py", line 417, in acquire await fut asyncio.exceptions.CancelledError

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/local/lib/python3.9/asyncio/tasks.py", line 490, in wait_for return fut.result() asyncio.exceptions.CancelledError

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "/config/custom_components/localtuya/pytuya/init.py", line 539, in detect_available_dps data = await self.status() File "/config/custom_components/localtuya/pytuya/init.py", line 481, in status status = await self.exchange(STATUS) File "/config/custom_components/localtuya/pytuya/init.py", line 460, in exchange msg = await self.dispatcher.wait_for(seqno) File "/config/custom_components/localtuya/pytuya/init.py", line 247, in wait_for await asyncio.wait_for(self.listeners[seqno].acquire(), timeout=timeout) File "/usr/local/lib/python3.9/asyncio/tasks.py", line 492, in wait_for raise exceptions.TimeoutError() from exc asyncio.exceptions.TimeoutError 2022-07-09 02:40:43 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf4...mfy] Closing connection 2022-07-09 02:40:43 ERROR (MainThread) [custom_components.localtuya.config_flow] Unexpected exception Traceback (most recent call last): File "/usr/local/lib/python3.9/asyncio/locks.py", line 417, in acquire await fut asyncio.exceptions.CancelledError

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/local/lib/python3.9/asyncio/tasks.py", line 490, in wait_for return fut.result() asyncio.exceptions.CancelledError

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "/config/custom_components/localtuya/config_flow.py", line 533, in async_step_configure_device self.dps_strings = await validate_input(self.hass, user_input) File "/config/custom_components/localtuya/config_flow.py", line 242, in validate_input detected_dps = await interface.detect_available_dps() File "/config/custom_components/localtuya/pytuya/init.py", line 539, in detect_available_dps data = await self.status() File "/config/custom_components/localtuya/pytuya/init.py", line 481, in status status = await self.exchange(STATUS) File "/config/custom_components/localtuya/pytuya/init.py", line 460, in exchange msg = await self.dispatcher.wait_for(seqno) File "/config/custom_components/localtuya/pytuya/init.py", line 247, in wait_for await asyncio.wait_for(self.listeners[seqno].acquire(), timeout=timeout) File "/usr/local/lib/python3.9/asyncio/tasks.py", line 492, in wait_for raise exceptions.TimeoutError() from exc asyncio.exceptions.TimeoutError

Сan any solution ?

joaofelipes commented 2 years ago

Same model here: Aubess Smart Switch 1-gang. Getting the same error. Works fine in Tuya Smart app. Any thoughts or work around?

goobags commented 2 years ago

It is definitely device related. I can still add models that I know work.

joaofelipes commented 2 years ago

I'm trying to debug the problem here using TuyaDebug. First running scan.py shows this:

FOUND Device [Valid payload]: 192.168.31.66 ID = eb7e7904563c0df8a4zpef, productKey = keyjnuy4s3kre7m7, Version = 3.4 FOUND Device [Valid payload]: 192.168.31.129 ID = eb9b1e3e3be9ccf172ucxe, productKey = gjv8e6a2etex8fqb, Version = 3.3 FOUND Device [Valid payload]: 192.168.31.214 ID = eb7f1e7b74608ae666s1pr, productKey = gq7t2uz9zpacyypt, Version = 3.3 FOUND Device [Valid payload]: 192.168.31.21 ID = eb89686a76ebbe4a96iojw, productKey = ygggdakmywjbny9h, Version = 3.3 Scan Complete! Found 4 devices.

The first device is the only one which won't work with localTuya. The difference seems to be the protocol version. The other ones are working fine.

Running test.py on that device returns an error:

>test.py eb7e7904563c0df8a4zpef 192.168.31.66 XXXXXXXXXXXXXXXX INFO:localtuya:localtuya version 1.0.0 INFO:localtuya:Python 3.9.2 (tags/v3.9.2:1a79785, Feb 19 2021, 13:44:55) [MSC v.1928 64 bit (AMD64)] on win32 INFO:localtuya:Using pytuya version '8.1.0' INFO:localtuya:Detecting list of available DPS of device eb7e7904563c0df8a4zpef [192.168.31.66], protocol 3.3. DEBUG:localtuya.pytuya:Sending command status (device type: type_0a) DEBUG:localtuya.pytuya:paylod=b'{"gwId":"eb7e7904563c0df8a4zpef","devId":"eb7e7904563c0df8a4zpef"}' DEBUG:localtuya.pytuya:DATA RECEIVED! DEBUG:localtuya.pytuya:READING AGAIN! DEBUG:localtuya.pytuya:Failed to connect to 192.168.31.66. Raising Exception. WARNING:localtuya.pytuya:Failed to get status: unpack requires a buffer of 20 bytes INFO:localtuya:Detecting list of available DPS of device eb7e7904563c0df8a4zpef [192.168.31.66], protocol 3.3. DEBUG:localtuya.pytuya:Sending command status (device type: type_0a) DEBUG:localtuya.pytuya:paylod=b'{"gwId":"eb7e7904563c0df8a4zpef","devId":"eb7e7904563c0df8a4zpef"}' DEBUG:localtuya.pytuya:DATA RECEIVED! DEBUG:localtuya.pytuya:READING AGAIN! DEBUG:localtuya.pytuya:Failed to connect to 192.168.31.66. Raising Exception. WARNING:localtuya.pytuya:Failed to get status: unpack requires a buffer of 20 bytes INFO:localtuya:Detecting list of available DPS of device eb7e7904563c0df8a4zpef [192.168.31.66], protocol 3.3. DEBUG:localtuya.pytuya:Sending command status (device type: type_0a) DEBUG:localtuya.pytuya:paylod=b'{"gwId":"eb7e7904563c0df8a4zpef","devId":"eb7e7904563c0df8a4zpef"}' DEBUG:localtuya.pytuya:DATA RECEIVED! DEBUG:localtuya.pytuya:READING AGAIN! DEBUG:localtuya.pytuya:Failed to connect to 192.168.31.66. Raising Exception. WARNING:localtuya.pytuya:Failed to get status: unpack requires a buffer of 20 bytes INFO:localtuya:TIMEOUT: No response from device eb7e7904563c0df8a4zpef [192.168.31.66] after 2 attempts.

Hope it helps if there's anyone digging around the problem.

goobags commented 2 years ago

Protocol version 3.4 would be the problem

CloCkWeRX commented 2 years ago

Duplicate of #897; sort of - at least the asyncio.exceptions.TimeoutError should be handled.

TeddyLafrite commented 2 years ago

Hi

Same problem for me with switch Aubess Smart Switch 1-gang 16A

Actually no solution

kevvar commented 2 years ago

Hello, did any one make your mini smart switch work? I have one too, retrieve the ID, local key, DP's from "Get Device Specification Attribute" from tuya cloud, but I can't make it work, maybe it is imcompatible with tuya local?

Monacoslo commented 2 years ago

I have plenty of those devices and I can not get them work in tuya local. I manally select 3.1 or 3.3, manually add DPS 1, but I can see is just offline switch.

Monacoslo commented 2 years ago

Hello, did any one make your mini smart switch work? I have one too, retrieve the ID, local key, DP's from "Get Device Specification Attribute" from tuya cloud, but I can't make it work, maybe it is imcompatible with tuya local?

We will obviously need to wait until protocol 3.4 will be supported in localtuya

dimyard commented 2 years ago

Hi!

Any news here?

kevvar commented 1 year ago

Hi friends local tuya add support for 3.4 protocol https://github.com/rospogrigio/localtuya/issues/1041#issuecomment-1375495357