diff --git a/custom_components/hildebrand_glow_ihd_mqtt/sensor.py b/custom_components/hildebrand_glow_ihd_mqtt/sensor.py index 1b9fd01..c1e52b9 100755 --- a/custom_components/hildebrand_glow_ihd_mqtt/sensor.py +++ b/custom_components/hildebrand_glow_ihd_mqtt/sensor.py @@ -253,8 +253,8 @@ "unit_of_measurement": "GBP", "state_class": SensorStateClass.TOTAL_INCREASING, "icon": "mdi:cash", - "func": lambda js : round(js['gasmeter']['energy']['import']['price']['standingcharge'] + \ - (js['gasmeter']['energy']['import']['day'] * js['gasmeter']['energy']['import']['price']['unitrate']), 2), + "func": lambda js : round((js['gasmeter']['energy']['import']['price']['standingcharge'] or 0)+ \ + ((js['gasmeter']['energy']['import']['day'] or 0) * (js['gasmeter']['energy']['import']['price']['unitrate'] or 0)), 2), } ]