Closed Anycubic closed 1 year ago
@Anycubic can you take a look at the https://github.com/leeyuentuen/localtuya/releases/tag/3.6.2-beta if this solved the problem?
@leeyuentuen I've just installed 3.6.2-beta code, I'll let you know, thanks!
I don't have climate stuff, so I can't test that part of the code.
I don't have climate stuff, so I can't test that part of the code.
I can test it for you, more than happy to help!
Hello @leeyuentuen , this morning I had again the issue on all of the devices, like that:
2022-12-29 01:25:47.409 WARNING (SyncWorker_6) [custom_components.localtuya.climate] [84b...f48] Entity climate.sala_nord is requesting unknown DPS index 101
But I saw you published 3.6.2-beta.3 addressing the same issue, just installed it and report back.
have you more logs? because this error is just that the tuya can't get value from DPS because the device is not available, but we need to know if it has crashed before
edit: typically the Zigbee gateway is unavailable for some reason (lost signal, typically after recovery, the value should be getting). But if the Localtuya has crashed due to some reason (which should be shown in the log) then you won't get the value anymore. So I'm searching for the crash of the localtuya log
@leeyuentuen unfortunately the only errors I have in the log with 3.6.2 beta are those ones, nothing wrong regarding local tuya before them like it was happening with 3.6.1
maybe add this in your configuration for more debug logs?
https://github.com/leeyuentuen/localtuya#debugging
logger: default: warning logs: custom_components.localtuya: debug
but next thing that I would implement is passive dps state from here: https://github.com/rospogrigio/localtuya/pull/956/files#diff-a3f5eb9a8d6d90187aad3eb57dacfb61863c40352af98dfcf1fb31cde8a778ed
Ok, I'll that for logs.
@leeyuentuen 3.6.3 broke the integration, all of the devices became unavailable since HA startup. Had to go back to 3.6.2
i need to check on 3.6.3. it is still a alpha version that could be break. maybe i remove them here from the list before other people also download them
@leeyuentuen I had to restart my Zigbee gateway and everything went south, any of my devices are available anymore. I tried to delete and re-add them but don't know why DPS are not recognised anymore (just on of them is recognised).
I deleted everything and started from scratch but I have always the same problem 😢
Is this related to https://github.com/leeyuentuen/localtuya/issues/28#issue-1519567674
maybe?
I really don't know what to do now, any help would be appreciated, thanks
i'm not sure, need to check, but one of my wired zigbee gateway got a firmware update, then it also failed on localtuya. could be a change of version 3.3 to 3.4 platform (tuya platform data message platform). this is also on my todo list to check the issue.
at the moment 3.6.2 is a stable version
@leeyuentuen I don't have automatic update on any device, so I doubt this is the reason. Do I need to reset anything starting from reinstalling standard Tuya integration? I deleted it
are the zigbee device recognized in tuya app on your mobile phone? to be sure if they are connected?
Yep
you can comment all the localtuya code and reboot, then remove the tuya devices in home assistant devices and reboot. remove the comment away from the gateway and see if there are error in the logs. and try uncomment one zigbee device and see if it recognized
Actually now I recalled the very same thing happened to me also in the past with 3.6.1, reinstalled everything from scratch and it worked. Not this time
normally if your device are unavailable, you should see something in the logs
you can comment all the localtuya code and reboot, then remove the tuya devices in home assistant devices and reboot. remove the comment away from the gateway and see if there are error in the logs. and try uncomment one zigbee device and see if it recognized
In which config file?
normally if you device are unavailable, you should see something in the logs
Thats funny because the first thing I did was looking at the logs but devices were recognised and no errors at all but they were unavailable
you can comment all the localtuya code and reboot, then remove the tuya devices in home assistant devices and reboot. remove the comment away from the gateway and see if there are error in the logs. and try uncomment one zigbee device and see if it recognized
In which config file?
you have add them in yaml?
something with localtuya: .....
you can comment all the localtuya code and reboot, then remove the tuya devices in home assistant devices and reboot. remove the comment away from the gateway and see if there are error in the logs. and try uncomment one zigbee device and see if it recognized
In which config file?
you have add them in yaml?
something with localtuya: .....
I just added the gateway from scratch and I don't have anything in /config/configuration.yaml
you can comment all the localtuya code and reboot, then remove the tuya devices in home assistant devices and reboot. remove the comment away from the gateway and see if there are error in the logs. and try uncomment one zigbee device and see if it recognized
In which config file?
you have add them in yaml? something with localtuya: .....
I just added the gateway from scratch and I don't have anything in /config/configuration.yaml
ah, you add them from the config flow instead of adding in configuration yaml
Exactly
you are sure running 3.6.2? not the alpha version?
what for error do you see in the log? maybe add the logging:
I don't know why, but reconfiguring "standard" Tuya integration fixed also Local Tuya
@Anycubic , it happens to me too (i found all of my devices in that state this morning - both independent and sub-devices). I managed to reconnect them by reloading each device individually in settings. After activating debugging i can see that the "Requesting unknown DPS" warning appears when the device is disconnected by localtuya.
2023-01-16 12:19:21.044 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...bhd] Heartbeat failed due to timeout, disconnecting 2023-01-16 12:19:21.047 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...bhd] Connection lost: None 2023-01-16 12:19:21.048 DEBUG (MainThread) [custom_components.localtuya.common] [bfb...bhd] Disconnected - waiting for discovery broadcast 2023-01-16 12:19:21.049 WARNING (SyncWorker_11) [custom_components.localtuya.climate] [bfb...bhd] Entity climate.underfloor_heating is requesting unknown DPS index 1 2023-01-16 12:19:21.052 WARNING (SyncWorker_11) [custom_components.localtuya.climate] [bfb...bhd] Entity climate.underfloor_heating is requesting unknown DPS index 16 2023-01-16 12:19:21.057 WARNING (SyncWorker_11) [custom_components.localtuya.climate] [bfb...bhd] Entity climate.underfloor_heating is requesting unknown DPS index 24 2023-01-16 12:19:21.064 WARNING (SyncWorker_11) [custom_components.localtuya.climate] [bfb...bhd] Entity climate.underfloor_heating is requesting unknown DPS index 2 2023-01-16 12:19:21.067 WARNING (SyncWorker_11) [custom_components.localtuya.climate] [bfb...bhd] Entity climate.underfloor_heating is requesting unknown DPS index 2 2023-01-16 12:19:21.071 WARNING (SyncWorker_11) [custom_components.localtuya.climate] [bfb...bhd] Entity climate.underfloor_heating is requesting unknown DPS index 3 2023-01-16 12:19:21.075 WARNING (SyncWorker_11) [custom_components.localtuya.climate] [bfb...bhd] Entity climate.underfloor_heating is requesting unknown DPS index 3
I'll keep watching it the logs. What I suspect might be happening is that localtuya gets disconnected from the device and somehow does not manage to reconnect.
@alexualbu for me re-addding the devices with integration was not working at all, as I said as strange as it could seem I had to reinstall Tuya integration and everything was back ok. I believe that I messed up with devices name (Tuya name and Local Tuya were the same, though I had deleted Tuya integration) when I re added my devices I just added also "_local" to their name, not to mess up again
@leeyuentuen and btw 3.6.2 is not showing the "unavailable" bug since at least one week, finger crossed
@Anycubic, i had named mine differently (with '_local' :) ) from the beginning. I didn't re-add the devices, clicked reload in the Integrations UI. Did you also restart home-assistant when reinstalling the tuya integration? Restarting seems to also fix it as well. Also running 3.6.2 btw.
@alexualbu last time I had a different kind of problem, everything went bananas after restarting my Zigbee gateway, nothing was working (erased everything, re-added devices, nothing). Then I configured Tuya again (I had removed it totally) and this made my day. Go figure...
So I think I was on to something: gateway disconnected, sub-devices disconnected, errors about unknown DPS appear (1), gateway reconnects - i believe (2), sub-devices did not reconnect automatically afterwards, only with a reload of the device (3). But then it happened again (4) and the gateway did not reconnect (absolutely no log entries for its device id) and a reload of the sub-device does not work anymore(5). And here is where it gets interesting - a reload of the gateway (6) starts producing normal logs(7)... except they appear as unavailable in the UI, even though the history shows data for them (8). After I went in the Smart Life app and changed something the status of the sub-device in HA is magically not unavailable anymore and the history is also updated with a new gap ?! - (9) Apparently this also works if a change is made on the TRV itself. So any status update from the sub-device will do. With this info I can also find another disconnect event dispatched from the gateway to the sub-devices(10)
So my line of thinking now is that if the gateway gets disconnected from localtuya the sub-devices are not added back until they send an update themselves or are reloaded (11). Which I think results in 2 courses of actions:
@leeyuentuen , does this make sense?
So I think I was on to something: gateway disconnected, sub-devices disconnected, errors about unknown DPS appear (1), gateway reconnects - i believe (2), sub-devices did not reconnect automatically afterwards, only with a reload of the device (3). But then it happened again (4) and the gateway did not reconnect (absolutely no log entries for its device id) and a reload of the sub-device does not work anymore(5). And here is where it gets interesting - a reload of the gateway (6) starts producing normal logs(7)... except they appear as unavailable in the UI, even though the history shows data for them (8). After I went in the Smart Life app and changed something the status of the sub-device in HA is magically not unavailable anymore and the history is also updated with a new gap ?! - (9) Apparently this also works if a change is made on the TRV itself. So any status update from the sub-device will do. With this info I can also find another disconnect event dispatched from the gateway to the sub-devices(10)
So my line of thinking now is that if the gateway gets disconnected from localtuya the sub-devices are not added back until they send an update themselves or are reloaded (11). Which I think results in 2 courses of actions:
- identify why the gateway does not reconnect sometimes
- re-add subdevices to the gateway then it reconnects itself
@leeyuentuen , does this make sense?
(1) (2) (3) (4) (5) (6) (7) (8) (9) (10) (11)
@alexualbu this is 100% what I'm also seeing with 3.6.4 beta. Was this fixed in 3.6.4 stable maybe?
@Anycubic , i don't believe there were any changes to 3.6.4 on top of the beta.
On the actual issue, i have an automation running right now that reloads the sub-device when it becomes unavailable (and if it fails it attempts to also reload the gateway) and it seems to be working flawlessly. I expect my hardware set-up is problematic in the sense that the gateway doesn't have great connection to the devices and this is why it's more obvious (it happens many times during the day), but I am pretty sure there is some issue with automatically reconnecting the sub-devices. I was pretty distracted by work (😢 ) this past week, but I hope come weekend I can spend some time to check out the code and try some things since it seems easy to reproduce. I'll keep you updated.
@Anycubic , i don't believe there were any changes to 3.6.4 on top of the beta.
On the actual issue, i have an automation running right now that reloads the sub-device when it becomes unavailable (and if it fails it attempts to also reload the gateway) and it seems to be working flawlessly. I expect my hardware set-up is problematic in the sense that the gateway doesn't have great connection to the devices and this is why it's more obvious (it happens many times during the day), but I am pretty sure there is some issue with automatically reconnecting the sub-devices. I was pretty distracted by work (😢 ) this past week, but I hope come weekend I can spend some time to check out the code and try some things since it seems easy to reproduce. I'll keep you updated.
@alexualbu could you please share you automation code? Giving the situation it could be very useful. I also don't know whether it is better to open a new issue, with 3.6.4, when adding new devices (yes, I had to start again from scratch, upgraded to 3.6.4 and all of the devices were unavailable with no solution...) so when adding new devices recognised DPS are very erratic: all devices are the same, but some of them are with all of the DPSs, other with just 2 or 3 of them. I never saw such a behaviour before
@Anycubic , here's the automation YAML
Interesting behavior with 3.6.4 - i haven't done the actual update, but it sounds very strange, like the config entries get corrupted. I'll give it a try hopefully later today.
I've created a new beta version. What I have tried is disconnecting the power of my gateway, the device became unavailable, reconnect the gateway and it will automatically reconnect (to simulate wifi disconnection?).
2023-01-25 21:33:10.358 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf4...2qe] Connection lost: None
2023-01-25 21:33:10.358 DEBUG (MainThread) [custom_components.localtuya.common] [bf4...2qe] Dispatching event event_disconnected to sub-device a4c138669e188bb2 with data None
2023-01-25 21:33:10.359 DEBUG (MainThread) [custom_components.localtuya.common] [bf4...2qe] Disconnected (TuyaGatewayDevice) - event dispatch event_disconnected
2023-01-25 21:33:10.359 DEBUG (MainThread) [custom_components.localtuya.common] [bf4...2qe] Disconnected (TuyaGatewayDevice) - waiting for discovery broadcast
2023-01-25 21:33:10.359 DEBUG (SyncWorker_4) [custom_components.localtuya.common] [a4c...bb2] Received event event_disconnected from gateway with data None
2023-01-25 21:33:10.360 WARNING (SyncWorker_0) [custom_components.localtuya.sensor] [a4c...bb2] Entity sensor.local_motion_sensor_bedroom_battery is requesting unknown DPS index 4
2023-01-25 21:33:10.362 WARNING (SyncWorker_0) [custom_components.localtuya.sensor] [a4c...bb2] Entity sensor.local_motion_sensor_bedroom_timeout is requesting unknown DPS index 10
2023-01-25 21:33:10.365 WARNING (SyncWorker_3) [custom_components.localtuya.binary_sensor] [a4c...bb2] Entity binary_sensor.local_motion_sensor_bedroom is requesting unknown DPS index 1
2023-01-25 21:33:10.366 DEBUG (SyncWorker_4) [custom_components.localtuya.common] [a4c...bb2] Disconnected TuyaSubDevice: localtuya_a4c138669e188bb2
2023-01-25 21:33:10.368 WARNING (SyncWorker_3) [custom_components.localtuya.binary_sensor] [a4c...bb2] Entity binary_sensor.local_motion_sensor_bedroom is requesting unknown DPS index 1
2023-01-25 21:33:10.375 DEBUG (MainThread) [custom_components.localtuya.common] [bf4...2qe] Connecting to gateway 172.16.0.60
2023-01-25 21:33:11.226 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf4...2qe] Heartbeat failed due to timeout, disconnecting
2023-01-25 21:33:31.433 WARNING (MainThread) [custom_components.localtuya.common] [bf4...2qe] Connect to gateway 172.16.0.60 failed
2023-01-25 21:34:16.305 DEBUG (MainThread) [custom_components.localtuya.common] [bf4...2qe] Connecting to gateway 172.16.0.60
2023-01-25 21:34:16.417 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf4...2qe] Started heartbeat loop
2023-01-25 21:34:16.417 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf4...2qe] Sending command heartbeat (device type: type_0d)
2023-01-25 21:34:16.417 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf4...2qe] Send payload: b'{}'
2023-01-25 21:34:16.419 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf4...2qe] Waiting for sequence number -100
2023-01-25 21:34:16.452 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf4...2qe] Dispatching message TuyaMessage(seqno=0, cmd=9, retcode=0, payload=b'', crc=2958142211, crcpassed=True)
2023-01-25 21:34:16.452 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf4...2qe] Got heartbeat response
2023-01-25 21:34:16.454 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf4...2qe] Decrypted payload: {}
2023-01-25 21:34:26.456 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf4...2qe] Sending command heartbeat (device type: type_0d)
2023-01-25 21:34:26.456 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf4...2qe] Send payload: b'{}'
2023-01-25 21:34:26.457 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf4...2qe] Waiting for sequence number -100
2023-01-25 21:34:26.470 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf4...2qe] Dispatching message TuyaMessage(seqno=0, cmd=9, retcode=0, payload=b'', crc=2958142211, crcpassed=True)
2023-01-25 21:34:26.470 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf4...2qe] Got heartbeat response
2023-01-25 21:34:26.472 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf4...2qe] Decrypted payload: {}
2023-01-25 21:34:35.120 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf4...2qe] Dispatching message TuyaMessage(seqno=0, cmd=8, retcode=0, payload=b'3.3\x00\x00\x00\x00\x00\x00\xee.\x00\x00\x00\x01\xee {\xb1k\x1c\x96\\\xc9 5\xb1\x93\xf2\xc0h\xc7\xd0\xc4\x9c3\x98_\x7f\xff\xc5E\xae\x7f\xc3\x82I\xd9\x0b_)\xc2\xb3\x134\x9d\x93\xd6\xff\xcb\xc7\xc6g\xb3\xde}l\x86z\xa1\xef>\x9e\x0be\xf68\xd0#', crc=41981344, crcpassed=True)
2023-01-25 21:35:04.951 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf4...2qe] Got status update
2023-01-25 21:35:04.952 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf4...2qe] Decrypted payload: {"dps":{"1":"pir"},"cid":"a4c138669e188bb2","t":1674682505}
2023-01-25 21:35:04.952 DEBUG (MainThread) [custom_components.localtuya.common] [bf4...2qe] Dispatching event event_status_updated to sub-device a4c138669e188bb2 with data {'1': 'pir'}
2023-01-25 21:35:04.953 DEBUG (SyncWorker_1) [custom_components.localtuya.common] [a4c...bb2] Received event event_status_updated from gateway with data {'1': 'pir'}
2023-01-25 21:35:04.964 DEBUG (MainThread) [custom_components.localtuya.sensor] [a4c...bb2] Entity Local Motion Sensor Bedroom Battery - Additional attributes: {'raw_state': 100}
2023-01-25 21:35:04.964 DEBUG (MainThread) [custom_components.localtuya.sensor] [a4c...bb2] Entity Local Motion Sensor Bedroom Timeout - Additional attributes: {'raw_state': '30s'}
2023-01-25 21:35:04.965 DEBUG (MainThread) [custom_components.localtuya.binary_sensor] [a4c...bb2] Entity Local Motion Sensor Bedroom - Additional attributes: {'raw_state': 'pir'}
this is a first step to see if the gateway work correctly. afterwards i will reload the sub device, but need to be sure that the gateway is working correctly
atm the sub device could be unavailable, but after the refresh time of the device, you should get the value from the device. but later, after gateway reconnect, i can maybe force them to get the value of the subdevice
very good! I'll test tomorrow and will report back
this is a first step to see if the gateway work correctly. afterwards i will reload the sub device, but need to be sure that the gateway is working correctly
atm the sub device could be unavailable, but after the refresh time of the device, you should get the value from the device. but later, after gateway reconnect, i can maybe force them to get the value of the subdevice
3.6.5 beta 1 is working as intended! I switched of my ZIgbee gateway, TRV valves reconnected by themselves
@leeyuentuen unfortunately it seems there is still a problem with 1.6.5 beta. Indeed devices come back after switching off/on the gateway, but when they came back are in zombie state. Restarting HA or the plugin doesn't work to fix the issue. The only thing which works is doing anything from Smart Life app (i.e. switch off/on the devices) they will get back to life also on HA
let me later try to fix reconnect subdevices and see if this help. but it seems gateway already works here
@leeyuentuen unfortunately it seems there is still a problem with 1.6.5 beta. Indeed devices come back after switching off/on the gateway, but when they came back are in zombie state. Restarting HA or the plugin doesn't work to fix the issue. The only thing which works is doing anything from Smart Life app (i.e. switch off/on the devices) they will get back to life also on HA
but if you wait for a long time (1-2 hours) should it recover the value? i know for my sensor. it will not instantly send update of the value of the temperature. maybe after 30 min or after 1 hour.
but same like previous post, i can try to force to update
@leeyuentuen unfortunately it seems there is still a problem with 1.6.5 beta. Indeed devices come back after switching off/on the gateway, but when they came back are in zombie state. Restarting HA or the plugin doesn't work to fix the issue. The only thing which works is doing anything from Smart Life app (i.e. switch off/on the devices) they will get back to life also on HA
but if you wait for a long time (1-2 hours) should it recover the value? i know for my sensor. it will not instantly send update of the value of the temperature. maybe after 30 min or after 1 hour.
but same like previous post, i can try to force to update
But I see a big issue in this scenario: I could not be aware that the gateway went off line and on line for any reason, giving commands to valves and being not aware at all that those commands were not executed. I mean, everything seems working fine except that it doesn't. I myself wasn't aware of this issue, and I think that more than hour had passed after I power cycled the gateway
At the moment, the problem is that the 'gateway is offline' when it is back online we don't have the data in the gateway, we need to wait that the subdevice (in this case the trv) to let us know what the data is.
for my motion sensor i've got here an example
and i got this data in my debug:
2023-01-28 19:39:03.364 DEBUG (SyncWorker_2) [custom_components.localtuya.common] [a4c...bb2] Received event event_status_updated from gateway with data {'1': 'pir'}
2023-01-28 19:39:03.377 DEBUG (MainThread) [custom_components.localtuya.binary_sensor] [a4c...bb2] Entity Local Motion Sensor Bedroom - Additional attributes: {'raw_state': 'pir'}
so I got only the PIR state (motion detection) but didn't get the battery state or the timeout value. I need to wait for it.
The other solution could be using caching. so if we don't restart home assistant, the last know value will be showing them.
@Anycubic , here's the automation YAML
Automation code Interesting behavior with 3.6.4 - i haven't done the actual update, but it sounds very strange, like the config entries get corrupted. I'll give it a try hopefully later today.
@leeyuentuen @alexualbu this issue is still there in 3.6.5 beta 2. DPS ID are populated only after they have been "touched" at least once from Smart Life app, otherwise they will not appear in the config flow.
@anycubic - i updated to 3.6.5. sub-devices worked normally after that. the issue you mention about DPs not appearing in some sub devices was there earlier - i am not sure how DP detection works, but some of them (inputs) have to be touched from smartlife to ensure they appear.
@leeyuentuen , regarding the reconnection issue, on my side i couldn't confirm yet if the sub-devices actually get reloaded on their own - ran without the automation for a few hours and they didn't. i'll try to test on the dev instance to confirm. however there is a new issue after 3.6.5 that sometimes even a reload of the sub-device will not bring it back to life (also need to investigate more here)
@alexualbu I confirm after gateway off/on cycle devices will never get back by themselves, which is really dangerous since I have automation using them. Also the 2nd gateway bug is really a big one (devices not working if plugged to a 2nd gateway).
@alexualbu I confirm after gateway off/on cycle devices will never get back by themselves, which is really dangerous since I have automation using them. Also the 2nd gateway bug is really a big one (devices not working if plugged to a 2nd gateway).
@Anycubic for the second gateway, have you try the beta version 3.7? because during the change of the protocol to 3.4 i found something that could maybe give issue with second gateway. i've reply on this issue: https://github.com/leeyuentuen/localtuya/issues/36
Suddenly and apparently randomly devices become unavailable forever. I have 6 TRV valves connected to a ZIgbee Gateway, in Tuya they work fine. Reloading Local Tuya does not help, to fix it I have to restart Home Assistant. Unfortunately after a while the same thing happens.
Environment Localtuya version: 3.6.1 Last working localtuya version (if known and relevant): 3.5.3 Home Assistant Core version: 2022.12 Are you using the Home Assistant Tuya Cloud component ? no Are you using the Tuya App in parallel ? Just for reading devices status
home-assistant_2022-12-21T21-35-32.480Z copy.txt