Luligu / matterbridge-zigbee2mqtt

Matterbridge zigbee2mqtt plugin
https://github.com/Luligu/matterbridge-zigbee2mqtt/blob/main/README.md
Apache License 2.0
63 stars 8 forks source link

Plugin starts only when matterbridge is in debug mode #30

Closed PascalHaury closed 2 months ago

PascalHaury commented 2 months ago

Hi,

I installed Matterbridge today, but the Zigbee2MQTT plugin isn't starting.

I have installed the latest versions:

I used the integrated plugin installer for the installation.

After some research, I found out that the Legacy API in Zigbee2MQTT must be disabled. However, this did not resolve the issue.

When I restarted Matterbridge with the -frontend and -debug options, all my devices were shown and available.

After restarting it again without the debug flag, the plugin didn't start again, and 0 devices are available.

Here is a screenshot showing the issue: image

Attached is the log file with debugging enabled, where everything works: cleaned_z2m.log

And here is the log file without debugging enabled, where no devices are available:

[20:09:15.235] [Matterbridge] Matterbridge version 1.3.0 mode bridge running on Linux 6.5.11-6-pve linux x64 
[20:09:15.320] [Matterbridge] Loading plugin matterbridge-zigbee2mqtt type DynamicPlatform 
[20:09:15.343] [Matterbridge] WebSocketServer is listening on ws://10.0.1.6:8284 
[20:09:15.343] [Matterbridge] The frontend is listening on http://10.0.1.6:8283 
[20:09:15.352] [Matterbridge zigbee2mqtt plugin] Loaded zigbee2mqtt parameters from /root/.matterbridge/matterbridge-zigbee2mqtt.config.json: 
[20:09:15.353] [Zigbee2MQTT] Created new instance with host: 10.0.1.7 port: 1883 topic: zigbee2mqtt username: z2m_user password: ***** 
[20:09:15.353] [Matterbridge zigbee2mqtt plugin] Connecting to MQTT broker: mqtt://10.0.1.7:1883 
[20:09:15.381] [Matterbridge] Loaded plugin matterbridge-zigbee2mqtt type DynamicPlatform (entrypoint /usr/lib/node_modules/matterbridge-zigbee2mqtt/dist/index.js) 
[20:09:15.382] [Matterbridge] Starting plugin matterbridge-zigbee2mqtt type DynamicPlatform 
[20:09:15.382] [Matterbridge zigbee2mqtt plugin] Starting zigbee2mqtt dynamic platform v2.1.0: Matterbridge is starting 
[20:09:15.383] [Matterbridge zigbee2mqtt plugin] MQTT broker at 10.0.1.7:1883 connected 
[20:09:15.386] [Matterbridge zigbee2mqtt plugin] zigbee2MQTT is online 
[20:09:15.389] [Matterbridge zigbee2mqtt plugin] zigbee2MQTT version 1.38.0 zh version 0.49.2 zhc version 19.47.1 
[20:09:15.459] [Matterbridge zigbee2mqtt plugin] zigbee2MQTT sent 49 devices  
[20:09:15.466] [Matterbridge zigbee2mqtt plugin] zigbee2MQTT sent 1 groups  
[20:09:15.491] [Matterbridge zigbee2mqtt plugin] zigbee2MQTT device Wohnzimmer Deckenlampe 1 is online 
[20:09:15.507] [Matterbridge zigbee2mqtt plugin] zigbee2MQTT device Schlafzimmer Deckenlampe 2 is online 
[20:09:15.507] [Matterbridge zigbee2mqtt plugin] zigbee2MQTT device Wohnzimmer Deckenlampe 2 is online 
[20:09:15.515] [Matterbridge zigbee2mqtt plugin] zigbee2MQTT device Remote Schlafzimmer Licht is online 
[20:09:15.516] [Matterbridge zigbee2mqtt plugin] zigbee2MQTT device Lüfter Mobil is online 
[20:09:15.517] [Matterbridge zigbee2mqtt plugin] zigbee2MQTT device Sofa Licht is online 
[20:09:15.517] [Matterbridge zigbee2mqtt plugin] zigbee2MQTT device Badezimmer Licht is online 
[20:09:15.518] [Matterbridge zigbee2mqtt plugin] zigbee2MQTT device Schlafzimmer Deckenlampe 3 is online 
[20:09:15.518] [Matterbridge zigbee2mqtt plugin] zigbee2MQTT device Kaffeemaschine Licht is online 
[20:09:15.518] [Matterbridge zigbee2mqtt plugin] zigbee2MQTT device Küche Licht is online 
[20:09:15.519] [Matterbridge zigbee2mqtt plugin] zigbee2MQTT device Badezimmer Abluft is online 
[20:09:15.519] [Matterbridge zigbee2mqtt plugin] zigbee2MQTT device Dusche Licht is online 
[20:09:15.519] [Matterbridge zigbee2mqtt plugin] zigbee2MQTT device Sim Rig is online 
[20:09:15.520] [Matterbridge zigbee2mqtt plugin] zigbee2MQTT device Sim Rig Monitore is offline 
[20:09:15.525] [Matterbridge zigbee2mqtt plugin] zigbee2MQTT device Küchenzeile Licht is online 
[20:09:15.550] [Matterbridge zigbee2mqtt plugin] zigbee2MQTT device Remote Küche Licht is online 
[20:09:15.550] [Matterbridge zigbee2mqtt plugin] zigbee2MQTT device Wohnzimmer Deckenlampe 3 is online 
[20:09:15.552] [Zigbee2MQTT] tryJsonParse: parsing error: SyntaxError: Unexpected token 'o', "online" is not valid JSON SyntaxError: Unexpected token 'o', "online" is not valid JSON
    at JSON.parse (<anonymous>)
    at Zigbee2MQTT.tryJsonParse (file:///usr/lib/node_modules/matterbridge-zigbee2mqtt/dist/zigbee2mqtt.js:328:25)
    at Zigbee2MQTT.messageHandler (file:///usr/lib/node_modules/matterbridge-zigbee2mqtt/dist/zigbee2mqtt.js:583:35)
    at MqttClient.<anonymous> (file:///usr/lib/node_modules/matterbridge-zigbee2mqtt/dist/zigbee2mqtt.js:168:22)
    at MqttClient.emit (node:events:519:28)
    at Array.<anonymous> (/usr/lib/node_modules/matterbridge-zigbee2mqtt/node_modules/mqtt/build/lib/handlers/publish.js:85:28)
    at MqttClient.options.customHandleAcks (/usr/lib/node_modules/matterbridge-zigbee2mqtt/node_modules/mqtt/build/lib/client.js:103:28)
    at handlePublish (/usr/lib/node_modules/matterbridge-zigbee2mqtt/node_modules/mqtt/build/lib/handlers/publish.js:73:21)
    at handle (/usr/lib/node_modules/matterbridge-zigbee2mqtt/node_modules/mqtt/build/lib/handlers/index.js:28:35)
    at work (/usr/lib/node_modules/matterbridge-zigbee2mqtt/node_modules/mqtt/build/lib/client.js:221:40) 
[20:09:15.571] [Matterbridge zigbee2mqtt plugin] zigbee2MQTT device Computer Licht is online 
[20:09:15.572] [Matterbridge zigbee2mqtt plugin] zigbee2MQTT device Computer Lautsprecher is online 
[20:09:15.572] [Matterbridge zigbee2mqtt plugin] zigbee2MQTT device Remote Bett Licht is online 
[20:09:15.573] [Matterbridge zigbee2mqtt plugin] zigbee2MQTT device Remote Computer Licht is offline 
[20:09:15.573] [Matterbridge zigbee2mqtt plugin] zigbee2MQTT device Computer is online 
[20:09:15.574] [Matterbridge zigbee2mqtt plugin] zigbee2MQTT device Monitore is online 
[20:09:15.574] [Matterbridge zigbee2mqtt plugin] zigbee2MQTT device Remote Sofa is offline 
[20:09:15.574] [Matterbridge zigbee2mqtt plugin] zigbee2MQTT device Remote Wohnzimmer is offline 
[20:09:15.577] [Matterbridge zigbee2mqtt plugin] zigbee2MQTT device Remote Sofa 2 is online 
[20:09:15.583] [Matterbridge zigbee2mqtt plugin] zigbee2MQTT device Temperatur Wohnzimmer is online 
[20:09:15.588] [Matterbridge zigbee2mqtt plugin] zigbee2MQTT device Temperatur Badezimmer is online 
[20:09:15.595] [Matterbridge zigbee2mqtt plugin] zigbee2MQTT device Temperatur Küche is online 
[20:09:15.598] [Matterbridge zigbee2mqtt plugin] zigbee2MQTT device Temperatur Schlafzimmer is online 
[20:09:15.599] [Matterbridge zigbee2mqtt plugin] zigbee2MQTT device Wohnzimmer Balkon is online 
[20:09:15.603] [Matterbridge zigbee2mqtt plugin] zigbee2MQTT device Haustüre is online 
[20:09:15.604] [Matterbridge zigbee2mqtt plugin] zigbee2MQTT device Küche Fenster is online 
[20:09:15.615] [Matterbridge zigbee2mqtt plugin] zigbee2MQTT device Dachfenster 1 is online 
[20:09:15.616] [Matterbridge zigbee2mqtt plugin] zigbee2MQTT device Dachfenster 2 is online 
[20:09:15.624] [Matterbridge zigbee2mqtt plugin] zigbee2MQTT device Simrig Fernseher is offline 
[20:09:15.626] [Matterbridge zigbee2mqtt plugin] zigbee2MQTT device Schlafzimmer Deckenlampe 1 is online 
[20:09:15.626] [Matterbridge zigbee2mqtt plugin] zigbee2MQTT device Mixer Küche is online 
[20:09:15.627] [Matterbridge zigbee2mqtt plugin] zigbee2MQTT device Bett Strom is online 
[20:09:15.627] [Matterbridge zigbee2mqtt plugin] zigbee2MQTT device Tablet Bett Strom is offline 
[20:09:15.627] [Matterbridge zigbee2mqtt plugin] zigbee2MQTT device Wohnzimmer Media is online 
[20:09:15.635] [Matterbridge zigbee2mqtt plugin] zigbee2MQTT device Router Strom is online 
[20:09:15.636] [Matterbridge zigbee2mqtt plugin] zigbee2MQTT device Fernseher Schlafzimmer Power is online 
[20:09:15.638] [Matterbridge zigbee2mqtt plugin] zigbee2MQTT device 0x60a423fffeeed460 is offline 
[20:09:15.639] [Matterbridge zigbee2mqtt plugin] zigbee2MQTT device Schreibtisch Licht is online 
[20:09:15.639] [Matterbridge zigbee2mqtt plugin] zigbee2MQTT device Kühlschrank Temperatur is online 
[20:09:15.640] [Matterbridge zigbee2mqtt plugin] zigbee2MQTT device Remote Wohnzimmer 2 is online 
[20:09:15.640] [Matterbridge zigbee2mqtt plugin] zigbee2MQTT device Badezimmer Schalter is online 
[20:09:16.888] [Matterbridge] Failed to start plugin matterbridge-zigbee2mqtt: Error: Only supported EndpointInterface implementation is Endpoint 
[20:09:17.379] [Matterbridge] Matter server started 
[20:09:17.413] [Matterbridge] The commissioning server on port 5540 for Matterbridge is not commissioned. Pair it scanning the QR code:
Luligu commented 2 months ago

Hi, I'm sorry to see you are having this strange issue. The debug log seems ok:

The log without -debug tell us that matter.js throw error. The problem here is that without -debug is difficult to understand exactly where is the issue.

If you are available to make some test I can send you a patch and try to understand where is the problem.

If not, try to totally clean the mqtt broker from all retained messages, restart the machine where you run z2m and the mqtt broker, factory reset matterbridge.

PascalHaury commented 2 months ago

Hi, I can test anything you want or need to try 👍

If you need any more infos/files feel free to ask, and i will try to provide the infos

PascalHaury commented 2 months ago

Ok, quick update. I fired up a new lxc in proxmox with the exactly same settings (Debian 12, 1CPU Core, 512MB RAM, 16Gb storage), and now it works. The only differences are:

The only bug i think i found is that the debug mode is now default enabled for the plugin. Even if the debug checkbox is not checked and Matterbridge is set to info logging, i get the debug logs in the main window. But for now all my devices are showing up in matterbridge.

If you need to test anything else, feel free to ask, but i think the issue can be closed

image

copystring commented 2 months ago

It's the same for me. matterbridge-zigbee2mqtt has always been on debug regardless of setting.

Luligu commented 2 months ago

Hi, thanks for your feedback. Since I released also matterbridge-shelly (https://github.com/Luligu/matterbridge-shelly/blob/main/README.md), I'm unifying the debug system for all plugins. The idea is to be able to debug the single plugin without debugging the whole matterbridge... cause some users have hundreds of devices... in different plugins In the case of zigbee2mqtt plugin debug is only in the config but not operational. Will move from global to single plugin debug in the next release. Is a transitional update that takes a few time.

Luligu commented 2 months ago

Fixed debug default to false for zigbee2mqtt plugin and somfy (https://github.com/Luligu/matterbridge-somfy-tahoma/blob/main/README.md). Thanks.