home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
72.27k stars 30.25k forks source link

Meross Matter smart wifi plug fails to pair when added to home assistant directly, but works when credentials are shared from google home #104368

Closed fuomag9 closed 10 months ago

fuomag9 commented 10 months ago

The problem

Meross Matter wifi smart plug fails to pair when added to home assistant directly

What works instead:

Note: I'm using a VLAN but both the plugs and HA are in the same VLAN, and I also have a mDNS reflector active. Pairing is done on the same vlan. Threads also works (I paired my other devices before the VLAN change in case it might be useful)

Devices works after this "strange" pairing, so I don't believe my network configuration is wrong (otherwise they won't work at all!)

Pairing with an iOS device fails completely (I don't have any hub and I don't know if that method of pairing is supported right now)

What version of Home Assistant Core has the issue?

core-2023.11.2

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

Matter

Link to integration documentation on our website

https://www.home-assistant.io/integrations/matter/

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

2023-11-22 15:45:57 core-matter-server PersistentStorage[126] INFO Committing...
2023-11-22 15:46:04 core-matter-server chip.DMG[126] ERROR Subscription Liveness timeout with SubscriptionID = 0x2957ef72, Peer = 01:0000000000000011
2023-11-22 15:46:04 core-matter-server matter_server.server.device_controller.[node 17][126] INFO Previous subscription failed with Error: 50, re-subscribing in 0 ms...
2023-11-22 15:46:22 core-matter-server chip.EM[126] ERROR Failed to Send CHIP MessageCounter:135634974 on exchange 65047i sendCount: 4 max retries: 4
2023-11-22 15:46:25 core-matter-server chip.DMG[126] ERROR Time out! failed to receive report data from Exchange: 65047i
2023-11-22 15:46:25 core-matter-server matter_server.server.device_controller.[node 3][126] INFO Previous subscription failed with Error: 50, re-subscribing in 166748 ms...
2023-11-22 15:46:35 core-matter-server chip.DIS[126] ERROR Timeout waiting for mDNS resolution.
2023-11-22 15:46:49 core-matter-server chip.DIS[126] ERROR OperationalSessionSetup[1:0000000000000011]: operational discovery failed: src/lib/address_resolve/AddressResolve_DefaultImpl.cpp:119: CHIP Error 0x00000032: Timeout
2023-11-22 15:46:49 core-matter-server chip.DMG[126] ERROR Failed to establish CASE for re-subscription with error 'src/lib/address_resolve/AddressResolve_DefaultImpl.cpp:119: CHIP Error 0x00000032: Timeout'
2023-11-22 15:46:49 core-matter-server matter_server.server.device_controller.[node 17][126] INFO Previous subscription failed with Error: 50, re-subscribing in 5192 ms...
2023-11-22 15:46:58 core-matter-server matter_server.server.helpers.paa_certificates[126] INFO Fetching the latest PAA root certificates from DCL.
2023-11-22 15:46:58 core-matter-server matter_server.server.helpers.paa_certificates[126] INFO Fetched 0 PAA root certificates from DCL.
2023-11-22 15:46:58 core-matter-server matter_server.server.helpers.paa_certificates[126] INFO Fetching the latest PAA root certificates from Git.
2023-11-22 15:46:58 core-matter-server matter_server.server.helpers.paa_certificates[126] INFO Fetched 0 PAA root certificates from Git.
2023-11-22 15:47:29 core-matter-server chip.CTL[126] ERROR Mdns discovery timed out
2023-11-22 15:47:29 core-matter-server matter_server.server.client_handler[126] ERROR [547590033936] Error handling message: CommandMessage(message_id='866fdcb7586b4c75afa82e94ad77af04', command='commission_on_network', args={'setup_pin_code': CENSOR})
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/matter_server/server/client_handler.py", line 188, in _run_handler
    result = await result
             ^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/matter_server/server/device_controller.py", line 221, in commission_on_network
    raise NodeCommissionFailed(
matter_server.common.errors.NodeCommissionFailed: Commission on network failed for node 18
2023-11-22 15:47:29 core-matter-server chip.DIS[126] ERROR Timeout waiting for mDNS resolution.

Additional information

No response

home-assistant[bot] commented 10 months ago

Hey there @home-assistant/matter, mind taking a look at this issue as it has been labeled with an integration (matter) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `matter` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Renames the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign matter` Removes the current integration label and assignees on the issue, add the integration domain after the command. - `@home-assistant add-label needs-more-information` Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue. - `@home-assistant remove-label needs-more-information` Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


matter documentation matter source (message by IssueLinks)

marcelveldt commented 10 months ago

mDNS reflectors are known to play havoc with the IPv6 MDNS traffic used for Matter. It causes strange issues, just like you experience. Even if HA and the device(wifi) are on the same vLAN. We've seen wireshark traces where the traffic just got replicated in enormous amounts, some packets even malformed. mDNS reflectors are bad for IPv4, let alone for IPv6.

If you have an IoT (v)LAN just make sure all devices are on that LAN, including HA. Then there is no need to start forwarding multicast traffic anymore. Just keep that in its layer 2 as intended as use firewall rules if you want to limit devices.

As for pairing the Meross device. I have several of them here and they work great but sometimes require multiple attempts when commissioning. Just make sure to first factory reset before you pair to a controller. You can't use the QR code to pair to multiple controllers. Once paired to one controller you NEED to share the device from that controller to another, which basically opens the commissioning window for that device again (so sharing is not the exact right word).

If you keep experiencing issues, have a look at your switches. Check with IGMP snooping on or off. Check other settings on your network or WiFi that could potentially harm multicast traffic, such as the filters in Unifi WiFi networks.

psychowood commented 10 months ago

Is it by chance one of these? I was having exactly the same issue. I'm not sure this is related but I was able to pair the plug (two of them, actually, more than once) after disabling the companion app security (pin/fingerprint). EDIT: Not related.

Sadly no power measurement over matter (yet).

Similar issue: https://github.com/home-assistant/core/issues/99857

fuomag9 commented 10 months ago

Is it by chance one of these? I was having exactly the same issue. I'm not sure this is related but I was able to pair the plug (two of them, actually, more than once) after disabling the companion app security (pin/fingerprint).

Sadly no power measurement over matter (yet).

Yes, they are indeed the mss315 model! According to this matter 1.3 has power monitoring but there's no implementation yet? https://github.com/project-chip/connectedhomeip/issues/30193

And of course we're still relying on the manufacturer to update the firmware, which is something I'm not really hopeful about T.T

fuomag9 commented 10 months ago

mDNS reflectors are known to play havoc with the IPv6 MDNS traffic used for Matter. It causes strange issues, just like you experience. Even if HA and the device(wifi) are on the same vLAN. We've seen wireshark traces where the traffic just got replicated in enormous amounts, some packets even malformed. mDNS reflectors are bad for IPv4, let alone for IPv6.

If you have an IoT (v)LAN just make sure all devices are on that LAN, including HA. Then there is no need to start forwarding multicast traffic anymore. Just keep that in its layer 2 as intended as use firewall rules if you want to limit devices.

As for pairing the Meross device. I have several of them here and they work great but sometimes require multiple attempts when commissioning. Just make sure to first factory reset before you pair to a controller. You can't use the QR code to pair to multiple controllers. Once paired to one controller you NEED to share the device from that controller to another, which basically opens the commissioning window for that device again (so sharing is not the exact right word).

If you keep experiencing issues, have a look at your switches. Check with IGMP snooping on or off. Check other settings on your network or WiFi that could potentially harm multicast traffic, such as the filters in Unifi WiFi networks.

I have tried with IGMP snooping on/off (was on), mDNS reflector on and off, unifi settings on and off, MLD snooping on and off, but it still does not work when using the home assistant app to pair, both on iPhone and android. If I use the google home app on android (on iOS this technique does NOT work) then I can pair the device and add it to HASS from this interface (and then remove it from google home, as I can still control it from home assistant). IMG_7472

Google home failing on iOS IMG_7471

Home assistant failing on iOS IMG_7466 IMG_7467 IMG_7468

psychowood commented 10 months ago

I believe it is mostly a timeout issue, perhaps this specific model is slower than others to reply. I also noticed some messages similar to "device found but commissioning window is not open anymore" which seems to confirm a similar behavior.

My network is plain, without VLANs, mdns messages go through without problems (checked with wireshark), but Matter Server struggle to register these plugs. It's not a consistent KO anyways: after a few resets eventually I managed to pair the devices (I also reinstalled the add-on, just in case).

fuomag9 commented 10 months ago

I believe it is mostly a timeout issue, perhaps this specific model is slower than others to reply. I also noticed some messages similar to "device found but commissioning window is not open anymore" which seems to confirm a similar behavior.

My network is plain, without VLANs, mdns messages go through without problems (checked with wireshark), but Matter Server struggle to register these plugs. It's not a consistent KO anyways: after a few resets eventually I managed to pair the devices (I also reinstalled the add-on, just in case).

When I try to pair by using the HA app, I see the device connecting to the wifi network, but then the device -> HA pairing fails as I've shown above. I'm writing this down to help devs confirm if this is the case

Ironically the google home "hack" works 100% of the time when adding the device to HA

fuomag9 commented 10 months ago

It seems to be happening to this person as well @psychowood

https://community.home-assistant.io/t/matter-adding-meross-plug-fails/633692

alverdal commented 10 months ago

I’ve expericed this issue as well with Meross MSS315. Tried to connect via Home assistant Hassio+Matter beta addon

fuomag9 commented 10 months ago

I’ve expericed this issue as well with Meross MSS315. Tried to connect via Home assistant Hassio+Matter beta addon

Do you have a plain network configuration? (No VLANs, etc)

alverdal commented 10 months ago

I run hassio on a mac as a virtual machine (bridged network).

marcelveldt commented 10 months ago

I'm starting to think these devices are just a bit flaky and Google works around it by just retrying and retrying and retrying numerous times until it succeeds. There's not much we can do here. I'm not a fan of this keep-retrying just because we can approach. We already do a pretty large timeout and a couple of retries which is enough for all devices I've seen so far.

I'd suggest to just commission them to Google, share to HA and then remove from Google again (or not) if that works for you.

I actually should receive the Meross MS315 later this week. I'll try to reproduce this scenario once I have it on my desk.

m4tthall73 commented 10 months ago

So I have bought 2 of these and today tried to add them. Bear in mind I am fairly new to Home Assistant and wish I hadn't purchased matter devices and had stuck with zigbee.

Anyway, added the first and it worked like a dream. Popped up on my Android phone, asked me if I wanted to add it and selected to use Home Assistant to do so. Viola, added and all good.

Tried adding the second and got to the point of adding it to Home Assistant step and it failed, Asked to retry, still didn't work. Tried numerous times, reset, moved location, nothing. So tried adding via Google and it worked and added to Google Home without an issue.

I noticed @fuomag9 above suggesting

"sharing the credentials with home assistant" "The device works with home assistant"

I am a bit confused what this means. How does that work exactly? As I will try that next.

(edit: I just saw how to do that in the Google Home app and it worked, so now have them both in Home Assistant)

Anyway, now I am playing around with the plugs but cannot see anything to do with energy monitoring in either Google Home nor Home Assistant. These are MSS315 and double checked they should provide that, am I being stupid?

Thanks

fuomag9 commented 10 months ago

So I have bought 2 of these and today tried to add them. Bear in mind I am fairly new to Home Assistant and wish I hadn't purchased matter devices and had stuck with zigbee.

Anyway, added the first and it worked like a dream. Popped up on my Android phone, asked me if I wanted to add it and selected to use Home Assistant to do so. Viola, added and all good.

Tried adding the second and got to the point of adding it to Home Assistant step and it failed, Asked to retry, still didn't work. Tried numerous times, reset, moved location, nothing. So tried adding via Google and it worked and added to Google Home without an issue.

I noticed @fuomag9 above suggesting

"sharing the credentials with home assistant"

"The device works with home assistant"

I am a bit confused what this means. How does that work exactly? As I will try that next.

Anyway, now I am playing around with the plugs but cannot see anything to do with energy monitoring in either Google Home nor Home Assistant. These are MSS315 and double checked they should provide that, am I being stupid?

Thanks

Energy monitoring is cloud only for now, there's a project for using them with local MQTT but I've not tried it yet due to lack of time. Matter 1.3 should solve this, but it's still in the works and the devices need to get a firmare update when it comes out

image

This interface is what I mean for "credentials sharing"

m4tthall73 commented 10 months ago

Thanks for the quick reply @fuomag9, I managed to get the second one working that way.

That's a real arse with the energy monitoring, I should have checked before buying given it was one of the main reasons for going with that model. Lesson learned!

I guess they are going to be pretty dumb smart plugs for the foreseeable future then. Annoying, as I bought these to replace two kasa hs100 plugs I had, which were great but don't work in home assistant due to tplink breaking them :-(

Suppose I will waste some more money on a few more plugs and pick ones more carefully...

Thanks again

fuomag9 commented 10 months ago

Thanks for the quick reply @fuomag9, I managed to get the second one working that way.

That's a real arse with the energy monitoring, I should have checked before buying given it was one of the main reasons for going with that model. Lesson learned!

I guess they are going to be pretty dumb smart plugs for the foreseeable future then. Annoying, as I bought these to replace two kasa hs100 plugs I had, which were great but don't work in home assistant due to tplink breaking them :-(

Suppose I will waste some more money on a few more plugs and pick ones more carefully...

Thanks again

If you have HACS you can use the cloud Meross via this https://github.com/albertogeniola/meross-homeassistant

It has also a link to the lan only version, which I've not tried yet

m4tthall73 commented 10 months ago

Thanks for the quick reply @fuomag9, I managed to get the second one working that way. That's a real arse with the energy monitoring, I should have checked before buying given it was one of the main reasons for going with that model. Lesson learned! I guess they are going to be pretty dumb smart plugs for the foreseeable future then. Annoying, as I bought these to replace two kasa hs100 plugs I had, which were great but don't work in home assistant due to tplink breaking them :-( Suppose I will waste some more money on a few more plugs and pick ones more carefully... Thanks again

If you have HACS you can use the cloud Meross via this https://github.com/albertogeniola/meross-homeassistant

It has also a link to the lan only version, which I've not tried yet

I have taken the HACS integration route, and while I would rather keep it local this is working fine.

Thanks once more

alverdal commented 10 months ago

I was also able to connect my Meross MSS315 via the HACS route but it would be nice to use the matter integration instead.