I'm on 0.2.8
..........
@FezVrasta on a different .... matter...
Adding an Aggregator and hitting "deploy" without adding a matter server crashes the whole nodered instance and leaves it in a "boot loop":
1 Sep 10:20:45 - [info] [matter-aggregator:test] Adding device 321c310fd56b723f to aggregator
1 Sep 10:20:45 - [info] [matter-aggregator:test] All related nodes added (1/1)
1 Sep 10:20:45 - [info] [matter-aggregator:test] Starting matter aggregator
1 Sep 10:20:45 - [info] [matter-aggregator:test] Registering device to Matter server
1 Sep 10:20:45 - [warn] [matter-aggregator:test] Matter server not found
1 Sep 10:20:45 - [red] Uncaught Exception:
1 Sep 10:20:45 - [error] TypeError: Cannot read properties of null (reading 'serverPromise')
at /home/optic/.node-red/node_modules/@node-red-matter/node-red-matter/lib/src/nodes/matter-device-node.js:65:41
at processTicksAndRejections (node:internal/process/task_queues:96:5)
nodered.service: Main process exited, code=exited, status=1/FAILURE
nodered.service: Failed with result 'exit-code'.
it was reproducable for me.
@FezVrasta a heads up (PS, I know this is very early code so I am not criticizing, just pointing out something you may not be aware of)
Looks like you are mixing promise and async code but without any .catch()
(on the promise) nor any try/catch blocks around the async code. Your nodes should be defensive when it comes to async code to avoid crashing node-red. Node-RED can/will catch errors in synchronous code but as with all node based applications, unhandled exceptions in async code is a sure fire way to end the party.
I deployed a new version with some bug fixes, I made the matter server initialization synchronous to reduce chances of race conditions and simplify the logic.
@Steve-Mcl that specific error is actually related to an access of a missing node, it's not related to async logic, I should have fixed it anyway.
v0.2.10 should be much more stable if anyone wants to try it.
I understand, I just wanted to make you aware of the best way to crash node-red (no try/catch around async, no .catch() on a promise. Not meaning to rock the boat or judge your work at all. We all greatly appreciate your efforts here.
i managed to add an aggregator and one device to homeassistant. This worked very well for a short time.
but as soon as i add another single device to the matter server or add a device to the aggretator, HA will lose the connection to the device/aggregator and NR throws these errors:
2023-09-01 12:30:52.910 ERROR ExchangeManager Cannot find a session for ID 38674
at ExchangeManager.<anonymous> (/home/optic/.node-red/node_modules/@project-chip/matter.js/dist/cjs/protocol/ExchangeManager.js:94:23)
at Generator.next (<anonymous>)
at /home/optic/.node-red/node_modules/@project-chip/matter.js/dist/cjs/protocol/ExchangeManager.js:13:71
at new Promise (<anonymous>)
at __awaiter (/home/optic/.node-red/node_modules/@project-chip/matter.js/dist/cjs/protocol/ExchangeManager.js:9:12)
at ExchangeManager.onMessage (/home/optic/.node-red/node_modules/@project-chip/matter.js/dist/cjs/protocol/ExchangeManager.js:88:16)
at /home/optic/.node-red/node_modules/@project-chip/matter.js/dist/cjs/protocol/ExchangeManager.js:58:18
at /home/optic/.node-red/node_modules/@project-chip/matter.js/dist/cjs/net/UdpInterface.js:38:80
at Socket.messageListener (/home/optic/.node-red/node_modules/@project-chip/matter-node.js/dist/net/UdpChannelNode.js:96:13)
at Socket.emit (node:events:513:28)
at Socket.emit (node:domain:489:12)
at UDP.onMessage [as onmessage] (node:dgram:930:8)
at UDP.callbackTrampoline (node:internal/async_hooks:130:17)
2023-09-01 12:30:58.896 ERROR ExchangeManager Cannot find a session for ID 38674
at ExchangeManager.<anonymous> (/home/optic/.node-red/node_modules/@project-chip/matter.js/dist/cjs/protocol/ExchangeManager.js:94:23)
at Generator.next (<anonymous>)
at /home/optic/.node-red/node_modules/@project-chip/matter.js/dist/cjs/protocol/ExchangeManager.js:13:71
at new Promise (<anonymous>)
at __awaiter (/home/optic/.node-red/node_modules/@project-chip/matter.js/dist/cjs/protocol/ExchangeManager.js:9:12)
at ExchangeManager.onMessage (/home/optic/.node-red/node_modules/@project-chip/matter.js/dist/cjs/protocol/ExchangeManager.js:88:16)
at /home/optic/.node-red/node_modules/@project-chip/matter.js/dist/cjs/protocol/ExchangeManager.js:58:18
at /home/optic/.node-red/node_modules/@project-chip/matter.js/dist/cjs/net/UdpInterface.js:38:80
at Socket.messageListener (/home/optic/.node-red/node_modules/@project-chip/matter-node.js/dist/net/UdpChannelNode.js:96:13)
at Socket.emit (node:events:513:28)
at Socket.emit (node:domain:489:12)
at UDP.onMessage [as onmessage] (node:dgram:930:8)
at UDP.callbackTrampoline (node:internal/async_hooks:130:17)
still no luck with alexa.
Of course! Thanks for the help.
I published a new version with better form validation on the matter-device-node, before that you could have the node misconfigured and not reported as such. Everything should be clearer now.
The matter.js maintainer noticed the Home Assistant Matter controller is behaving in an unusual way, I suppose the issue may be on their side.
If you could enable the debug logging (NODE_RED_MATTER_LOG_LEVEL=0
), reproduce the problem and share them here, I could forward them to the maintainer to see if they notice anything off. It would also be useful to see the logs from the HA Matter controller side.
It looks like right now the best Matter controller implementation is the one provided by Apple, probably because Matter was heavily based on the existing HomeKit architecture.
i started the NR log right before adding the second device to the server. before adding the second device, the first device was working well.
Couldn´t find a Matter Server Log, all i got is the HA Core Log
NR LOG:
HA CORE LOG when i try to send commands to the first device
2023-09-01 13:25:04.304 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [140515949642304] src/app/CommandSender.cpp:248: CHIP Error 0x00000032: Timeout
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 226, in handle_call_service
await hass.services.async_call(
File "/usr/src/homeassistant/homeassistant/core.py", line 1974, in async_call
response_data = await coro
^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/core.py", line 2011, in _execute_service
return await target(service_call)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 235, in handle_service
return await service.entity_service_call(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 870, in entity_service_call
response_data = await _handle_entity_call(
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 942, in _handle_entity_call
result = await task
^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/light/__init__.py", line 591, in async_handle_light_off_service
await light.async_turn_off(**filter_turn_off_params(light, params))
File "/usr/src/homeassistant/homeassistant/components/matter/light.py", line 284, in async_turn_off
await self.send_device_command(
File "/usr/src/homeassistant/homeassistant/components/matter/light.py", line 249, in send_device_command
await self.matter_client.send_device_command(
File "/usr/local/lib/python3.11/site-packages/matter_server/client/client.py", line 225, in send_device_command
return await self.send_command(
^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/matter_server/client/client.py", line 315, in send_command
return await future
^^^^^^^^^^^^
matter_server.common.errors.SDKStackError: src/app/CommandSender.cpp:248: CHIP Error 0x00000032: Timeout
I can't open the pastebin link, it seems invalid.
Maybe gist.github.com?
added the log to my first try above.
yes!
Could you take the logs from the matter addon? There you find the ones specific to Matter.
I know it's not particularly useful but I was able to pair the bridge to my newly installed Hassio server and it seems to be working fine for now. I'll keep it running to see how it goes.
The setup is a RPi4 running Hass.io, the Node-RED Addon, the Matter Addon. The Node-RED Matter bridge is paired to Apple Home, and then from Apple Home I paired it to Home Assistant too.
ahhh great, it´s an addon.
sorry i don´t know my way around that good, normally i´m just a "user":
File "/usr/local/lib/python3.11/enum.py", line 711, in __call__
return cls.__new__(cls, value)
^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/enum.py", line 1128, in __new__
raise ve_exc
ValueError: 0 is not a valid EventPriority
2023-09-01 13:21:31 core-matter-server matter_server.server.device_controller.[node 11][127] INFO Subscription succeeded
Exception ignored on calling ctypes callback function: <function _OnReadEventDataCallback at 0x7fd23d247560>
Traceback (most recent call last):
File "/usr/local/lib/python3.11/site-packages/chip/clusters/Attribute.py", line 871, in _OnReadEventDataCallback
EndpointId=endpoint, ClusterId=cluster, EventId=event, EventNumber=number, Priority=EventPriority(priority), Timestamp=timestamp, TimestampType=EventTimestampType(timestampType)), path, dataBytes[:], status)
^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/enum.py", line 711, in __call__
return cls.__new__(cls, value)
^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/enum.py", line 1128, in __new__
raise ve_exc
ValueError: 0 is not a valid EventPriority
Exception ignored on calling ctypes callback function: <function _OnReadEventDataCallback at 0x7fd23d247560>
Traceback (most recent call last):
File "/usr/local/lib/python3.11/site-packages/chip/clusters/Attribute.py", line 871, in _OnReadEventDataCallback
EndpointId=endpoint, ClusterId=cluster, EventId=event, EventNumber=number, Priority=EventPriority(priority), Timestamp=timestamp, TimestampType=EventTimestampType(timestampType)), path, dataBytes[:], status)
^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/enum.py", line 711, in __call__
return cls.__new__(cls, value)
^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/enum.py", line 1128, in __new__
raise ve_exc
ValueError: 0 is not a valid EventPriority
2023-09-01 13:21:36 core-matter-server matter_server.server.device_controller.[node 11][127] INFO Subscription succeeded
Exception ignored on calling ctypes callback function: <function _OnReadEventDataCallback at 0x7fd23d247560>
Traceback (most recent call last):
File "/usr/local/lib/python3.11/site-packages/chip/clusters/Attribute.py", line 871, in _OnReadEventDataCallback
EndpointId=endpoint, ClusterId=cluster, EventId=event, EventNumber=number, Priority=EventPriority(priority), Timestamp=timestamp, TimestampType=EventTimestampType(timestampType)), path, dataBytes[:], status)
^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/enum.py", line 711, in __call__
return cls.__new__(cls, value)
^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/enum.py", line 1128, in __new__
raise ve_exc
ValueError: 0 is not a valid EventPriority
Exception ignored on calling ctypes callback function: <function _OnReadEventDataCallback at 0x7fd23d247560>
Traceback (most recent call last):
File "/usr/local/lib/python3.11/site-packages/chip/clusters/Attribute.py", line 871, in _OnReadEventDataCallback
EndpointId=endpoint, ClusterId=cluster, EventId=event, EventNumber=number, Priority=EventPriority(priority), Timestamp=timestamp, TimestampType=EventTimestampType(timestampType)), path, dataBytes[:], status)
^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/enum.py", line 711, in __call__
return cls.__new__(cls, value)
^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/enum.py", line 1128, in __new__
raise ve_exc
ValueError: 0 is not a valid EventPriority
2023-09-01 13:22:02 core-matter-server chip.EM[127] ERROR Failed to Send CHIP MessageCounter:13670209 on exchange 50884r sendCount: 4 max retries: 4
2023-09-01 13:22:05 core-matter-server chip.EM[127] ERROR Failed to Send CHIP MessageCounter:13670210 on exchange 40665i sendCount: 4 max retries: 4
2023-09-01 13:22:16 core-matter-server chip.EM[127] ERROR Failed to Send CHIP MessageCounter:13670213 on exchange 40666i sendCount: 4 max retries: 4
2023-09-01 13:22:25 core-matter-server chip.EM[127] ERROR Failed to Send CHIP MessageCounter:13670215 on exchange 40667i sendCount: 4 max retries: 4
2023-09-01 13:25:01 core-matter-server chip.EM[127] ERROR Failed to Send CHIP MessageCounter:13670222 on exchange 40668i sendCount: 4 max retries: 4
2023-09-01 13:28:16 core-matter-server chip.DMG[127] ERROR Subscription Liveness timeout with SubscriptionID = 0xb4c6ef8e, Peer = 01:000000000000000B
2023-09-01 13:28:16 core-matter-server matter_server.server.device_controller.[node 11][127] INFO Previous subscription failed with Error: 50, re-subscribing in 0 ms...
2023-09-01 13:28:47 core-matter-server chip.DIS[127] ERROR Timeout waiting for mDNS resolution.
2023-09-01 13:29:01 core-matter-server chip.DIS[127] ERROR OperationalSessionSetup[1:000000000000000B]: operational discovery failed: src/lib/address_resolve/AddressResolve_DefaultImpl.cpp:114: CHIP Error 0x00000032: Timeout
2023-09-01 13:29:01 core-matter-server chip.DMG[127] ERROR Failed to establish CASE for re-subscription with error 'src/lib/address_resolve/AddressResolve_DefaultImpl.cpp:114: CHIP Error 0x00000032: Timeout'
2023-09-01 13:29:01 core-matter-server matter_server.server.device_controller.[node 11][127] INFO Previous subscription failed with Error: 50, re-subscribing in 8163 ms...
2023-09-01 13:29:41 core-matter-server chip.DIS[127] ERROR Timeout waiting for mDNS resolution.
2023-09-01 13:29:55 core-matter-server chip.DIS[127] ERROR OperationalSessionSetup[1:000000000000000B]: operational discovery failed: src/lib/address_resolve/AddressResolve_DefaultImpl.cpp:114: CHIP Error 0x00000032: Timeout
2023-09-01 13:29:55 core-matter-server chip.DMG[127] ERROR Failed to establish CASE for re-subscription with error 'src/lib/address_resolve/AddressResolve_DefaultImpl.cpp:114: CHIP Error 0x00000032: Timeout'
2023-09-01 13:29:55 core-matter-server matter_server.server.device_controller.[node 11][127] INFO Previous subscription failed with Error: 50, re-subscribing in 4537 ms...
2023-09-01 13:30:30 core-matter-server chip.DIS[127] ERROR Timeout waiting for mDNS resolution.
2023-09-01 13:30:44 core-matter-server chip.DIS[127] ERROR OperationalSessionSetup[1:000000000000000B]: operational discovery failed: src/lib/address_resolve/AddressResolve_DefaultImpl.cpp:114: CHIP Error 0x00000032: Timeout
2023-09-01 13:30:44 core-matter-server chip.DMG[127] ERROR Failed to establish CASE for re-subscription with error 'src/lib/address_resolve/AddressResolve_DefaultImpl.cpp:114: CHIP Error 0x00000032: Timeout'
2023-09-01 13:30:44 core-matter-server matter_server.server.device_controller.[node 11][127] INFO Previous subscription failed with Error: 50, re-subscribing in 9675 ms...
2023-09-01 13:31:31 core-matter-server chip.DIS[127] ERROR Timeout waiting for mDNS resolution.
2023-09-01 13:31:45 core-matter-server chip.DIS[127] ERROR OperationalSessionSetup[1:000000000000000B]: operational discovery failed: src/lib/address_resolve/AddressResolve_DefaultImpl.cpp:114: CHIP Error 0x00000032: Timeout
2023-09-01 13:31:45 core-matter-server chip.DMG[127] ERROR Failed to establish CASE for re-subscription with error 'src/lib/address_resolve/AddressResolve_DefaultImpl.cpp:114: CHIP Error 0x00000032: Timeout'
2023-09-01 13:31:45 core-matter-server matter_server.server.device_controller.[node 11][127] INFO Previous subscription failed with Error: 50, re-subscribing in 28002 ms...
2023-09-01 13:32:31 core-matter-server chip.DIS[127] ERROR Timeout waiting for mDNS resolution.
2023-09-01 13:32:45 core-matter-server chip.DIS[127] ERROR OperationalSessionSetup[1:000000000000000B]: operational discovery failed: src/lib/address_resolve/AddressResolve_DefaultImpl.cpp:114: CHIP Error 0x00000032: Timeout
2023-09-01 13:32:45 core-matter-server chip.DMG[127] ERROR Failed to establish CASE for re-subscription with error 'src/lib/address_resolve/AddressResolve_DefaultImpl.cpp:114: CHIP Error 0x00000032: Timeout'
2023-09-01 13:32:45 core-matter-server matter_server.server.device_controller.[node 11][127] INFO Previous subscription failed with Error: 50, re-subscribing in 26066 ms...
2023-09-01 13:33:47 core-matter-server chip.DIS[127] ERROR Timeout waiting for mDNS resolution.
2023-09-01 13:34:01 core-matter-server chip.DIS[127] ERROR OperationalSessionSetup[1:000000000000000B]: operational discovery failed: src/lib/address_resolve/AddressResolve_DefaultImpl.cpp:114: CHIP Error 0x00000032: Timeout
2023-09-01 13:34:01 core-matter-server chip.DMG[127] ERROR Failed to establish CASE for re-subscription with error 'src/lib/address_resolve/AddressResolve_DefaultImpl.cpp:114: CHIP Error 0x00000032: Timeout'
2023-09-01 13:34:01 core-matter-server matter_server.server.device_controller.[node 11][127] INFO Previous subscription failed with Error: 50, re-subscribing in 67477 ms...
2023-09-01 13:35:19 core-matter-server chip.DIS[127] ERROR Timeout waiting for mDNS resolution.
2023-09-01 13:35:33 core-matter-server chip.DIS[127] ERROR OperationalSessionSetup[1:000000000000000B]: operational discovery failed: src/lib/address_resolve/AddressResolve_DefaultImpl.cpp:114: CHIP Error 0x00000032: Timeout
2023-09-01 13:35:33 core-matter-server chip.DMG[127] ERROR Failed to establish CASE for re-subscription with error 'src/lib/address_resolve/AddressResolve_DefaultImpl.cpp:114: CHIP Error 0x00000032: Timeout'
2023-09-01 13:35:33 core-matter-server matter_server.server.device_controller.[node 11][127] INFO Previous subscription failed with Error: 50, re-subscribing in 122743 ms...
2023-09-01 13:37:41 core-matter-server chip.DIS[127] ERROR Timeout waiting for mDNS resolution.
2023-09-01 13:37:55 core-matter-server chip.DIS[127] ERROR OperationalSessionSetup[1:000000000000000B]: operational discovery failed: src/lib/address_resolve/AddressResolve_DefaultImpl.cpp:114: CHIP Error 0x00000032: Timeout
2023-09-01 13:37:55 core-matter-server chip.DMG[127] ERROR Failed to establish CASE for re-subscription with error 'src/lib/address_resolve/AddressResolve_DefaultImpl.cpp:114: CHIP Error 0x00000032: Timeout'
2023-09-01 13:37:55 core-matter-server matter_server.server.device_controller.[node 11][127] INFO Previous subscription failed with Error: 50, re-subscribing in 122794 ms...
2023-09-01 13:41:51 core-matter-server chip.DIS[127] ERROR Timeout waiting for mDNS resolution.
2023-09-01 13:42:05 core-matter-server chip.DIS[127] ERROR OperationalSessionSetup[1:000000000000000B]: operational discovery failed: src/lib/address_resolve/AddressResolve_DefaultImpl.cpp:114: CHIP Error 0x00000032: Timeout
2023-09-01 13:42:05 core-matter-server chip.DMG[127] ERROR Failed to establish CASE for re-subscription with error 'src/lib/address_resolve/AddressResolve_DefaultImpl.cpp:114: CHIP Error 0x00000032: Timeout'
2023-09-01 13:42:05 core-matter-server matter_server.server.device_controller.[node 11][127] INFO Previous subscription failed with Error: 50, re-subscribing in 246558 ms...
2023-09-01 13:45:43 core-matter-server chip.DIS[127] ERROR Timeout waiting for mDNS resolution.
2023-09-01 13:45:57 core-matter-server chip.DIS[127] ERROR OperationalSessionSetup[1:000000000000000B]: operational discovery failed: src/lib/address_resolve/AddressResolve_DefaultImpl.cpp:114: CHIP Error 0x00000032: Timeout
2023-09-01 13:45:57 core-matter-server chip.DMG[127] ERROR Failed to establish CASE for re-subscription with error 'src/lib/address_resolve/AddressResolve_DefaultImpl.cpp:114: CHIP Error 0x00000032: Timeout'
2023-09-01 13:45:57 core-matter-server matter_server.server.device_controller.[node 11][127] INFO Previous subscription failed with Error: 50, re-subscribing in 328509 ms...
Small update on my end. I've been running a bridge the whole day. It's still connected to HA, but it lost connection to Apple Home.
I will not get to work on this plug-in next week but I count to collect more logs the week after.
I would suggest to provide any logs you collect (both from my plug-in with debug logs enabled and from HA) to the matter.js repository as they will be very useful to debug the issue
The reason I couldn't connect virtual matter device to to Alexa?
Matter devices only support ipv6, and when I ran a test on my router from http://ip6.me/ it indicates that I am connected using ipv4 and ipv6 is not available, and on checking, ipv6 was disabled by default on the LAN.
I've now reconfigured my router enabling ipv6 on the LAN and was then able to discover and connect to an individual device, but groups of devices as in your example were not discoverable.
Import example
Deploy
"Alexa Discover Devices"
No new smart devices discovered!
In fact the ability to discover leave alone connect seems very hit and miss, but I was able to connect on a few occasions to matter device nodes.
So provided Alexa can successfully discover the device it can now connect.
It is not necessary to configure ipv6 in the router. If no ipv6(DHCP) is configured, all devices give themselves link-local addresses. Like APIPA for v4.
These addresses are usually sufficient.
I have not enabled v6 on either the WAN or LAN interface on my router and am successfully running multiple Matter devices with Alexa.
What would need to be considered is that the v6 protocol is enabled on the NodeRed instance and/or the Homeassistant instance and thus a link local address can be assigned.
@PdeJ since i cant reply anymore because i am a new user, i Am editing my post.....
yes, i am sure that i am using Matter devices. (Meross Matter/Wifi Smart Plugs and Aqara P2 Matter/Thread devices with Echo 4.Gen as Thread TBR.)
I didn't say you were wrong, quite the opposite.
You are absolutely right that Matter requires ipv6.
I just wanted to mention that it is not necessary to enable ipv6 on the router including ipv6 DHCP, but all devices generate a local link address based on their MAC address even without DHCP, which is perfectly sufficient for communication on the local network.
When v6 is enabled on the router (including DHCP), all local devices get a public IP address.
Since Matter is supposed to work without cloud, this should not be necessary.
My understanding is that Matter is based on the ipv6 and requires that as a minimum. Devices were able to connect to Alexa before Matter, so are your devices actually using Matter? Are you able to get Alexa to connect to matter node red using ipv4 protocol? The only success I have in getting a connection to the node on my Raspberry pi Zero 2w is when ipv6 has been enabled on the LAN. I see your argument, but ipv6 is likely to be more likely to work.
0.3.0 introduces support for dimmable lights and switches
Aside, I was able to test this plugin with LG ThinQ and I was able to pair a device (on a completely different home with different router etc), unfortunately ThinQ only supports basic lights and switches but it worked at least. Home Assistant worked as well in this new place.
did you try to add a second matter device to the matter server?
After deploying the change, are you still able to control your first matter device through homeassistant?