Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception in MQTT Message Received #29

Open
viking2010 opened this issue Feb 7, 2023 · 2 comments
Open

Exception in MQTT Message Received #29

viking2010 opened this issue Feb 7, 2023 · 2 comments

Comments

@viking2010
Copy link

viking2010 commented Feb 7, 2023

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
Copy link
Author

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
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant