krahabb / meross_lan

Home Assistant integration for Meross devices
MIT License
424 stars 47 forks source link

Devices Become Unavailable But Still Work Via App #238

Closed Nerwyn closed 1 year ago

Nerwyn commented 1 year ago

Version of the custom_component

Present on both v2.6.2 and v2.7.0-alpha.0

Configuration

I'm not exactly sure where to find the yaml for the device configuration. The device host address is statically set by my router DHCP server and the key is cloud retrieved. The devices work most of the time and were working perfectly up to a couple of weeks ago.

Describe the bug

As of a week or two ago, my Meross devices configured via this integration will intermittently become unavailable before going completely unresponsive. Restarting Home Assistant does not always help, nor does restarting the device by turning it off and on. The only thing that does seem to work is restarting my router and home assistant server several times until the device becomes responsive again, but this issue is starting to occur every few hours and that is becoming untenable.

The devices still do work via the Meross app when this issue occurs and do show up in my router DHCP list as assigned to their static IPs, BUT I get timeout errors when I try to ping them in the command prompt. The issue is also not occurring consistently on the same devices and seems to be random. These devices are not configured via MQTT, and should be working over HTTP.

Debug log

The download diagnostics for both the currently not working Meross device and the Meross LAN integration have been attached. The log with just meross_lan debug logging enabled is a couple of thousand lines and has been attached. The main error is the following:

Logger: custom_components.meross_lan
Source: custom_components/meross_lan/helpers.py:27
Integration: Meross LAN ([documentation](https://github.com/krahabb/meross_lan), [issues](https://github.com/krahabb/meross_lan/issues))
First occurred: 10:20:11 PM (3 occurrences)
Last logged: 10:20:25 PM
- MerossDevice(2204119681230052050148e1e98f0afa) error in async_http_request: Server disconnected
- MerossDevice(2204113366714352050148e1e98ef959) error in async_http_request: Server disconnected
- MerossDevice(2204117511381852050148e1e98f0812) error in async_http_request: TimeoutError

config_entry-meross_lan-5d75ae75398af1c609dbc2a9c863b517.json.txt meross_lan-5d75ae75398af1c609dbc2a9c863b517-Smart RGB Bulb (2204117511381852050148e1e98f0812)-71e50c6186e3e45b973e9c867e63a25c.json.txt home-assistant_2022-12-25T03-22-24.982Z.log

krahabb commented 1 year ago

Hello @Nerwyn, Sorry to hear that but this strongly hints me to maybe a device firmware update which introduced a subtle bug in th edveice itself. meross_lan is a bit 'strict' on disconnections by the device so it quickly reports the issue after few failed communication attempts. It looks like the device starts rejecting the connection attempts ('Server disconnected') and then maybe totaly ignore ('TimeoutError') these since the internal http stack is maybe crashed or so.... The Meross app might be working still since it uses a communication channel through the cloud mqtt servers to communicate and this could be unaffected.

I have a plan to further reduce meross_lan 'sensitivity' to HTTP disconnections and failures (those that are temporary, that is...) but still the issue might come when you just need to operate the device and HA/meross_lan is unable to reliably send the command

Nerwyn commented 1 year ago

I think I found the root cause of the issue but it sounds too ridiculous to be true. My Christmas Tree has a ton of individual addressable LEDs in it and a couple of weeks ago I set it up in the corner of my living room in front of my WiFi router. The electronics used to drive LEDs can interfere with WiFi signals, and it seems that Meross bulbs and switches are especially susceptible to this. I moved my Christmas tree to a different part of the room and no more problem! Two days now with zero downtime on any of my Meross devices integrated through this amazing integration. I'll reopen if it the issue happens again when the Christmas tree is gone but it looks like this was a weird edge case caused by my gaudy Christmas tree. Happy Holidays!

krahabb commented 1 year ago

Wow...that's a powerful Christmas Tree! ...Awesome ;)

time for a nice old ...'Merry Christmas'