Luligu / matterbridge-zigbee2mqtt

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

Zigbee2MQTT availability (?) cause errors in logs #16

Closed L2jLiga closed 6 months ago

L2jLiga commented 6 months ago

I'm not really sure if it somehow related to availability feature in Z2M, but I see in logs:

debug - [13:15:22.933] [Zigbee2MQTT]: tryJsonParse: parsing error from offline
error - [13:15:22.934] [Zigbee2MQTT]: tryJsonParse: parsing error: SyntaxError: Unexpected token 'o', "offline" is not valid JSON

stacktrace:

[13:15:22.934] [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/local/lib/node_modules/matterbridge-zigbee2mqtt/dist/zigbee2mqtt.js:316:25)
    at Zigbee2MQTT.messageHandler (file:///usr/local/lib/node_modules/matterbridge-zigbee2mqtt/dist/zigbee2mqtt.js:601:43)
    at MqttClient.<anonymous> (file:///usr/local/lib/node_modules/matterbridge-zigbee2mqtt/dist/zigbee2mqtt.js:167:22)
    at MqttClient.emit (node:events:518:28)
    at Array.<anonymous> (/usr/local/lib/node_modules/matterbridge-zigbee2mqtt/node_modules/mqtt/build/lib/handlers/publish.js:85:28)
    at MqttClient.options.customHandleAcks (/usr/local/lib/node_modules/matterbridge-zigbee2mqtt/node_modules/mqtt/build/lib/client.js:103:28)
    at handlePublish (/usr/local/lib/node_modules/matterbridge-zigbee2mqtt/node_modules/mqtt/build/lib/handlers/publish.js:73:21)
    at handle (/usr/local/lib/node_modules/matterbridge-zigbee2mqtt/node_modules/mqtt/build/lib/handlers/index.js:32:35)
    at work (/usr/local/lib/node_modules/matterbridge-zigbee2mqtt/node_modules/mqtt/build/lib/client.js:221:40) 
Luligu commented 6 months ago

Hi, thank you for your message. Can you please tell me what version of Matterbridge and what version of matterbridge-zigbee2mqtt and z2m are you using? This issue showed up when in z2m you have Legacy option active but of course it should cause any problem here. I thought the bag has been solved months ago... Maybe something new but I need the versions I asked you.

L2jLiga commented 6 months ago

Hi, I'm using latest versions available as of now:

matterbridge: 1.2.12, matterbridge-zigbee2mqtt: 2.0.12 Zigbee2mqtt: 1.37.0 commit: 46f34c8

This issue showed up when in z2m you have Legacy option active

Hmm, you mean this one? I didn't even touch this settings, will try to disable Screenshot_20240505-102706_Chrome

L2jLiga commented 6 months ago

I've unchecked both and restart Z2M, error message still appearing =(

Luligu commented 6 months ago

Ok thank you for your message. We found the bug! Will be fixed in the next release. If you want not to see it anymore now is easy: remove all retained messages from your MQTT broker for devices you don't have anymore. z2m doesn't remove retained messages when you remove a device. So they stay there forever and are sent every connections.

Luligu commented 6 months ago

Thanks for your help.

L2jLiga commented 6 months ago

Ok thank you for your message. We found the bug! Will be fixed in the next release. If you want not to see it anymore now is easy: remove all retained messages from your MQTT broker for devices you don't have anymore. z2m doesn't remove retained messages when you remove a device. So they stay there forever and are sent every connections.

Thanks, will try 🙂