ha_hildebrand_glow_ihd_mqtt icon indicating copy to clipboard operation
ha_hildebrand_glow_ihd_mqtt copied to clipboard

Exception in MQTT Message Received

Open viking2010 opened this issue 2 years ago • 2 comments

Hi

I installed the integration this evening and it's great, but I'm getting the following errors appearing in the logs and I'm unsure what the issue might be:

Logger: homeassistant.util.logging
Source: util/logging.py:159
First occurred: 23:24:32 (138 occurrences)
Last logged: 23:47:22

Exception in mqtt_message_received when handling msg on 'glow/REDACTED/SENSOR/electricitymeter': '{"electricitymeter":{"timestamp":"2023-02-07T23:46:33Z","energy":{"export":{"cumulative":0.000,"units":"kWh"},"import":{"cumulative":25393.127,"day":13.390,"week":29.440,"month":131.037,"units":"kWh","mpan":"Metering PointID","supplier":"---","price":{"unitrate":null,"standingcharge":null}}},"power":{"value":0.496,"units":"kW"}}}' Traceback (most recent call last): File "/config/custom_components/hildebrand_glow_ihd/sensor.py", line 281, in mqtt_message_received updateGroup.process_update(message) File "/config/custom_components/hildebrand_glow_ihd/sensor.py", line 325, in process_update sensor.process_update(parsed_data) File "/config/custom_components/hildebrand_glow_ihd/sensor.py", line 359, in process_update new_value = self._func(mqtt_data) File "/config/custom_components/hildebrand_glow_ihd/sensor.py", line 152, in <lambda> (js['electricitymeter']['energy']['import']['day'] * js['electricitymeter']['energy']['import']['price']['unitrate']), 2), TypeError: unsupported operand type(s) for *: 'float' and 'NoneType'

Exception in mqtt_message_received when handling msg on 'glow/REDACTED/SENSOR/electricitymeter': '{"electricitymeter":{"timestamp":"2023-02-07T23:46:43Z","energy":{"export":{"cumulative":0.000,"units":"kWh"},"import":{"cumulative":25393.129,"day":13.391,"week":29.441,"month":131.038,"units":"kWh","mpan":"Metering PointID","supplier":"---","price":{"unitrate":null,"standingcharge":null}}},"power":{"value":0.501,"units":"kW"}}}' Traceback (most recent call last): File "/config/custom_components/hildebrand_glow_ihd/sensor.py", line 281, in mqtt_message_received updateGroup.process_update(message) File "/config/custom_components/hildebrand_glow_ihd/sensor.py", line 325, in process_update sensor.process_update(parsed_data) File "/config/custom_components/hildebrand_glow_ihd/sensor.py", line 359, in process_update new_value = self._func(mqtt_data) File "/config/custom_components/hildebrand_glow_ihd/sensor.py", line 152, in <lambda> (js['electricitymeter']['energy']['import']['day'] * js['electricitymeter']['energy']['import']['price']['unitrate']), 2), TypeError: unsupported operand type(s) for *: 'float' and 'NoneType'

Exception in mqtt_message_received when handling msg on 'glow/REDACTED/SENSOR/electricitymeter': '{"electricitymeter":{"timestamp":"2023-02-07T23:46:53Z","energy":{"export":{"cumulative":0.000,"units":"kWh"},"import":{"cumulative":25393.129,"day":13.392,"week":29.442,"month":131.039,"units":"kWh","mpan":"Metering PointID","supplier":"---","price":{"unitrate":null,"standingcharge":null}}},"power":{"value":0.504,"units":"kW"}}}' Traceback (most recent call last): File "/config/custom_components/hildebrand_glow_ihd/sensor.py", line 281, in mqtt_message_received updateGroup.process_update(message) File "/config/custom_components/hildebrand_glow_ihd/sensor.py", line 325, in process_update sensor.process_update(parsed_data) File "/config/custom_components/hildebrand_glow_ihd/sensor.py", line 359, in process_update new_value = self._func(mqtt_data) File "/config/custom_components/hildebrand_glow_ihd/sensor.py", line 152, in <lambda> (js['electricitymeter']['energy']['import']['day'] * js['electricitymeter']['energy']['import']['price']['unitrate']), 2), TypeError: unsupported operand type(s) for *: 'float' and 'NoneType'

Exception in mqtt_message_received when handling msg on 'glow/REDACTED/SENSOR/electricitymeter': '{"electricitymeter":{"timestamp":"2023-02-07T23:47:03Z","energy":{"export":{"cumulative":0.000,"units":"kWh"},"import":{"cumulative":25393.131,"day":13.394,"week":29.444,"month":131.041,"units":"kWh","mpan":"Metering PointID","supplier":"---","price":{"unitrate":null,"standingcharge":null}}},"power":{"value":0.666,"units":"kW"}}}' Traceback (most recent call last): File "/config/custom_components/hildebrand_glow_ihd/sensor.py", line 281, in mqtt_message_received updateGroup.process_update(message) File "/config/custom_components/hildebrand_glow_ihd/sensor.py", line 325, in process_update sensor.process_update(parsed_data) File "/config/custom_components/hildebrand_glow_ihd/sensor.py", line 359, in process_update new_value = self._func(mqtt_data) File "/config/custom_components/hildebrand_glow_ihd/sensor.py", line 152, in <lambda> (js['electricitymeter']['energy']['import']['day'] * js['electricitymeter']['energy']['import']['price']['unitrate']), 2), TypeError: unsupported operand type(s) for *: 'float' and 'NoneType'

Exception in mqtt_message_received when handling msg on 'glow/REDACTED/SENSOR/electricitymeter': '{"electricitymeter":{"timestamp":"2023-02-07T23:47:13Z","energy":{"export":{"cumulative":0.000,"units":"kWh"},"import":{"cumulative":25393.133,"day":13.396,"week":29.446,"month":131.043,"units":"kWh","mpan":"Metering PointID","supplier":"---","price":{"unitrate":null,"standingcharge":null}}},"power":{"value":0.630,"units":"kW"}}}' Traceback (most recent call last): File "/config/custom_components/hildebrand_glow_ihd/sensor.py", line 281, in mqtt_message_received updateGroup.process_update(message) File "/config/custom_components/hildebrand_glow_ihd/sensor.py", line 325, in process_update sensor.process_update(parsed_data) File "/config/custom_components/hildebrand_glow_ihd/sensor.py", line 359, in process_update new_value = self._func(mqtt_data) File "/config/custom_components/hildebrand_glow_ihd/sensor.py", line 152, in <lambda> (js['electricitymeter']['energy']['import']['day'] * js['electricitymeter']['energy']['import']['price']['unitrate']), 2), TypeError: unsupported operand type(s) for *: 'float' and 'NoneType'

HA Version Info: Home Assistant 2023.2.2 Supervisor 2023.01.1 Operating System 9.5 Frontend 20230202.0 - latest

Please let me know if there is any other details you might need.

Thank you

viking2010 avatar Feb 07 '23 23:02 viking2010

I think I've figured this out and why the errors are being produced. For some reason, my SMETS1 meter isn't publishing the data for "price" and it's coming through as Null. The calculation that's being done to work out the days total cost is then producing the error as the "price" value is null. As for figuring out a fix for null values, I'm not sure how to go about that yet!

viking2010 avatar Feb 08 '23 11:02 viking2010

The pull request that's waiting for approval helped me with the code to resolve this issue. What I've had to do is manually enter the figures in the sensor.py file. I'm not sure if this is the correct way of doing this, but it's working:

    "name": "Smart Meter Electricity: Import Standing Charge",
    "device_class": SensorDeviceClass.MONETARY,
    "unit_of_measurement": "GBP",
    "state_class": SensorStateClass.MEASUREMENT,
    "icon": "mdi:cash",
    "func": lambda js : (0.45066),
    "ignore_zero_values": True,

    "name": "Smart Meter Electricity: Cost (Today)",
    "device_class": SensorDeviceClass.MONETARY,
    "unit_of_measurement": "GBP",
    "state_class": SensorStateClass.TOTAL_INCREASING,
    "icon": "mdi:cash",
    "func": lambda js : round(0.45066 + \
       (js['electricitymeter']['energy']['import']['day'] * 0.17383), 2),

It's probably a very crude way to fix my issue, but it's working.

viking2010 avatar Feb 08 '23 16:02 viking2010