scooter1556 / hass-addons

A collection of Home Assistant OS addons
Apache License 2.0
1 stars 2 forks source link

Add-on crashes and is not restarted by watchdog #5

Closed bertha73 closed 1 year ago

bertha73 commented 1 year ago

I've had glow2mqtt set up and running for a couple of months (not local MQTT). Occasionally there have been hiccups with incorrect data entering the database (isolated readings of millions or billions of kWh) which I've corrected using the statistics tool in Home Assistant. However, in the last few days, the Glow2MQTT add-on has been crashing with the error log below and has not been restarting.

Home Assistant is fully updated: Home Assistant 2022.11.3 Supervisor 2022.10.2 Operating System 9.3 Frontend 20221108.0 - latest

Running on a RPi 4B (2GB), with the GlowStick CAD for SMETS1 meters and Cloud MQTT from Hildebrand

MQTT found in this Home Assistant instance. Starting glow2mqtt.py... MQTT connected... Connected to Glow MQTT broker... Configuring Home Assistant... {'elec_imp': 42743.259, 'watt_now': 396} Traceback (most recent call last): File "/glow2mqtt.py", line 240, in 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 s6-rc: info: service legacy-services successfully stopped s6-rc: info: service legacy-cont-init: stopping s6-rc: info: service legacy-cont-init successfully stopped s6-rc: info: service fix-attrs: stopping s6-rc: info: service fix-attrs successfully stopped s6-rc: info: service s6rc-oneshot-runner: stopping s6-rc: info: service s6rc-oneshot-runner successfully stopped

scooter1556 commented 1 year ago

Hi @bertha73 ,

Thanks for raising an issue. It looks like the data you are receiving is not always including current power readings for some reason. Are you able to connect to the Hildebrand broker with an MQTT client (e.g. MQTT Explorer) and send me an example of the data you are receiving with your personal data removed of course.

I will get the code updated to accommodate.

It would also be great if you can send me an example of an incorrect import reading. I'd be interested to know if these erroneous readings are always the same high value or different each time which would be harder to cater for. I know some were reporting getting '0' readings often which was causing issues but random high readings is a new one.

bertha73 commented 1 year ago

Hope you can do something with the data below. As I'm watching the add-on log in Home Assistant in real time I can see that it does restart by itself from time to time, but there are occasions when it crashes but doesn't restart as above.

{"elecMtr":{"0702":{"03":{"01":"000001","05":"29","04":"AB","02":"0003E8","07":"Metering PointID","08":"----------------","03":"AB","00":"00","06":"00"},"00":{"07":"2B0CB902","01":"000000000000","00":"0000028C9C85","14":"02","02":"000000000000"},"04":{"01":"000CA8","00":"000211"},"02":{"00":"00"}}},"gasMtr":{"0702":{"00":{}}},"ts":"2022-11-20 10:08:07","hversion":"EHZBWIFI0v4","time":"6379FC87","gmtime":1668938887,"pan":{"status":"joined","nPAN":"00","join":"0","lqi":"FF"},"ets":"2022-11-20 10:08:02","error":{"lastCommand":"00","errorCode":"00"},"gid":"70B3D521E0003AA5"} {"elecMtr":{"0702":{"03":{"01":"000001","05":"29","04":"AB","02":"0003E8","07":"Metering PointID","08":"----------------","03":"AB","00":"00","06":"00"},"00":{"07":"2B0CB8FA","01":"000000000000","00":"0000028C9C84","14":"02","02":"000000000000"},"04":{"01":"000CA6","00":"0002A1"},"02":{"00":"00"}}},"gasMtr":{"0702":{"00":{}}},"ts":"2022-11-20 10:07:54","hversion":"EHZBWIFI0v4","time":"6379FC7A","gmtime":1668938874,"pan":{"status":"joined","nPAN":"00","join":"0","lqi":"FF"},"ets":"2022-11-20 10:07:54","error":{"lastCommand":"00","errorCode":"00"},"gid":"70B3D521E0003AA5"} {"elecMtr":{"0702":{"03":{"01":"000001","05":"29","04":"AB","02":"0003E8","07":"Metering PointID","08":"----------------","03":"AB","00":"00","06":"00"},"00":{"07":"2B0CB8ED","01":"000000000000","00":"0000028C9C82","14":"02","02":"000000000000"},"04":{"01":"000CA4","00":"0002A5"},"02":{"00":"00"}}},"gasMtr":{"0702":{"00":{}}},"ts":"2022-11-20 10:07:47","hversion":"EHZBWIFI0v4","time":"6379FC73","gmtime":1668938867,"pan":{"status":"joined","nPAN":"00","join":"0","lqi":"FF"},"ets":"2022-11-20 10:07:41","error":{"lastCommand":"00","errorCode":"00"},"gid":"70B3D521E0003AA5"} {"elecMtr":{"0702":{"03":{"01":"000001","05":"29","04":"AB","02":"0003E8","07":"Metering PointID","08":"----------------","03":"AB","00":"00","06":"00"},"00":{"07":"2B0CB8D7","01":"000000000000","00":"0000028C9C7F","14":"02","02":"000000000000"},"04":{"01":"000CA0","00":"0001A5"},"02":{"00":"00"}}},"gasMtr":{"0702":{"00":{}}},"ts":"2022-11-20 10:07:26","hversion":"EHZBWIFI0v4","time":"6379FC5E","gmtime":1668938846,"pan":{"status":"joined","nPAN":"00","join":"0","lqi":"FF"},"ets":"2022-11-20 10:07:19","error":{"lastCommand":"00","errorCode":"00"},"gid":"70B3D521E0003AA5"} {"elecMtr":{"0702":{"03":{"01":"000001","05":"29","04":"AB","02":"0003E8","07":"Metering PointID","08":"----------------","03":"AB","00":"00","06":"00"},"00":{"07":"2B0CB8CA","01":"000000000000","00":"0000028C9C7D","14":"02","02":"000000000000"},"04":{"01":"000C9E","00":"0001AC"},"02":{"00":"00"}}},"gasMtr":{"0702":{"00":{}}},"ts":"2022-11-20 10:07:12","hversion":"EHZBWIFI0v4","time":"6379FC50","gmtime":1668938832,"pan":{"status":"joined","nPAN":"00","join":"0","lqi":"FF"},"ets":"2022-11-20 10:07:06","error":{"lastCommand":"00","errorCode":"00"},"gid":"70B3D521E0003AA5"} {"elecMtr":{"0702":{"03":{"01":"000001","05":"29","04":"AB","02":"0003E8","07":"Metering PointID","08":"----------------","03":"AB","00":"00","06":"00"},"00":{"07":"2B0CB8C1","01":"000000000000","00":"0000028C9C7B","14":"02","02":"000000000000"},"04":{"01":"000C9D","00":"0001D8"},"02":{"00":"00"}}},"gasMtr":{"0702":{"00":{}}},"ts":"2022-11-20 10:06:59","hversion":"EHZBWIFI0v4","time":"6379FC43","gmtime":1668938819,"pan":{"status":"joined","nPAN":"00","join":"0","lqi":"FF"},"ets":"2022-11-20 10:06:57","error":{"lastCommand":"00","errorCode":"00"},"gid":"70B3D521E0003AA5"} {"elecMtr":{"0702":{"00":{}}},"gasMtr":{"0702":{"00":{}}},"ts":"2022-11-20 10:06:52","hversion":"EHZBWIFI0v4","time":"6379FC3C","gmtime":1668938812,"pan":{"status":"joined","nPAN":"00","join":"0","lqi":"FF"},"error":{"lastCommand":"00","errorCode":"00"},"gid":"70B3D521E0003AA5"} {"elecMtr":{"0702":{"03":{"01":"000001","05":"29","04":"AB","02":"0003E8","07":"Metering PointID","08":"----------------","03":"AB","00":"00","06":"00"},"00":{"07":"2B0CB893","01":"000000000000","00":"0000028C9C74","14":"02","02":"000000000000"},"04":{"01":"000C96","00":"000281"},"02":{"00":"00"}}},"gasMtr":{"0702":{"00":{}}},"ts":"2022-11-20 10:06:22","hversion":"EHZBWIFI0v4","time":"6379FC1E","gmtime":1668938782,"pan":{"status":"joined","nPAN":"00","join":"0","lqi":"FF"},"ets":"2022-11-20 10:06:11","error":{"lastCommand":"00","errorCode":"00"},"gid":"70B3D521E0003AA5"} {"elecMtr":{"0702":{"03":{"01":"000001","05":"29","04":"AB","02":"0003E8","07":"Metering PointID","08":"----------------","03":"AB","00":"00","06":"00"},"00":{"07":"2B0CB888","01":"000000000000","00":"0000028C9C73","14":"02","02":"000000000000"},"04":{"01":"000C93","00":"0001B7"},"02":{"00":"00"}}},"gasMtr":{"0702":{"00":{}}},"ts":"2022-11-20 10:06:01","hversion":"EHZBWIFI0v4","time":"6379FC09","gmtime":1668938761,"pan":{"status":"joined","nPAN":"00","join":"0","lqi":"FF"},"ets":"2022-11-20 10:06:00","error":{"lastCommand":"00","errorCode":"00"},"gid":"70B3D521E0003AA5"} {"elecMtr":{"0702":{"03":{"01":"000001","05":"29","04":"AB","02":"0003E8","07":"Metering PointID","08":"----------------","03":"AB","00":"00","06":"00"},"00":{"07":"2B0CB888","01":"000000000000","00":"0000028C9C73","14":"02","02":"000000000000"},"04":{"01":"000C93","00":"0001B7"},"02":{"00":"00"}}},"gasMtr":{"0702":{"00":{}}},"ts":"2022-11-20 10:06:01","hversion":"EHZBWIFI0v4","time":"6379FC09","gmtime":1668938761,"pan":{"status":"joined","nPAN":"00","join":"0","lqi":"FF"},"ets":"2022-11-20 10:06:00","error":{"lastCommand":"00","errorCode":"00"},"gid":"70B3D521E0003AA5"} {"elecMtr":{"0702":{"03":{"01":"000001","05":"29","04":"AB","02":"0003E8","07":"Metering PointID","08":"----------------","03":"AB","00":"00","06":"00"},"00":{"07":"2B0CB877","01":"000000000000","00":"0000028C9C70","14":"02","02":"000000000000"},"04":{"01":"000C92","00":"00025D"},"02":{"00":"00"}}},"gasMtr":{"0702":{"00":{}}},"ts":"2022-11-20 10:05:49","hversion":"EHZBWIFI0v4","time":"6379FBFD","gmtime":1668938749,"pan":{"status":"joined","nPAN":"00","join":"0","lqi":"FF"},"ets":"2022-11-20 10:05:43","error":{"lastCommand":"00","errorCode":"00"},"gid":"70B3D521E0003AA5"} {"elecMtr":{"0702":{"00":{}}},"gasMtr":{"0702":{"00":{}}},"ts":"2022-11-20 10:05:39","hversion":"EHZBWIFI0v4","time":"6379FBF3","gmtime":1668938739,"pan":{"status":"joined","nPAN":"00","join":"0","lqi":"FF"},"error":{"lastCommand":"00","errorCode":"00"},"gid":"70B3D521E0003AA5"}

scooter1556 commented 1 year ago

Thanks for sending that over @bertha73

It looks like occasionally you are getting data with no electric or gas readings included (such as the final one in the data you sent me). Let me put a catch in the code for this and get the addon updated.

bertha73 commented 1 year ago

Thanks. Don't know if it's relevant or not but there will never be any gas meter data since only the electricity meter is smart! The gas one is a traditional manually read meter and there's no prospect of it changing apparently for technical reasons.

scooter1556 commented 1 year ago

@bertha73 I am hoping this is fixed with the latest update to the addon (1.2.4).

bertha73 commented 1 year ago

Updated and it seems rock solid now. Thank you!