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
73.68k stars 30.82k forks source link

Switchbot Curtain can not controlled via Matter #95298

Closed smartmatic closed 1 year ago

smartmatic commented 1 year ago

The problem

I‘ve added the Switchbot Hub 2 to HA and the curtains linked to the Hub 2 are integrated as Matter devices in HA.

Unfortunately i can not open or close the curtains. They do not react.

What version of Home Assistant Core has the issue?

2023.6.3

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

config_entry-matter-0405ed183ecb093f4a6d7ec50105a320.json.txt

Example YAML snippet

No response

Anything in the logs that might be useful for us?

Logger: homeassistant.components.matter
Source: components/matter/__init__.py:128 
Integration: Matter (BETA) (documentation, issues) 
First occurred: 21:18:09 (1 occurrences) 
Last logged: 21:18:09

Unexpected exception: 4
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/matter/__init__.py", line 128, in _client_listen
    await matter_client.start_listening(init_ready)
  File "/usr/local/lib/python3.11/site-packages/matter_server/client/client.py", line 331, in start_listening
    self._handle_incoming_message(msg)
  File "/usr/local/lib/python3.11/site-packages/matter_server/client/client.py", line 370, in _handle_incoming_message
    self._handle_event_message(msg)
  File "/usr/local/lib/python3.11/site-packages/matter_server/client/client.py", line 403, in _handle_event_message
    self._nodes[node_id].update_attribute(attribute_path, new_value)
  File "/usr/local/lib/python3.11/site-packages/matter_server/client/models/node.py", line 342, in update_attribute
    self.endpoints[endpoint_id].set_attribute_value(attribute_path, new_value)
    ~~~~~~~~~~~~~~^^^^^^^^^^^^^
KeyError: 4

Additional information

No response

home-assistant[bot] commented 1 year 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.

(message by CodeOwnersMention)


matter documentation matter source (message by IssueLinks)

marcelveldt commented 1 year ago

This is strange, the switchbot hub and curtain control should work fine. I spot a weird issue in your log that should not happen, something is malformed.

Can you please try to restart the matter server and/or home assistant ?

smartmatic commented 1 year ago

This is strange, the switchbot hub and curtain control should work fine. I spot a weird issue in your log that should not happen, something is malformed.

Can you please try to restart the matter server and/or home assistant ?

I tried i have now an error in the Matter Logs:

ValueError: Unknown level: 'NULL'
[16:26:54] INFO: Starting Matter Server...
parse error: Expected string key before ':' at line 1, column 4
[16:26:55] ERROR: Unknown HTTP error occured
parse error: Expected string key before ':' at line 1, column 4
[16:26:55] ERROR: Unknown HTTP error occured
parse error: Expected string key before ':' at line 1, column 4
[16:26:55] ERROR: Unknown HTTP error occured
[16:26:56] INFO: Successfully send discovery information to Home Assistant.
Traceback (most recent call last):
  File "/usr/local/bin/matter-server", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/usr/local/lib/python3.11/site-packages/matter_server/server/__main__.py", line 71, in main
    logging.basicConfig(handlers=handlers, level=args.log_level.upper())
  File "/usr/local/lib/python3.11/logging/__init__.py", line 2069, in basicConfig
    root.setLevel(level)
  File "/usr/local/lib/python3.11/logging/__init__.py", line 1464, in setLevel
    self.level = _checkLevel(level)
                 ^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/logging/__init__.py", line 207, in _checkLevel
    raise ValueError("Unknown level: %r" % level)
ValueError: Unknown level: 'NULL'
[16:27:01] INFO: Starting Matter Server...
parse error: Expected string key before ':' at line 1, column 4
[16:27:02] ERROR: Unknown HTTP error occured
parse error: Expected string key before ':' at line 1, column 4
[16:27:02] ERROR: Unknown HTTP error occured
parse error: Expected string key before ':' at line 1, column 4
[16:27:02] ERROR: Unknown HTTP error occured
[16:27:02] INFO: Successfully send discovery information to Home Assistant.

Integration is now in Re-Setup loop

marcelveldt commented 1 year ago

Can you check the add-on settings, especially the log level settings ? Maybe even try to reset it or re-apply.

smartmatic commented 1 year ago

Ok, i have reset it to defaults and restart of the add-on was possible but still with erros

s6-rc: info: service s6rc-oneshot-runner: starting
s6-rc: info: service s6rc-oneshot-runner successfully started
s6-rc: info: service fix-attrs: starting
s6-rc: info: service banner: starting
s6-rc: info: service fix-attrs successfully started
s6-rc: info: service legacy-cont-init: starting
s6-rc: info: service legacy-cont-init successfully started
-----------------------------------------------------------
 Add-on: Matter Server
 Matter WebSocket Server for Home Assistant Matter support.
-----------------------------------------------------------
 Add-on version: 4.6.1
 You are running the latest version of this add-on.
 System: Home Assistant OS 10.3  (aarch64 / yellow)
 Home Assistant Core: 2023.6.3
 Home Assistant Supervisor: 2023.06.2
-----------------------------------------------------------
 Please, share the above information when looking for help
 or support in, e.g., GitHub, forums or the Discord chat.
-----------------------------------------------------------
s6-rc: info: service banner successfully started
s6-rc: info: service matter-server: starting
s6-rc: info: service matter-server successfully started
s6-rc: info: service legacy-services: starting
[17:44:36] INFO: Starting Matter Server...
s6-rc: info: service legacy-services successfully started
[17:44:38] INFO: Successfully send discovery information to Home Assistant.
[1687880682.294787][126:126] CHIP:CTL: Setting attestation nonce to random value
[1687880682.295639][126:126] CHIP:CTL: Setting CSR nonce to random value
[1687880682.298239][126:126] CHIP:DL: ChipLinuxStorage::Init: Using KVS config file: /tmp/chip_kvs
[1687880682.299829][126:126] CHIP:DL: writing settings to file (/tmp/chip_kvs-7ic2cK)
[1687880682.300499][126:126] CHIP:DL: renamed tmp file to file (/tmp/chip_kvs)
[1687880682.301246][126:126] CHIP:DL: ChipLinuxStorage::Init: Using KVS config file: /data/chip_factory.ini
[1687880682.302027][126:126] CHIP:DL: ChipLinuxStorage::Init: Using KVS config file: /data/chip_config.ini
[1687880682.303048][126:126] CHIP:DL: ChipLinuxStorage::Init: Using KVS config file: /data/chip_counters.ini
[1687880682.303955][126:126] CHIP:DL: writing settings to file (/data/chip_counters.ini-kPcfII)
[1687880682.304965][126:126] CHIP:DL: renamed tmp file to file (/data/chip_counters.ini)
[1687880682.305225][126:126] CHIP:DL: NVS set: chip-counters/reboot-count = 34 (0x22)
[1687880682.306549][126:126] CHIP:DL: Got Ethernet interface: eth0
[1687880682.307859][126:126] CHIP:DL: Found the primary Ethernet interface:eth0
[1687880682.311206][126:126] CHIP:DL: Failed to get WiFi interface
[1687880682.311442][126:126] CHIP:DL: Failed to reset WiFi statistic counts
2023-06-27 17:44:42 core-matter-server chip.DL[126] ERROR MDNS failed to join multicast group on veth9720374 for address type IPv4: src/inet/UDPEndPointImplSockets.cpp:764: Inet Error 0x00000110: Address not found
2023-06-27 17:44:42 core-matter-server chip.DL[126] ERROR MDNS failed to join multicast group on vethf65713d for address type IPv4: src/inet/UDPEndPointImplSockets.cpp:764: Inet Error 0x00000110: Address not found
2023-06-27 17:44:42 core-matter-server chip.DL[126] ERROR MDNS failed to join multicast group on vethc8b9bf2 for address type IPv4: src/inet/UDPEndPointImplSockets.cpp:764: Inet Error 0x00000110: Address not found
2023-06-27 17:44:42 core-matter-server chip.DL[126] ERROR MDNS failed to join multicast group on veth0cc4cc7 for address type IPv4: src/inet/UDPEndPointImplSockets.cpp:764: Inet Error 0x00000110: Address not found
2023-06-27 17:44:42 core-matter-server chip.DL[126] ERROR MDNS failed to join multicast group on vethd0cbac7 for address type IPv4: src/inet/UDPEndPointImplSockets.cpp:764: Inet Error 0x00000110: Address not found
2023-06-27 17:44:42 core-matter-server chip.DL[126] ERROR MDNS failed to join multicast group on vethe680fde for address type IPv4: src/inet/UDPEndPointImplSockets.cpp:764: Inet Error 0x00000110: Address not found
2023-06-27 17:44:42 core-matter-server chip.DL[126] ERROR MDNS failed to join multicast group on veth6e1e223 for address type IPv4: src/inet/UDPEndPointImplSockets.cpp:764: Inet Error 0x00000110: Address not found
2023-06-27 17:44:42 core-matter-server chip.DL[126] ERROR MDNS failed to join multicast group on veth18ea4c1 for address type IPv4: src/inet/UDPEndPointImplSockets.cpp:764: Inet Error 0x00000110: Address not found
2023-06-27 17:44:42 core-matter-server chip.DL[126] ERROR MDNS failed to join multicast group on veth2cbe482 for address type IPv4: src/inet/UDPEndPointImplSockets.cpp:764: Inet Error 0x00000110: Address not found
2023-06-27 17:44:42 core-matter-server chip.DL[126] ERROR MDNS failed to join multicast group on wpan0 for address type IPv4: src/inet/UDPEndPointImplSockets.cpp:764: Inet Error 0x00000110: Address not found
2023-06-27 17:44:42 core-matter-server chip.DL[126] ERROR MDNS failed to join multicast group on veth4cf0ac3 for address type IPv4: src/inet/UDPEndPointImplSockets.cpp:764: Inet Error 0x00000110: Address not found
2023-06-27 17:44:42 core-matter-server chip.DL[126] ERROR MDNS failed to join multicast group on vethf705318 for address type IPv4: src/inet/UDPEndPointImplSockets.cpp:764: Inet Error 0x00000110: Address not found
2023-06-27 17:44:42 core-matter-server chip.DL[126] ERROR MDNS failed to join multicast group on veth016c6f3 for address type IPv4: src/inet/UDPEndPointImplSockets.cpp:764: Inet Error 0x00000110: Address not found
2023-06-27 17:44:42 core-matter-server chip.DL[126] ERROR MDNS failed to join multicast group on veth139bdbe for address type IPv4: src/inet/UDPEndPointImplSockets.cpp:764: Inet Error 0x00000110: Address not found
/usr/local/lib/python3.11/site-packages/matter_server/server/helpers/paa_certificates.py:46: CryptographyDeprecationWarning: The parsed certificate contains a NULL parameter value in its signature algorithm parameters. This is invalid and will be rejected in a future version of cryptography. If this certificate was created via Java, please upgrade to JDK16+ or the latest JDK11 once a fix is issued. If this certificate was created in some other fashion please report the issue to the cryptography issue tracker. See https://github.com/pyca/cryptography/issues/8996 for more details.
  pem_certificate = x509.load_pem_x509_certificate(certificate.encode())
/usr/local/lib/python3.11/asyncio/events.py:73: RuntimeWarning: coroutine 'StorageController.async_save' was never awaited
  self._args = None
RuntimeWarning: Enable tracemalloc to get the object allocation traceback

mDNS is enabled on my Unify Dream Router

marcelveldt commented 1 year ago

Disable the mDNS responder on your Unifi setup, that is known to cause issues. The other errors and warnings are safe to ignore and will be fixed in future versions.

The server looks to be started correctly this time btw (except for the bunch of warnings), can you control the switchbot now ?

smartmatic commented 1 year ago

I was able to open each curtain exactly one time but then could not close them.

I am wondering if i need mDNS at all. I have no VLAN's configured.

marcelveldt commented 1 year ago

You need mDNS to traverse your network properly as Matter is based around mDNS. Within Unifi make sure to disable the mDNS forwarder (or whatever that option is called) as it corrupts Matter mDNS packets. Especially if you do not even have any VLAN's disable it.

Also I've seen cases where it helps to disable "multicast enhancements" for Unifi WiFi as that also conflicts. In my own personal setup I've just created a secondary 2,4Ghz only WiFi SSID for IoT devices (like Matter) with multicast enhancements disabled and that works perfectly well.

smartmatic commented 1 year ago

Now i can control the Switchbot Curtains. I forgot that the communication between the Hub 2 and the Curtains is still Bluetooth. So i placed the Hub closer to the curtains and then it worked.

What i am not able to solve is the mDNS error. I did not found something like mDNS forwarder but Multicast Enhancement is disabled.

marcelveldt commented 1 year ago

Yeah, that is indeed something to remember, although the bridge uses matter, the communication with its devices is still bluetooth (in case of switchbot) or zigbee (hue, ikea and aqara).

Don't worry too much about the mdns error if your devices do work fine. Do you have an addon called "aircast" installed ? That messes with mdns packets too.

smartmatic commented 1 year ago

"Aircast" is not installed on my system

marcelveldt commented 1 year ago

OK, well, maybe at some day you find out what device/service is causing these packets but for now just ignore it if everything works fine. The logging is a bit verbose for some parts

marcelveldt commented 1 year ago

I just reproduced those mdns errors on an Intel NUC running HAOS, seems that these are (virtual?) network interfaces and the sdk tries to join the multicast group and fails, hence the error.