domoticz-zigbee2mqtt-plugin: Error in WXKG03LM

Hi

I have this error with last version and Xiaomi Aqara wall switch (WXKG03LM)

2019-01-12 18:34:19.796  (Zigbee2MQTT) MQTT message: zigbee2mqtt/luz_salonb {'battery': 99, 'voltage': 3025, 'linkquality': 39, 'click': 'single'}

2019-01-12 18:34:19.797  Error: (Zigbee2MQTT) 'onMessage' failed 'TypeError':''ZigbeeMessage' object is not subscriptable'.
2019-01-12 18:34:19.797  Error: (Zigbee2MQTT) ----> Line 183 in '/home/pi/domoticz/plugins/zigbee2mqtt/plugin.py', function onMessage
2019-01-12 18:34:19.798  Error: (Zigbee2MQTT) ----> Line 110 in '/home/pi/domoticz/plugins/zigbee2mqtt/plugin.py', function onMessage
2019-01-12 18:34:19.798  Error: (Zigbee2MQTT) ----> Line 134 in '/home/pi/domoticz/plugins/zigbee2mqtt/mqtt.py', function onMessage
2019-01-12 18:34:19.798  Error: (Zigbee2MQTT) ----> Line 156 in '/home/pi/domoticz/plugins/zigbee2mqtt/plugin.py', function onMQTTPublish
2019-01-12 18:34:19.798  Error: (Zigbee2MQTT) ----> Line 18 in '/home/pi/domoticz/plugins/zigbee2mqtt/adapters/base_adapter.py', function handleMqttMessage
2019-01-12 18:34:19.798  Error: (Zigbee2MQTT) ----> Line 16 in '/home/pi/domoticz/plugins/zigbee2mqtt/adapters/lumi/WXKG03LM.py', function convert_message

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 15 (5 by maintainers)

Commits related to this issue

Most upvoted comments

I think I found the issue. The ‘click’ field needs to be accessed using the .raw method and not just the message object directly. (I am not a Python expert, so I may be calling these by the wrong terms for Python) and I am not sure why diff is flagging the handle_command call - there are no changes there.

index b50ffbd..c89876a 100644
--- a/adapters/lumi/WXKG03LM.py
+++ b/adapters/lumi/WXKG03LM.py
@@ -13,9 +13,9 @@ class WXKG03LM(AdapterWithBattery):
         message = super().convert_message(message)

         if 'click' in message.raw:
-            message.raw['state'] = 'on' if message['click'] == 'single' else 'off'
+            message.raw['state'] = 'on' if message.raw['click'] == 'single' else 'off'

         return message

     def handleCommand(self, alias, device, device_data, command, level, color):
-        self.switch.handle_command(device_data, command, level, color)
+        self.switch.handle_command(device_data, command, level, color)

with this fix locally, I no longer get the error message

 2019-03-03 10:55:40.779 (zigbee2mqtt) MqttClient::Ping
2019-03-03 10:55:50.812 (zigbee2mqtt) MqttClient::Ping
2019-03-03 10:55:51.270 (zigbee2mqtt) MQTT message: zigbee2mqtt/0x00158d0002a56041 {'battery': 100, 'voltage': 3085, 'linkquality': 155, 'click': 'single'}
2019-03-03 10:55:52.038 (zigbee2mqtt) MQTT message: zigbee2mqtt/0x00158d0002a56041 {'battery': 100, 'voltage': 3085, 'linkquality': 155, 'click': 'single'}
2019-03-03 10:55:52.706 (zigbee2mqtt) MQTT message: zigbee2mqtt/0x00158d0002a56041 {'battery': 100, 'voltage': 3085, 'linkquality': 155, 'click': 'single'}
2019-03-03 10:55:53.425 (zigbee2mqtt) MQTT message: zigbee2mqtt/0x00158d0002a56041 {'battery': 100, 'voltage': 3085, 'linkquality': 155, 'click': 'single'}
2019-03-03 10:56:00.798 (zigbee2mqtt) MqttClient::Ping
2019-03-03 10:56:10.831 (zigbee2mqtt) MqttClient::Ping