stas-demydiuk / domoticz-zigbee2mqtt-plugin

zigbee2mqtt plugin for domoticz
MIT License
136 stars 98 forks source link

Plugin fails to connect due to TypeError: a bytes-like object is required, not 'str' #874

Closed averter closed 6 months ago

averter commented 7 months ago

Issue description Zigbee2mqtt is working properly and I can add devices to it without any issues. However, the plugin does not connect to mqtt or adds devices to DZ due to a type error. The domoticz log is as follows

2024-02-15 15:52:20.165 Error: zigbee: Call to function 'onMessage' failed, exception details:
2024-02-15 15:52:20.165 Error: zigbee: Traceback (most recent call last):
2024-02-15 15:52:20.165 Error: zigbee: File "/home/pi/domoticz/plugins/zigbee2mqtt/plugin.py", line 299, in onMessage
2024-02-15 15:52:20.165 Error: zigbee: _plugin.onMessage(Connection, Data)
2024-02-15 15:52:20.165 Error: zigbee: File "/home/pi/domoticz/plugins/zigbee2mqtt/plugin.py", line 137, in onMessage
2024-02-15 15:52:20.165 Error: zigbee: self.mqttClient.onMessage(Connection, Data)
2024-02-15 15:52:20.165 Error: zigbee: File "/home/pi/domoticz/plugins/zigbee2mqtt/mqtt.py", line 146, in onMessage
2024-02-15 15:52:20.165 Error: zigbee: topic = Data['Topic'] if 'Topic' in Data else ''
2024-02-15 15:52:20.165 Error: zigbee: ^^^^^^^^^^^^^^^
2024-02-15 15:52:20.165 Error: zigbee: TypeError: a bytes-like object is required, not 'str'
2024-02-15 15:53:10.180 Error: zigbee: Disconnected from MQTT Server: 192.168.88.162:8085

Additional information Zigbee2MQTT version: 3.8 Python version: 3.11 Domoticz version: 2024.4 Plugin version: master branch, commit 660db3f68ae48fedce9b17727db4617ec5f721c8

Logs See above.

averter commented 6 months ago

I was able to sort it out on my own. Essentially I was not aware that mosquitto had to be installed before running zigbee2mqtt (I thought that it would be included in the package). As soon as mqtt broker was installed it started working immediately.