bwp91 / homebridge-meross

Homebridge plugin to integrate Meross devices into HomeKit.
MIT License
197 stars 32 forks source link

Plugin breaks connection to Meross cloud #514

Open gkahn84 opened 1 year ago

gkahn84 commented 1 year ago

What issue do you have? Please be as thorough and explicit as possible.

I have a strange problem with my Homebridge/Meross setup and after a lot of troubleshooting and analysis I have the feeling that this plugin might be the cause.

When all my components are configured and homebridge is started everything is fine. I can add all thermostats to Homekit and control them totally fine from the Home app as well as the Meross app itself. But after some time all requests to control the thermostats run in a timeout and I can't control anything anymore. Not from the Home app and also not from the Meross app.

So I first suspected the MSH300HK hub to lose connection to the Meross cloud because of WiFi issues. I tried everything I could find in similar issues (locking WiFi channel and IPs, using 2.4GHz only, deactivating "smart" router features and so on). Nothing helped, after a while all requests from Home or Meross apps time out.

Interestingly the hub itself always has connection to WiFi and internet as I checked on my router, by pinging/tracerouting it and using Wireshark network analysis (also when requests from the apps and hence requests to the Meross cloud time out).

Another strong indicator that this plugin may be the cause of the problem is that when I restart the plugin everything is fine again for a while. Until eventually the connection to the cloud gets blocked/frozen again.

So I started running a cronjob that kills the plugin every ten minutes and since I did this, it's now been 3 days without any problem. Once I deactivate the cronjob, the timeout return after a while (as I tested again today, see logs below).

My initial guess without knowing the details of how this plugin communicates would be that the plugin maybe opens connections/websockets to the Meross cloud without closing/reusing them and hence is creating more and more open connections until the Meross Cloud is not allowing any new ones.

One other thing I noticed is that when the plugin checks the device cloud status it first sees the hub as online and 5 seconds later it is reported offline. But this doesn't mean that it is broken already. Initially everything works fine even when the logs say the hub has been reported offline. As mentioned it takes a while until everything seizes to work (at which time the logs still look the same until you actually control something, then you see a timeout).

Do you have any idea about this? I'm happy to provide more help if I can.

Details of your setup.

Please paste any relevant logs below.

[20/03/2023, 11:36:02] Registering platform 'homebridge-meross.Meross'
[20/03/2023, 11:36:07] [Meross] Initializing Meross platform...
[20/03/2023, 11:36:07] [Meross] Initializing child bridge *****
[20/03/2023, 11:36:12] [Meross] Launched child bridge with PID 3576
[20/03/2023, 11:36:14] Registering platform 'homebridge-meross.Meross'
[20/03/2023, 11:36:15] [Meross] Loaded homebridge-meross v9.0.1 child bridge successfully
[20/03/2023, 11:36:15] [Meross] Initialising plugin v9.0.1 | System linux | Node v18.15.0 | HB v1.6.0 | HAPNodeJS v0.11.0...
[20/03/2023, 11:36:15] Publishing bridge accessory (name: Meross, publishInfo: {
[20/03/2023, 11:36:15] [Meross] Plugin initialised. Setting up accessories....
[20/03/2023, 11:36:16] Homebridge v1.6.0 (HAP v0.11.0) (Meross) is running on port 51547.
[20/03/2023, 11:36:18] [Meross] [Badezimmer] initialising with options {"connection":"hybrid","lowBattThreshold":20}.
[20/03/2023, 11:36:18] [Meross] [Smart Wi-Fi Hub] [Badezimmer] subdevice initialised with id [*****].
[20/03/2023, 11:36:18] [Meross] [Wohnzimmer] initialising with options {"connection":"hybrid","lowBattThreshold":20}.
[20/03/2023, 11:36:18] [Meross] [Smart Wi-Fi Hub] [Wohnzimmer] subdevice initialised with id [*****].
[20/03/2023, 11:36:18] [Meross] [Flur] initialising with options {"connection":"hybrid","lowBattThreshold":20}.
[20/03/2023, 11:36:18] [Meross] [Smart Wi-Fi Hub] [Flur] subdevice initialised with id [*****].
[20/03/2023, 11:36:18] [Meross] [Küche] initialising with options {"connection":"hybrid","lowBattThreshold":20}.
[20/03/2023, 11:36:18] [Meross] [Smart Wi-Fi Hub] [Küche] subdevice initialised with id [*****].
[20/03/2023, 11:36:18] [Meross] [Schlafzimmer] initialising with options {"connection":"hybrid","lowBattThreshold":20}.
[20/03/2023, 11:36:18] [Meross] [Smart Wi-Fi Hub] [Schlafzimmer] subdevice initialised with id [*****].
[20/03/2023, 11:36:18] [Meross] [Smart Wi-Fi Hub] initialised with id [*****}].
[20/03/2023, 11:36:19] [Meross] ✓ Setup complete. Have a feature request? Visit https://bit.ly/hb-meross-issues to ask!
[20/03/2023, 11:36:22] [Meross] [Badezimmer] has been reported [online].
[20/03/2023, 11:36:22] [Meross] [Wohnzimmer] has been reported [online].
[20/03/2023, 11:36:22] [Meross] [Flur] has been reported [online].
[20/03/2023, 11:36:22] [Meross] [Küche] has been reported [online].
[20/03/2023, 11:36:23] [Meross] [Schlafzimmer] has been reported [online].
[20/03/2023, 11:36:23] [Meross] [Smart Wi-Fi Hub] has been reported [online].
[20/03/2023, 11:51:21] [Meross] [Smart Wi-Fi Hub] has been reported [offline].
[20/03/2023, 11:56:17] [Meross] [Badezimmer] has been reported [online].
[20/03/2023, 11:56:17] [Meross] [Wohnzimmer] has been reported [online].
[20/03/2023, 11:56:17] [Meross] [Flur] has been reported [online].
[20/03/2023, 11:56:17] [Meross] [Küche] has been reported [online].
[20/03/2023, 11:56:17] [Meross] [Schlafzimmer] has been reported [online].
[20/03/2023, 11:56:17] [Meross] [Smart Wi-Fi Hub] has been reported [online].
[20/03/2023, 11:56:22] [Meross] [Smart Wi-Fi Hub] has been reported [offline].
[20/03/2023, 12:01:17] [Meross] [Badezimmer] has been reported [online].
[20/03/2023, 12:01:17] [Meross] [Wohnzimmer] has been reported [online].
[20/03/2023, 12:01:17] [Meross] [Flur] has been reported [online].
[20/03/2023, 12:01:17] [Meross] [Küche] has been reported [online].
[20/03/2023, 12:01:17] [Meross] [Schlafzimmer] has been reported [online].
[20/03/2023, 12:01:17] [Meross] [Smart Wi-Fi Hub] has been reported [online].
[20/03/2023, 12:01:21] [Meross] [Smart Wi-Fi Hub] has been reported [offline]. <--- Reported offline
[20/03/2023, 12:01:53] [Meross] [Badezimmer] current temperature [23°C]. <--- But reading temp
[20/03/2023, 12:06:07] [Meross] [Badezimmer] current state [off]. <--- And controlling state still works fine
[20/03/2023, 12:06:09] [Meross] [Badezimmer] current state [on].
[20/03/2023, 12:06:17] [Meross] [Badezimmer] has been reported [online].
[20/03/2023, 12:06:17] [Meross] [Wohnzimmer] has been reported [online].
[20/03/2023, 12:06:17] [Meross] [Flur] has been reported [online].
[20/03/2023, 12:06:17] [Meross] [Küche] has been reported [online].
[20/03/2023, 12:06:17] [Meross] [Schlafzimmer] has been reported [online].
[20/03/2023, 12:06:17] [Meross] [Smart Wi-Fi Hub] has been reported [online].
[20/03/2023, 12:06:17] [Meross] [Schlafzimmer] current target [19.5°C].
[20/03/2023, 12:06:21] [Meross] [Smart Wi-Fi Hub] has been reported [offline].
[20/03/2023, 12:06:23] [Meross] [Schlafzimmer] current target [17°C].
[20/03/2023, 12:06:28] [Meross] [Schlafzimmer] current state [off].
[20/03/2023, 12:06:29] [Meross] [Schlafzimmer] current state [on].
...
[20/03/2023, 17:49:03] [Meross] [Badezimmer] current temperature [24°C].
[20/03/2023, 17:51:17] [Meross] [Badezimmer] has been reported [online].
[20/03/2023, 17:51:17] [Meross] [Wohnzimmer] has been reported [online].
[20/03/2023, 17:51:17] [Meross] [Flur] has been reported [online].
[20/03/2023, 17:51:17] [Meross] [Küche] has been reported [online].
[20/03/2023, 17:51:18] [Meross] [Schlafzimmer] has been reported [online].
[20/03/2023, 17:51:18] [Meross] [Smart Wi-Fi Hub] has been reported [online].
[20/03/2023, 17:51:22] [Meross] [Smart Wi-Fi Hub] has been reported [offline].
[20/03/2023, 17:52:04] [Meross] [Badezimmer] current temperature [23°C].
[20/03/2023, 17:53:34] [Meross] [Badezimmer] sending update failed as the request timed out. <--- First timeouts
[20/03/2023, 17:54:00] [Meross] [Schlafzimmer] sending update failed as the request timed out.
[20/03/2023, 17:54:09] [Meross] [Schlafzimmer] sending update failed as the request timed out.
[20/03/2023, 17:55:40] [Meross] [Schlafzimmer] current state [off].
[20/03/2023, 17:55:42] [Meross] [Schlafzimmer] current state [on].
[20/03/2023, 17:56:17] [Meross] [Badezimmer] has been reported [online].
[20/03/2023, 17:56:17] [Meross] [Wohnzimmer] has been reported [online].
[20/03/2023, 17:56:17] [Meross] [Flur] has been reported [online].
[20/03/2023, 17:56:17] [Meross] [Küche] has been reported [online].
[20/03/2023, 17:56:17] [Meross] [Schlafzimmer] has been reported [online].
[20/03/2023, 17:56:18] [Meross] [Smart Wi-Fi Hub] has been reported [online].
[20/03/2023, 17:56:22] [Meross] [Smart Wi-Fi Hub] has been reported [offline].
[20/03/2023, 17:57:18] [Meross] [Schlafzimmer] sending update failed as the request timed out.
[20/03/2023, 17:57:28] [Meross] [Schlafzimmer] sending update failed as the request timed out.
[20/03/2023, 17:58:07] [Meross] Restarting child bridge... <--- Restarted child bridge
[20/03/2023, 17:58:07] [Meross] [Smart Wi-Fi Hub] mqtt connection closed.
[20/03/2023, 17:58:12] [Meross] Child bridge process ended
[20/03/2023, 17:58:12] [Meross] Process Ended. Code: 143, Signal: null
[20/03/2023, 17:58:19] [Meross] Restarting Process...
[20/03/2023, 17:58:21] [Meross] Launched child bridge with PID 18447
[20/03/2023, 17:58:23] Registering platform 'homebridge-meross.Meross'
[20/03/2023, 17:58:23] [Meross] Loaded homebridge-meross v9.0.1 child bridge successfully
[20/03/2023, 17:58:23] [Meross] Initialising plugin v9.0.1 | System linux | Node v18.15.0 | HB v1.6.0 | HAPNodeJS v0.11.0...
[20/03/2023, 17:58:23] Publishing bridge accessory (name: Meross, publishInfo: {
[20/03/2023, 17:58:23] [Meross] Plugin initialised. Setting up accessories....
[20/03/2023, 17:58:24] Homebridge v1.6.0 (HAP v0.11.0) (Meross) is running on port 51547.
[20/03/2023, 17:58:25] [Meross] [Badezimmer] initialising with options {"connection":"hybrid","lowBattThreshold":20}.
[20/03/2023, 17:58:25] [Meross] [Smart Wi-Fi Hub] [Badezimmer] subdevice initialised with id [*****].
[20/03/2023, 17:58:25] [Meross] [Wohnzimmer] initialising with options {"connection":"hybrid","lowBattThreshold":20}.
[20/03/2023, 17:58:25] [Meross] [Smart Wi-Fi Hub] [Wohnzimmer] subdevice initialised with id [*****].
[20/03/2023, 17:58:25] [Meross] [Flur] initialising with options {"connection":"hybrid","lowBattThreshold":20}.
[20/03/2023, 17:58:25] [Meross] [Smart Wi-Fi Hub] [Flur] subdevice initialised with id [*****].
[20/03/2023, 17:58:25] [Meross] [Küche] initialising with options {"connection":"hybrid","lowBattThreshold":20}.
[20/03/2023, 17:58:25] [Meross] [Smart Wi-Fi Hub] [Küche] subdevice initialised with id [*****].
[20/03/2023, 17:58:25] [Meross] [Schlafzimmer] initialising with options {"connection":"hybrid","lowBattThreshold":20}.
[20/03/2023, 17:58:25] [Meross] [Smart Wi-Fi Hub] [Schlafzimmer] subdevice initialised with id [*****].
[20/03/2023, 17:58:25] [Meross] [Smart Wi-Fi Hub] initialised with id [*****}].
[20/03/2023, 17:58:26] [Meross] ✓ Setup complete. Check out my other Homebridge plugins! https://github.com/bwp91
[20/03/2023, 17:58:33] [Meross] [Smart Wi-Fi Hub] has been reported [offline].
[20/03/2023, 18:02:07] [Meross] [Küche] current state [off]. <--- Controlling state works again
[20/03/2023, 18:02:13] [Meross] [Küche] current state [on].
[20/03/2023, 18:02:29] [Meross] [Schlafzimmer] current target [22°C].
[20/03/2023, 18:02:34] [Meross] [Schlafzimmer] current target [17°C].

Timeout in Home app:

Timeout in Meross app:

schemers commented 1 year ago

I’ve also started seeing “No response” from HomeKit for all my Homebridge plugins as well. If I login to the Homebridge server and restart it, they all come back for some period of time. I also resorted to restarting the Homebridge server (first ever 6 hours, then 3, then 2, etc).

I’m also running Homebridge v1.6.0, and was running Node.js 18.15.0, though a few minutes ago I just downgraded to Node 18.4.2 to see if that helps the situation. I had upgraded to Node.js 18.15.0 because this plugin tends to always recommend the latest, even though it probably should only update the recommended Node.js versions less frequently.

In my case I can still access the garage door openers from the Meross app.

schemers commented 1 year ago

I should also mention I’m following these HomeBridge issues:

https://github.com/homebridge/homebridge/issues/3335 https://github.com/homebridge/homebridge/issues/3251

It feels like the only recent changes I’ve made to my system were updating to latest Node.js, and updating this plugin to 9.0.1 (from v8.5.3)

gkahn84 commented 1 year ago

@schemers I don't think that our issues are related. Mine is only about this plugin, everything else (other plugins/child bridges as well as the main bridge) works totally fine even when requests to Meross time out.

schemers commented 1 year ago

@gkahn84 ah, sorry about that. Are you using child bridges for everything? I'm not using child bridges at all and might switch over to them to see if that isolates the problem to a single child bridge instead of causing issues with all of them (I'm running 5 plugins).

gkahn84 commented 1 year ago

@schemers Yes, I'm running every plugin in its own child bridge.

bwp91 commented 1 year ago

Hi @gkahn84 is this still an ongoing issue?

gkahn84 commented 1 year ago

Hi @bwp91, yes, it is. With my cronjob (which restarts the child bridge every 20 minutes) active, I haven't had any issues for some weeks now. This morning I deactivated the cronjob and now, about 5h later, the connection to the Meross cloud is broken again as described in the issue.

ogerardin commented 8 months ago

I have the same behaviour. I have 6 smart thermostats MTS100v3 and a hub MSH300 and I was seeing most themostats offline in the Meross app, sometimes 1 or 2 would come online briefly but if I try to interact with them I often get a timetout... This was driving me mad and then I thought could it be homebridge?? I stopped it and I haven't had a single thermostat offline in the Meross app for 24 hours now.

In the log I also see the same pattern [Hub] has been reported [online] / [Hub] has been reported [offline]

My setting: Synology DS918+, latest versions of everything, meross plugin runs in a child bridge.

gkahn84 commented 8 months ago

I’m still experiencing this as well. My workaround with a cronjob restarting the Meross plugin child bridge every 20 minutes works fine for me though.

gkahn84 commented 8 months ago

(Sorry, accidentally closed and reopened the issue)

ogerardin commented 8 months ago

I’m still experiencing this as well. My workaround with a cronjob restarting the Meross plugin child bridge every 20 minutes works fine for me though.

Yes I saw that... I'm not ready to do that yet :) I would highly prefer a clean fix than this workaround.

MikeFCVP commented 8 months ago

Hello, I got the same issue:

[11/3/2023, 12:38:32 PM] [Meross] [Smart Hub] has been reported [offline]. [11/3/2023, 12:38:32 PM] [Meross] [Smart Hub Old] has been reported [offline]. [11/3/2023, 12:43:28 PM] [Meross] [Kid's Room] has been reported [online]. [11/3/2023, 12:43:28 PM] [Meross] [Master Bedroom] has been reported [online]. [11/3/2023, 12:43:28 PM] [Meross] [Smart Hub] has been reported [online]. [11/3/2023, 12:43:32 PM] [Meross] [Smart Hub] has been reported [offline]. [11/3/2023, 12:46:46 PM] [Meross] [Master Bedroom] current temperature [15°C]. [11/3/2023, 12:47:02 PM] [Homebridge UI] [homebridge-meross] Terminating child process... [11/3/2023, 12:47:02 PM] [Homebridge UI] [homebridge-meross] Child process ended [11/3/2023, 12:48:28 PM] [Meross] [Living Room] has been reported [online]. [11/3/2023, 12:48:28 PM] [Meross] [Bar] has been reported [online]. [11/3/2023, 12:48:28 PM] [Meross] [Kitchen] has been reported [online]. [11/3/2023, 12:48:28 PM] [Meross] [Smart Hub Old] has been reported [online]. [11/3/2023, 12:48:28 PM] [Meross] [Kid's Room] has been reported [online]. [11/3/2023, 12:48:28 PM] [Meross] [Master Bedroom] has been reported [online]. [11/3/2023, 12:48:28 PM] [Meross] [Smart Hub] has been reported [online]. [11/3/2023, 12:48:32 PM] [Meross] [Smart Hub Old] has been reported [offline]. [11/3/2023, 12:48:32 PM] [Meross] [Smart Hub] has been reported [offline]. [11/3/2023, 12:53:28 PM] [Meross] [Kid's Room] has been reported [online]. [11/3/2023, 12:53:28 PM] [Meross] [Master Bedroom] has been reported [online]. [11/3/2023, 12:53:28 PM] [Meross] [Smart Hub] has been reported [online]. [11/3/2023, 12:53:32 PM] [Meross] [Smart Hub] has been reported [offline].

Every 5min Hubs goes offline for whatever reason.

Node 18.20. HB 1.6.1. Meross 10.0.0

ogerardin commented 8 months ago

This bug also completely messes up the schedule of the thermostats... I had stopped the plugin but after an update of Homebridge it got restarted without me noticing, and I woke up today to a cold house, I checked the schecules and they had been reset to a flat line. So until this bug is solved I have disabled the plugin completely.

ogerardin commented 8 months ago

I see there's some work in progress on 10.0.1, is this bug part of it? If you need to test a fix let me know :)

MikeFCVP commented 8 months ago

This bug also completely messes up the schedule of the thermostats... I had stopped the plugin but after an update of Homebridge it got restarted without me noticing, and I woke up today to a cold house, I checked the schecules and they had been reset to a flat line. So until this bug is solved I have disabled the plugin completely.

Exactly, I had the same issue. Yesterday decided to leave Meross, installed MOES Thermostats (Tuya compatible) and all works just fine on Homebridge...

ogerardin commented 8 months ago

Exactly, I had the same issue. Yesterday decided to leave Meross, installed MOES Thermostats (Tuya compatible) and all works just fine on Homebridge...

If I wanted to change the thermostats I think I would go for the MTS150 which are natively Homekit compatible.

gkahn84 commented 8 months ago

I can‘t confirm the time schedule issue. Using HomeKit for automation, my schedule and events (someone coming home etc) work fine. Except of course when an event occurs at the same time my cron job is restarting the plugin but that rarely happens.

ogerardin commented 8 months ago

I can‘t confirm the time schedule issue. Using HomeKit for automation, my schedule and events (someone coming home etc) work fine. Except of course when an event occurs at the same time my cron job is restarting the plugin but that rarely happens.

In case that wasn't clear I was referring to the builtin schedule of the Meross thermostats.

bwp91 commented 6 months ago

Sorry for delays with me looking into this properly. I haven't made any code changes yet to do with this, but I would be interested in seeing some debug logs from anyone here who can update to the existing beta version of the plugin.

It would be interesting to see what the plugin is doing around at the times that the hub becomes unresponsive. I would imagine it is when the plugin requests a status update, as this (by default) happens every 5 minutes.

bwp91 commented 6 months ago

Since I don't own one of these hubs, it could be also useful if (pre-emptive thinking) anyone here who has experience with HTTP sniffing on an iPhone (with an app like HTTP catcher) could jump onto discord and DM me so we can double check that the plugin is mimicking what the meross app is doing!

ogerardin commented 6 months ago

Hi, don't be sorry we all have a lot to do :)

It would be interesting to see what the plugin is doing around at the times that the hub becomes unresponsive. I would imagine it is when the plugin requests a status update, as this (by default) happens every 5 minutes.

The thing is, I know that if I do that I will have to redo the schedules of all my 6 thermostats, which is not something I look forward to. Maybe someone else would be willing to do it, maybe someone with just one thermonstat...

gkahn84 commented 6 months ago

I‘m currently on vacation but can try to help out once I‘m back and sorted my everyday things out 😅 Will be in about one or two weeks.

On another note, I received a mail from Meross informing about deprecation and shutdown of parts of their API. Do you already know if this will impact your plugin @bwp91 ?