stas-demydiuk / domoticz-zigbee2mqtt-plugin

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

Error with dual band Xiaomi Opple Switch (WXCJKG12LM) #838

Closed MarcusKlerks closed 1 year ago

MarcusKlerks commented 1 year ago

Issue description For unknown reasons the Opple Switch began to generate an error in the Domoticz log. The error occurs once per hour (zigbee2mqtt heartbeat?), for the rest the switch functions correct.

Additional information Zigbee2MQTT version: 1.28.2 commit: 360a777 Python version: 3.7.3 Domoticz version: 2022.2 latest beat Plugin version: 3.2.0

Logs Domoticz log:

2022-11-29 10:23:45.817 Error: Zigbee-Z2M: Call to function 'onMessage' failed, exception details:
2022-11-29 10:23:45.818 Error: Zigbee-Z2M: Traceback (most recent call last):
2022-11-29 10:23:45.818 Error: Zigbee-Z2M: File "/home/pi/domoticz/plugins/zigbee2mqtt/plugin.py", line 299, in onMessage
2022-11-29 10:23:45.818 Error: Zigbee-Z2M: _plugin.onMessage(Connection, Data)
2022-11-29 10:23:45.819 Error: Zigbee-Z2M: File "/home/pi/domoticz/plugins/zigbee2mqtt/plugin.py", line 137, in onMessage
2022-11-29 10:23:45.819 Error: Zigbee-Z2M: self.mqttClient.onMessage(Connection, Data)
2022-11-29 10:23:45.819 Error: Zigbee-Z2M: File "/home/pi/domoticz/plugins/zigbee2mqtt/mqtt.py", line 167, in onMessage
2022-11-29 10:23:45.819 Error: Zigbee-Z2M: self.on_mqtt_message_cb(topic, message)
2022-11-29 10:23:45.819 Error: Zigbee-Z2M: File "/home/pi/domoticz/plugins/zigbee2mqtt/plugin.py", line 215, in onMQTTPublish
2022-11-29 10:23:45.819 Error: Zigbee-Z2M: self.devices_manager.handle_mqtt_message(topic, message)
2022-11-29 10:23:45.819 Error: Zigbee-Z2M: File "/home/pi/domoticz/plugins/zigbee2mqtt/devices_manager.py", line 61, in handle_mqtt_message
2022-11-29 10:23:45.819 Error: Zigbee-Z2M: adapter.handle_mqtt_message(zigbee_message)
2022-11-29 10:23:45.819 Error: Zigbee-Z2M: File "/home/pi/domoticz/plugins/zigbee2mqtt/adapters/lumi/aqara_opple_switch.py", line 45, in handle_mqtt_message
2022-11-29 10:23:45.819 Error: Zigbee-Z2M: if action.startswith('button_' + str(btn_index)):
2022-11-29 10:23:45.819 Error: Zigbee-Z2M: AttributeError: 'NoneType' object has no attribute 'startswith'

The according mqtt message:

{
  "action": null,
  "battery": 100
}

I did filter the rest of the attributes. The message is the same when awaken the switch with the button (short press) on the back.

After inserting:

if action is None: return

before line 45 in the file aqara_opple_switch.py the problem is gone. I don't know if this is the proper place for correcting the error, but it works.

stas-demydiuk commented 1 year ago

Should be fixed now, could you please update the plugin and check

MarcusKlerks commented 1 year ago

Did the update and had it run for a couple of hours: no errors so I'd say its fixed and issue can be closed.

Stay strong and safe, Mark