stas-demydiuk / domoticz-zigbee2mqtt-plugin

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

Error: Zigbee2MQTT: TypeError: can only concatenate str (not "dict") to str** #803

Closed smitec11 closed 2 years ago

smitec11 commented 2 years ago

@Stanislav, Version: 2022.1 (build 14318) Build Hash: a380461ea Compile Date: 2022-04-22 07:36:31 dzVents Version: 3.1.8 Python Version: 3.9.2 (default, Feb 28 2021, 17:03:44) [GCC 10.2.1 20210110] rpi = 4b, 4gb, bullseye

got the following error in the log: 2022-05-03 20:21:11.856 Error: Zigbee2MQTT: Call to function 'onMessage' failed, exception details: 2022-05-03 20:21:11.864 Error: Zigbee2MQTT: Traceback (most recent call last): 2022-05-03 20:21:11.864 Error: Zigbee2MQTT: File "/home/pi/domoticz/plugins/zigbee2mqtt/plugin.py", line 298, in onMessage 2022-05-03 20:21:11.864 Error: Zigbee2MQTT: _plugin.onMessage(Connection, Data) 2022-05-03 20:21:11.864 Error: Zigbee2MQTT: File "/home/pi/domoticz/plugins/zigbee2mqtt/plugin.py", line 137, in onMessage 2022-05-03 20:21:11.864 Error: Zigbee2MQTT: self.mqttClient.onMessage(Connection, Data) 2022-05-03 20:21:11.864 Error: Zigbee2MQTT: File "/home/pi/domoticz/plugins/zigbee2mqtt/mqtt.py", line 167, in onMessage 2022-05-03 20:21:11.864 Error: Zigbee2MQTT: self.on_mqtt_message_cb(topic, message) 2022-05-03 20:21:11.864 Error: Zigbee2MQTT: File "/home/pi/domoticz/plugins/zigbee2mqtt/plugin.py", line 180, in onMQTTPublish 2022-05-03 20:21:11.864 Error: Zigbee2MQTT: domoticz.log('Zigbee2mqtt bridge is ' + (message)) 2022-05-03 20:21:11.864 Error: Zigbee2MQTT: TypeError: can only concatenate str (not "dict") to str

at line 179: if (topic == 'bridge/state'): domoticz.log('Zigbee2mqtt bridge is ' + message) return

shouldn't this be: if (topic == 'bridge/state'): domoticz.log('Zigbee2mqtt bridge is ' + str(message)) return

secator76 commented 2 years ago

Version: 2022.1 (build 14328) Build Hash: 37943b463 Compile Date: 2022-04-29 08:26:28 dzVents Version: 3.1.8 Python Version: 3.8.13 (default, Apr 19 2022, 02:32:06) [GCC 11.2.0] Ubuntu 22.04

Hi, same issue for me ........

2022-05-06 07:53:48.988 Error: Gateway Zigbee: Call to function 'onMessage' failed, exception details: 2022-05-06 07:53:49.013 Gateway Zigbee: Received available devices list from bridge 2022-05-06 07:53:49.014 Gateway Zigbee: Received available devices groups from bridge 2022-05-06 07:53:49.036 Status: MQTT Broker Mosquitto: connected to: localhost:1882 2022-05-06 07:53:49.011 Error: Gateway Zigbee: Traceback (most recent call last): 2022-05-06 07:53:49.011 Error: Gateway Zigbee: File "/home/domo2022/domoticz/plugins/zigbee2mqtt/plugin.py", line 298, in onMessage 2022-05-06 07:53:49.011 Error: Gateway Zigbee: _plugin.onMessage(Connection, Data) 2022-05-06 07:53:49.011 Error: Gateway Zigbee: File "/home/domo2022/domoticz/plugins/zigbee2mqtt/plugin.py", line 137, in onMessage 2022-05-06 07:53:49.011 Error: Gateway Zigbee: self.mqttClient.onMessage(Connection, Data) 2022-05-06 07:53:49.011 Error: Gateway Zigbee: File "/home/domo2022/domoticz/plugins/zigbee2mqtt/mqtt.py", line 167, in onMessage 2022-05-06 07:53:49.011 Error: Gateway Zigbee: self.on_mqtt_message_cb(topic, message) 2022-05-06 07:53:49.011 Error: Gateway Zigbee: File "/home/domo2022/domoticz/plugins/zigbee2mqtt/plugin.py", line 180, in onMQTTPublish 2022-05-06 07:53:49.011 Error: Gateway Zigbee: domoticz.log('Zigbee2mqtt bridge is ' + message) 2022-05-06 07:53:49.011 Error: Gateway Zigbee: TypeError: can only concatenate str (not "dict") to str

saper-2 commented 2 years ago

I think the line 179 of plugin.py should be fixed to this to keep with latest api of z2m:

domoticz.log('Zigbee2mqtt bridge is ' + str(message['state']))

I kept str as "fail-safe" 😉

But there is more problems with plugin since z2m folks changed api and some methods got deprecated (unsupported): like requesting device list...

saper-2 commented 2 years ago

Enabling Legacy API in Z2M make this error go away.

Personally I don't this is good solution 🙃

I think this might be decent solution, file plugin.py line 179+ :

            if (type(message) is dict):
                domoticz.log('Zigbee2mqtt bridge is ' + str(message['state']))
            else:
                domoticz.log('Zigbee2mqtt bridge is ' + str(message)) #keep "str" as fail-safe
smitec11 commented 2 years ago

nice solution, I think, but how do we get it into the release? seems like Stanislav is not reacting?

stas-demydiuk commented 2 years ago

Added the fix to master