rospogrigio / localtuya

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

Girier plugs stop reporting power altogether #370

Open Tryfos opened 3 years ago

Tryfos commented 3 years ago

I have these plugs: https://www.aliexpress.com/item/4000801500192.html?spm=a2g0s.9042311.0.0.6c154c4daUqiLe I’ve managed to successfully integrate them through localtuya in HA along with power readings. GREAT integration by the way! My only problem is that after some hours (which can be 48h) they stop reporting power readings altogether. This means to both HA and the Tuya app. I have to unplug and replug them manually, in order for them to start reporting power readings again. When this happens, readings could be just plain 0W or a last reading (eg. 92W), which then stays forever.

The interesting thing is that the switching part works as it should, even if power is not reported. Plugs never show as unavailable in HA. The number of hours until they stop reporting is completely random, so I cannot debug. I have not blocked internet to them. I've tried with both disconnecting them from Tuya app and having the app installed and them connected. Localtuya logs show no error, apart from the same devices being discovered over and over again (I don’t know if this is the expected behavior after they are discovered in the first place): 2021-02-15 22:09:01 DEBUG (MainThread) [custom_components.localtuya.discovery] Discovered device: {'ip': '192.168.1.67', 'gwId': 'bf4fbfdd0c0d77bb16rewi', 'active': 2, 'ablilty': 0, 'encrypt': True, 'productKey': 'keyt4addwh57c5wf', 'version': '3.3'} 2021-02-15 22:09:01 DEBUG (MainThread) [custom_components.localtuya] Device bf4fbfdd0c0d77bb16rewi found with IP 192.168.1.67 2021-02-15 22:09:02 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf4...ewi] Sending command heartbeat (device type: type_0a) 2021-02-15 22:09:02 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf4...ewi] Send payload: b'{}' 2021-02-15 22:09:02 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf4...ewi] Waiting for sequence number -100 2021-02-15 22:09:02 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf4...ewi] Dispatching message TuyaMessage(seqno=0, cmd=9, retcode=0, payload=b'', crc=2958142211) 2021-02-15 22:09:02 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf4...ewi] Got heartbeat response 2021-02-15 22:09:02 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf4...ewi] Decrypted payload: {} 2021-02-15 22:09:02 DEBUG (MainThread) [custom_components.localtuya.discovery] Discovered device: {'ip': '192.168.1.69', 'gwId': 'bf8234672ac806862ahzvs', 'active': 2, 'ablilty': 0, 'encrypt': True, 'productKey': 'teuu8swy9614jrxm', 'version': '3.3'} 2021-02-15 22:09:02 DEBUG (MainThread) [custom_components.localtuya] Device bf8234672ac806862ahzvs found with IP 192.168.1.69 2021-02-15 22:09:02 DEBUG (MainThread) [custom_components.localtuya.discovery] Discovered device: {'ip': '192.168.1.68', 'gwId': 'bf0de23c1216a32827ri7e', 'active': 2, 'ablilty': 0, 'encrypt': True, 'productKey': 'teuu8swy9614jrxm', 'version': '3.3'} 2021-02-15 22:09:02 DEBUG (MainThread) [custom_components.localtuya] Device bf0de23c1216a32827ri7e found with IP 192.168.1.68 2021-02-15 22:09:03 DEBUG (MainThread) [custom_components.localtuya.discovery] Discovered device: {'ip': '192.168.1.64', 'gwId': 'bf697f0ad7fe77d240lujc', 'active': 2, 'ablilty': 0, 'encrypt': True, 'productKey': 'keyt4addwh57c5wf', 'version': '3.3'} 2021-02-15 22:09:03 DEBUG (MainThread) [custom_components.localtuya] Device bf697f0ad7fe77d240lujc found with IP 192.168.1.64 2021-02-15 22:09:04 DEBUG (MainThread) [custom_components.localtuya.discovery] Discovered device: {'ip': '192.168.1.66', 'gwId': 'bf6f4443b3500f8180xazz', 'active': 2, 'ablilty': 0, 'encrypt': True, 'productKey': 'keyt4addwh57c5wf', 'version': '3.3'} 2021-02-15 22:09:04 DEBUG (MainThread) [custom_components.localtuya] Device bf6f4443b3500f8180xazz found with IP 192.168.1.66 2021-02-15 22:09:04 DEBUG (MainThread) [custom_components.localtuya.discovery] Discovered device: {'ip': '192.168.1.65', 'gwId': 'bf86b0cb0ee78d13652vne', 'active': 2, 'ablilty': 0, 'encrypt': True, 'productKey': 'keyt4addwh57c5wf', 'version': '3.3'} 2021-02-15 22:09:04 DEBUG (MainThread) [custom_components.localtuya] Device bf86b0cb0ee78d13652vne found with IP 192.168.1.65

I’m starting to think that it’s the plugs’ fault and I should just replace them. Any ideas?

banaslee commented 3 years ago

I have the same problem but happens immediately when I block internet to my plugs (from Gosund). Power consumption stops being reported and whatever value was there, stays forever. Switching them on and off works flawlessly though.

I wonder if yours have any problem connecting to the internet or getting a successful response from the DNS that prevents them from connecting with whatever they need to connect to have power consumption reporting correctly.

It's similar with https://github.com/rospogrigio/localtuya/issues/194 but I can turn my plug on and off.

Tryfos commented 3 years ago

No power reporting when internet is off is a well known issue. Plugs remain in "zombie" state and do not report anything. It is advised in the main page of this integration to also block DNS requests from the plugs to your router, in order for them to report power without internet. I haven't done that, since I haven't found a way to block DNS requests to my own router (this is not explained how and I cannot find an easy solution). No, I think my problem is different, since power stops being reported, even if Internet is connected, even to the Tuya app after a while. Either 0W or a constant number. I haven't been able to troubleshoot, because this happens in random times after replug. Switch on-off works always flawlessly, with or without Internet. I've since concluded that this a problem of the plugs (not localtuya) and I cannot do anything about it. I have to say this integration is excellent and our only solution, since literally 9/10 of the plugs I've recently purchased do not have ESP chip. This is a shame.