xZetsubou / hass-localtuya

🔹 A Home Assistant integration to handle Tuya devices locally "fork from localtuya"
https://xzetsubou.github.io/hass-localtuya/
GNU General Public License v3.0
201 stars 21 forks source link

[Bug]: Add new device DATAPOINT missing #193

Open marcofederici92 opened 3 weeks ago

marcofederici92 commented 3 weeks ago

LocalTuya Version

3.2.5.1

Home Assistant Version

Core 2024.4.1 Supervisor 2024.03.1 Operating System 12.1 Frontend 20240404.1

Environment

What happened?

Every time i try to add a device from my cloud project i get this error:

Connected to the device successfully but could not find datapoints. Please retry setup. If the problem persists, create a new report (including debug logs).

Here the log from the other repo (rospogrigio), by this i cannot enable debug mode, in both repo i have the same problem

👍 Help me to solve.. i've buy 10 camera for home assistante and not working =(

Steps to reproduce.

add new device by found devices

Relevant log output

2024-04-07 23:04:49.214 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfe...5kj] ACK received for command 13: ignoring it
2024-04-07 23:04:49.214 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfe...5kj] Sending command 10 (device type: type_0d)
2024-04-07 23:04:49.214 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfe...5kj] Sending payload: b'{"devId":"bfe657c2b61e9a251eg5kj","uid":"bfe657c2b61e9a251eg5kj","t":"1712523889","dps":{"1":null,"100":null,"101":null,"102":null,"103":null,"104":null,"105":null,"106":null,"107":null,"108":null,"109":null,"110":null}}'
2024-04-07 23:04:49.217 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfe...5kj] Command 13 waiting for seq. number 5
2024-04-07 23:04:49.234 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfe...5kj] Dispatching message CMD 13 TuyaMessage(seqno=5, cmd=13, retcode=0, payload=b'', crc=4036118812, crc_good=True)
2024-04-07 23:04:49.234 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfe...5kj] ACK received for command 13: ignoring it
2024-04-07 23:04:49.234 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfe...5kj] Detected dps: {}
2024-04-07 23:04:49.234 DEBUG (MainThread) [custom_components.localtuya.config_flow] Detected DPS: {}
2024-04-07 23:04:49.234 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfe...5kj] Closing connection
2024-04-07 23:04:49.240 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfe...5kj] Connection lost: None
2024-04-07 23:05:06.072 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfe...5kj] Sending command 10 (device type: type_0a)
2024-04-07 23:05:06.073 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfe...5kj] Sending payload: b'{"gwId":"bfe657c2b61e9a251eg5kj","devId":"bfe657c2b61e9a251eg5kj","uid":"bfe657c2b61e9a251eg5kj","t":"1712523906"}'
2024-04-07 23:05:06.075 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfe...5kj] Command 10 waiting for seq. number 1
2024-04-07 23:05:06.079 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfe...5kj] Dispatching message CMD 10 TuyaMessage(seqno=1, cmd=10, retcode=1, payload=b'd\x08\x87\xb1\xb7\xe9\xd5\xaf\xcc9\xd7\xccUW\xe0et\xe1\\\x14\xba\x89\x8b\xc4\xf5\xae\xd3\x1e\x9a\xad\x11\xef', crc=3320471993, crc_good=True)
2024-04-07 23:05:06.081 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfe...5kj] 'data unvalid' error detected: switching to dev_type 'type_0d'
2024-04-07 23:05:06.081 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfe...5kj] Re-send 10 due to device type change (type_0a -> type_0d)
2024-04-07 23:05:06.081 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfe...5kj] Sending command 10 (device type: type_0d)
2024-04-07 23:05:06.082 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfe...5kj] Sending payload: b'{"devId":"bfe657c2b61e9a251eg5kj","uid":"bfe657c2b61e9a251eg5kj","t":"1712523906","dps":{"1":null,"2":null,"3":null,"4":null,"5":null,"6":null,"7":null,"8":null,"9":null,"10":null}}'
2024-04-07 23:05:06.083 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfe...5kj] Command 13 waiting for seq. number 2
2024-04-07 23:05:06.094 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfe...5kj] Dispatching message CMD 13 TuyaMessage(seqno=2, cmd=13, retcode=0, payload=b'', crc=2380353348, crc_good=True)
2024-04-07 23:05:06.095 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfe...5kj] ACK received for command 13: ignoring it
2024-04-07 23:05:06.095 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfe...5kj] Sending command 10 (device type: type_0d)
2024-04-07 23:05:06.095 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfe...5kj] Sending payload: b'{"devId":"bfe657c2b61e9a251eg5kj","uid":"bfe657c2b61e9a251eg5kj","t":"1712523906","dps":{"1":null,"11":null,"12":null,"13":null,"14":null,"15":null,"16":null,"17":null,"18":null,"19":null,"20":null}}'
2024-04-07 23:05:06.097 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfe...5kj] Command 13 waiting for seq. number 3
2024-04-07 23:05:06.150 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfe...5kj] Dispatching message CMD 13 TuyaMessage(seqno=3, cmd=13, retcode=0, payload=b'', crc=1350014657, crc_good=True)
2024-04-07 23:05:06.151 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfe...5kj] ACK received for command 13: ignoring it
2024-04-07 23:05:06.151 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfe...5kj] Sending command 10 (device type: type_0d)
2024-04-07 23:05:06.152 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfe...5kj] Sending payload: b'{"devId":"bfe657c2b61e9a251eg5kj","uid":"bfe657c2b61e9a251eg5kj","t":"1712523906","dps":{"1":null,"21":null,"22":null,"23":null,"24":null,"25":null,"26":null,"27":null,"28":null,"29":null,"30":null}}'
2024-04-07 23:05:06.154 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfe...5kj] Command 13 waiting for seq. number 4
2024-04-07 23:05:06.229 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfe...5kj] Dispatching message CMD 13 TuyaMessage(seqno=4, cmd=13, retcode=0, payload=b'', crc=755273881, crc_good=True)
2024-04-07 23:05:06.230 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfe...5kj] ACK received for command 13: ignoring it
2024-04-07 23:05:06.230 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfe...5kj] Sending command 10 (device type: type_0d)
2024-04-07 23:05:06.231 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfe...5kj] Sending payload: b'{"devId":"bfe657c2b61e9a251eg5kj","uid":"bfe657c2b61e9a251eg5kj","t":"1712523906","dps":{"1":null,"100":null,"101":null,"102":null,"103":null,"104":null,"105":null,"106":null,"107":null,"108":null,"109":null,"110":null}}'
2024-04-07 23:05:06.233 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfe...5kj] Command 13 waiting for seq. number 5
2024-04-07 23:05:06.236 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfe...5kj] Dispatching message CMD 13 TuyaMessage(seqno=5, cmd=13, retcode=0, payload=b'', crc=4036118812, crc_good=True)
2024-04-07 23:05:06.236 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfe...5kj] ACK received for command 13: ignoring it
2024-04-07 23:05:06.237 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfe...5kj] Detected dps: {}
2024-04-07 23:05:06.237 DEBUG (MainThread) [custom_components.localtuya.config_flow] Detected DPS: {}
2024-04-07 23:05:06.237 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfe...5kj] Closing connection
2024-04-07 23:05:06.241 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfe...5kj] Connection lost: None
2024-04-07 23:08:15.624 WARNING (SyncWorker_11) [homeassistant.loader] We found a custom integration hacs which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2024-04-07 23:08:15.626 WARNING (SyncWorker_11) [homeassistant.loader] We found a custom integration localtuya which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant

Diagnostics information.

No response

xZetsubou commented 3 weeks ago

Not sure how does your device even works if you used cloud api set-up can you post entry diagnostics.

cb12tre commented 3 weeks ago

I have the same problem with a valve, these are the log messages Homeassistant 2024.4.2

2024-04-09 09:28:19.040 DEBUG (MainThread) [custom_components.localtuya.core.pytuya] [bf0...rna] Sending command 10 (device type: v3.4)
2024-04-09 09:28:19.040 DEBUG (MainThread) [custom_components.localtuya.core.pytuya] [bf0...rna] Sending payload: b'{"gwId":"bf006634dfc0d0fe25lrna","devId":"bf006634dfc0d0fe25lrna","uid":"bf006634dfc0d0fe25lrna","t":"1712647699"}'
2024-04-09 09:28:19.040 DEBUG (MainThread) [custom_components.localtuya.core.pytuya] [bf0...rna] final payload for cmd 16: b'{"gwId":"bf006634dfc0d0fe25lrna","devId":"bf006634dfc0d0fe25lrna","uid":"bf006634dfc0d0fe25lrna","t":"1712647699"}'
2024-04-09 09:28:19.043 DEBUG (MainThread) [custom_components.localtuya.core.pytuya] [bf0...rna] Command 16 waiting for seq. number 16263
2024-04-09 09:28:19.180 DEBUG (MainThread) [custom_components.localtuya.core.pytuya] [bf0...rna] Dispatching message CMD 16 TuyaMessage(seqno=16263, cmd=16, retcode=1, payload=b"w{3\x94\xda\x83m)t\xc5\xc0\xb73\xaa\xaa\x9fV';f\x08!e\xbe\xb6\x0cRf\xb9tP(", crc=b'\xfc\xf2Y@*\x97\x8a\xc0r\xefy\xd1\xd3`8D1a\xca}\xdd\x83zo9\xbc)\xa1o\xdeE\x7f', crc_good=True, prefix=21930, iv=None)
2024-04-09 09:28:19.181 DEBUG (MainThread) [custom_components.localtuya.config_flow] Detected DPS: {}
2024-04-09 09:28:19.184 DEBUG (MainThread) [custom_components.localtuya.core.pytuya] [bf0...rna] Closing connection
2024-04-09 09:28:19.186 DEBUG (MainThread) [custom_components.localtuya.core.pytuya] [bf0...rna] Connection lost: None
2024-04-09 09:34:54.214 DEBUG (MainThread) [custom_components.localtuya.core.pytuya] [bf0...rna] 3.4 or 3.5 device: negotiating a new session key
2024-04-09 09:34:54.214 DEBUG (MainThread) [custom_components.localtuya.core.pytuya] [bf0...rna] final payload for cmd 3: b'0123456789abcdef'
2024-04-09 09:34:54.216 DEBUG (MainThread) [custom_components.localtuya.core.pytuya] [bf0...rna] Command 3 waiting for seq. number -102
2024-04-09 09:34:54.407 DEBUG (MainThread) [custom_components.localtuya.core.pytuya] [bf0...rna] Dispatching message CMD 4 TuyaMessage(seqno=22158, cmd=4, retcode=0, payload=b'\xa5\xa3,"\x19\xa3\xad\x9c\'\xa4\xeb\xdc\x8c\xa2sW\xb8c\x1a\xd6\x0b\xa4\r\xde\xd0;R\x86Qp\x84\xaf\xe9\xe9\xa6\xaa\x9cb8\x98\xb5\x07\x1b&\x03k\x9d5\x1bZB"3-Z\x13\xbfC\x1c\x82\xfc(\x9f\x98', crc=b"\xe4\xc6D\xdb\xccB5\xc60\xd9?+\x9e\x80\xb6\xef\xda\xec\x9d\x17'\xfb\xb9\xf7?\x95\xbc\xc9\xf6\\f%", crc_good=True, prefix=21930, iv=None)
2024-04-09 09:34:54.408 DEBUG (MainThread) [custom_components.localtuya.core.pytuya] [bf0...rna] Got key negotiation response
2024-04-09 09:34:54.409 DEBUG (MainThread) [custom_components.localtuya.core.pytuya] [bf0...rna] decrypted session key negotiation step 2: payload=b'd30c7b36b29c23c23s\xc9w8\xd4\x88WPD\x81\xe9j\x02\xd5=@\xd5\x8b\xef\x94\xb1\x13\xe8\x068\x02%\xb8@\x0cL'
2024-04-09 09:34:54.409 DEBUG (MainThread) [custom_components.localtuya.core.pytuya] [bf0...rna] final payload for cmd 5: b'\xdd79\xbe"\x9cY\xc9?\xdfLPP\xec\xbb\xcc\xd3(\xe2%4Q\\\x89\xa5\xe6_\x900\x9brX'
2024-04-09 09:34:54.410 DEBUG (MainThread) [custom_components.localtuya.core.pytuya] [bf0...rna] Session key negotiate success! session key: b'\xf7\xea\x15\xfef{\xbf\xad\x0e\\*\x1d&a\x01T'
2024-04-09 09:34:54.410 DEBUG (MainThread) [custom_components.localtuya.core.pytuya] [bf0...rna] Sending command 10 (device type: v3.4)
2024-04-09 09:34:54.410 DEBUG (MainThread) [custom_components.localtuya.core.pytuya] [bf0...rna] Sending payload: b'{"gwId":"bf006634dfc0d0fe25lrna","devId":"bf006634dfc0d0fe25lrna","uid":"bf006634dfc0d0fe25lrna","t":"1712648094"}'
2024-04-09 09:34:54.410 DEBUG (MainThread) [custom_components.localtuya.core.pytuya] [bf0...rna] final payload for cmd 16: b'{"gwId":"bf006634dfc0d0fe25lrna","devId":"bf006634dfc0d0fe25lrna","uid":"bf006634dfc0d0fe25lrna","t":"1712648094"}'
2024-04-09 09:34:54.413 DEBUG (MainThread) [custom_components.localtuya.core.pytuya] [bf0...rna] Command 16 waiting for seq. number 22159
2024-04-09 09:34:54.659 DEBUG (MainThread) [custom_components.localtuya.core.pytuya] [bf0...rna] Dispatching message CMD 16 TuyaMessage(seqno=22159, cmd=16, retcode=1, payload=b'\x9b[\x17\xe2\xc7M(\x8a\xef\x17\xc4r4V\xbf\xc8I\xa3\xf5\xbeD\xd1c\x81\xbb\xd8i9\x86?L\xc6', crc=b'x\xfe\xb5\xad\x95\t\x90a\xe1\n\xa5\x95\xbe>\x1eLD\xa8\xc7\xa8,\x9dC\x0c\xdf\x04~j\xe7p\xf9x', crc_good=True, prefix=21930, iv=None)
2024-04-09 09:34:54.659 DEBUG (MainThread) [custom_components.localtuya.core.pytuya] [bf0...rna] Sending command 10 (device type: v3.4)
2024-04-09 09:34:54.659 DEBUG (MainThread) [custom_components.localtuya.core.pytuya] [bf0...rna] Sending payload: b'{"gwId":"bf006634dfc0d0fe25lrna","devId":"bf006634dfc0d0fe25lrna","uid":"bf006634dfc0d0fe25lrna","t":"1712648094"}'
2024-04-09 09:34:54.660 DEBUG (MainThread) [custom_components.localtuya.core.pytuya] [bf0...rna] final payload for cmd 16: b'{"gwId":"bf006634dfc0d0fe25lrna","devId":"bf006634dfc0d0fe25lrna","uid":"bf006634dfc0d0fe25lrna","t":"1712648094"}'
2024-04-09 09:34:54.661 DEBUG (MainThread) [custom_components.localtuya.core.pytuya] [bf0...rna] Command 16 waiting for seq. number 22160
2024-04-09 09:34:54.757 DEBUG (MainThread) [custom_components.localtuya.core.pytuya] [bf0...rna] Dispatching message CMD 16 TuyaMessage(seqno=22160, cmd=16, retcode=1, payload=b'\x9b[\x17\xe2\xc7M(\x8a\xef\x17\xc4r4V\xbf\xc8I\xa3\xf5\xbeD\xd1c\x81\xbb\xd8i9\x86?L\xc6', crc=b"5|\xc0m\x80S@\x03\xa2Dk\xf3\xb1\x04\xa6\xf9\x8a\x05S\xc4\x1a\xb3u'|\x06r\x0eI\x8c\xd6\xde", crc_good=True, prefix=21930, iv=None)
2024-04-09 09:34:54.758 DEBUG (MainThread) [custom_components.localtuya.core.pytuya] [bf0...rna] Sending command 10 (device type: v3.4)
2024-04-09 09:34:54.758 DEBUG (MainThread) [custom_components.localtuya.core.pytuya] [bf0...rna] Sending payload: b'{"gwId":"bf006634dfc0d0fe25lrna","devId":"bf006634dfc0d0fe25lrna","uid":"bf006634dfc0d0fe25lrna","t":"1712648094"}'
2024-04-09 09:34:54.758 DEBUG (MainThread) [custom_components.localtuya.core.pytuya] [bf0...rna] final payload for cmd 16: b'{"gwId":"bf006634dfc0d0fe25lrna","devId":"bf006634dfc0d0fe25lrna","uid":"bf006634dfc0d0fe25lrna","t":"1712648094"}'
2024-04-09 09:34:54.759 DEBUG (MainThread) [custom_components.localtuya.core.pytuya] [bf0...rna] Command 16 waiting for seq. number 22161
2024-04-09 09:34:54.923 DEBUG (MainThread) [custom_components.localtuya.core.pytuya] [bf0...rna] Dispatching message CMD 16 TuyaMessage(seqno=22161, cmd=16, retcode=1, payload=b'\x9b[\x17\xe2\xc7M(\x8a\xef\x17\xc4r4V\xbf\xc8I\xa3\xf5\xbeD\xd1c\x81\xbb\xd8i9\x86?L\xc6', crc=b'\xd5\xa8\xaav\xed\xfb\xf0\x15\xc5!z\xd5z\xe8Hc\x06T\xff\xba\x1fo\xf0\xa4\xee\x8fB\x94\xcbwm\x1a', crc_good=True, prefix=21930, iv=None)
2024-04-09 09:34:54.925 DEBUG (MainThread) [custom_components.localtuya.core.pytuya] [bf0...rna] Sending command 10 (device type: v3.4)
2024-04-09 09:34:54.925 DEBUG (MainThread) [custom_components.localtuya.core.pytuya] [bf0...rna] Sending payload: b'{"gwId":"bf006634dfc0d0fe25lrna","devId":"bf006634dfc0d0fe25lrna","uid":"bf006634dfc0d0fe25lrna","t":"1712648094"}'
2024-04-09 09:34:54.926 DEBUG (MainThread) [custom_components.localtuya.core.pytuya] [bf0...rna] final payload for cmd 16: b'{"gwId":"bf006634dfc0d0fe25lrna","devId":"bf006634dfc0d0fe25lrna","uid":"bf006634dfc0d0fe25lrna","t":"1712648094"}'
2024-04-09 09:34:54.927 DEBUG (MainThread) [custom_components.localtuya.core.pytuya] [bf0...rna] Command 16 waiting for seq. number 22162
2024-04-09 09:34:55.066 DEBUG (MainThread) [custom_components.localtuya.core.pytuya] [bf0...rna] Dispatching message CMD 16 TuyaMessage(seqno=22162, cmd=16, retcode=1, payload=b'\x9b[\x17\xe2\xc7M(\x8a\xef\x17\xc4r4V\xbf\xc8I\xa3\xf5\xbeD\xd1c\x81\xbb\xd8i9\x86?L\xc6', crc=b'\xb1\x0cbd<r\x82\x00\xa0t\xff#\xf7\r\xd9\xa5\xe9U\xf9\x1f\x08\x9f\xdb\x8d\xe2\x17\xe8cO\xcd\x84\x93', crc_good=True, prefix=21930, iv=None)
2024-04-09 09:34:55.067 DEBUG (MainThread) [custom_components.localtuya.config_flow] Detected DPS: {}
2024-04-09 09:34:55.067 DEBUG (MainThread) [custom_components.localtuya.core.pytuya] [bf0...rna] Closing connection
2024-04-09 09:34:55.071 DEBUG (MainThread) [custom_components.localtuya.core.pytuya] [bf0...rna] Connection lost: None
cb12tre commented 3 weeks ago

Now it works without having made any changes or updates, maybe it was just a temporary problem with the Tuya servers?

marcofederici92 commented 3 weeks ago

Now it works without having made any changes or updates, maybe it was just a temporary problem with the Tuya servers?

Tomorrow i'll try and let u know-

xZetsubou commented 3 weeks ago

What's is the devices you're trying to setup!?

Connect to the device is completely locally process a odd issues may happen if devices are "blocked from internet incorrectly" however a reason that could made @cb12tre connect later it's because the device was kinda dead? and when it turned on/off it wakes up. this can happen some times since Tuya Devices are toxic on local.

Ensure when you connect to the device that there is no other local connection happened to the device e.g. "any other local integration, smart and tuya apps need to be closed!."

galant-ho commented 2 weeks ago

What's is the devices you're trying to setup!?

Connect to the device is completely locally process a wired issues may happen if devices are "blocked from internet incorrectly" however a reason that could made @cb12tre connect later it's because the device was kinda dead? and when it turned on/off it wakes up. this can happen some times since Tuya Devices are toxic on local.

Ensure when you connect to the device that there is no other local connection happened to the device e.g. "any other local integration, smart and tuya apps need to be closed!."

I had to change my WiFi password, hence had to use Smart Life (one of the official apps to control/setup these Tuya OEM plugs) app to reset them. Of course, by doing this the local_key changed (we knew it). I had no problem accessing the API Explorer page and determine the key.

What I had trouble was re-configure them on HA. I wanted to ensure the plugs was online and in working order so at the same time configuring HA (localtuya) I also had the Smart Life app turned on. THIS IS THE PROBLEM

Thanks @xZetsubou and @cb12tre on checking this and sharing your experience. This is what I spent half day tried to fix it.

github-actions[bot] commented 5 days ago

This issue is stale because it has been open 14 days with no activity. Remove stale label or comment or this will be closed in 5 days.

cb12tre commented 16 hours ago

I've encountered the same problem again; the switch works correctly with both the official Tuya integration and SmartLife. I tried closing the application on the phone and also disabling the Tuya integration, restarting Home Assistant, but I still get the following error: image