Data from cloud MQTT service crashing Glow2MQTT HASS add-on
In the past couple of weeks I've been getting the following error log from the Glow2MQTT add-on for Home Assistant:
MQTT found in this Home Assistant instance. Starting glow2mqtt.py... MQTT connected... Connected to Glow MQTT broker... Configuring Home Assistant... {'elec_imp': 42749.539, 'watt_now': 454} {'elec_imp': 42749.542, 'watt_now': 461} Traceback (most recent call last): File "/glow2mqtt.py", line 240, in <module> mqttg.loop_forever() File "/usr/lib/python3.10/site-packages/paho/mqtt/client.py", line 1756, in loop_forever rc = self._loop(timeout) File "/usr/lib/python3.10/site-packages/paho/mqtt/client.py", line 1164, in _loop rc = self.loop_read() File "/usr/lib/python3.10/site-packages/paho/mqtt/client.py", line 1556, in loop_read rc = self._packet_read() File "/usr/lib/python3.10/site-packages/paho/mqtt/client.py", line 2439, in _packet_read rc = self._packet_handle() File "/usr/lib/python3.10/site-packages/paho/mqtt/client.py", line 3033, in _packet_handle return self._handle_publish() File "/usr/lib/python3.10/site-packages/paho/mqtt/client.py", line 3327, in _handle_publish self._handle_on_message(message) File "/usr/lib/python3.10/site-packages/paho/mqtt/client.py", line 3570, in _handle_on_message on_message(self, self._userdata, message) File "/glow2mqtt.py", line 83, in process_msg if '00' in data['elecMtr']['0702']['04']: KeyError: '04' s6-rc: info: service legacy-services: stopping
I have to restart the add-on manually and it then runs for an indeterminate period before crashing with the same error.
Comments
The problem seems to have been intermittent supply of null values from the cloud MQTT service. The add-on has now been updated by the developer to catch these and filter them out.