Skip to content

Commit

Permalink
Fix sensor warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
megakid committed Apr 19, 2023
1 parent 94dd8b9 commit af03465
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions custom_components/hildebrand_glow_ihd_mqtt/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@
"name": "Smart Meter Electricity: Import Unit Rate",
"device_class": SensorDeviceClass.MONETARY,
"unit_of_measurement": "GBP/kWh",
"state_class": SensorStateClass.MEASUREMENT,
"state_class": None,
"icon": "mdi:cash",
"func": lambda js : js['electricitymeter']['energy']['import']['price']['unitrate'],
"ignore_zero_values": True,
Expand All @@ -129,7 +129,7 @@
"name": "Smart Meter Electricity: Import Standing Charge",
"device_class": SensorDeviceClass.MONETARY,
"unit_of_measurement": "GBP",
"state_class": SensorStateClass.MEASUREMENT,
"state_class": None,
"icon": "mdi:cash",
"func": lambda js : js['electricitymeter']['energy']['import']['price']['standingcharge'],
"ignore_zero_values": True,
Expand All @@ -146,7 +146,7 @@
"name": "Smart Meter Electricity: Cost (Today)",
"device_class": SensorDeviceClass.MONETARY,
"unit_of_measurement": "GBP",
"state_class": SensorStateClass.TOTAL_INCREASING,
"state_class": None,
"icon": "mdi:cash",
"func": lambda js : round(js['electricitymeter']['energy']['import']['price']['standingcharge'] + \
(js['electricitymeter']['energy']['import']['day'] * js['electricitymeter']['energy']['import']['price']['unitrate']), 2),
Expand Down Expand Up @@ -224,7 +224,7 @@
"name": "Smart Meter Gas: Import Unit Rate",
"device_class": SensorDeviceClass.MONETARY,
"unit_of_measurement": "GBP/kWh",
"state_class": SensorStateClass.MEASUREMENT,
"state_class": None,
"icon": "mdi:cash",
"func": lambda js : js['gasmeter']['energy']['import']['price']['unitrate'],
"ignore_zero_values": True,
Expand All @@ -233,7 +233,7 @@
"name": "Smart Meter Gas: Import Standing Charge",
"device_class": SensorDeviceClass.MONETARY,
"unit_of_measurement": "GBP",
"state_class": SensorStateClass.MEASUREMENT,
"state_class": None,
"icon": "mdi:cash",
"func": lambda js : js['gasmeter']['energy']['import']['price']['standingcharge'],
"ignore_zero_values": True,
Expand All @@ -251,7 +251,7 @@
"name": "Smart Meter Gas: Cost (Today)",
"device_class": SensorDeviceClass.MONETARY,
"unit_of_measurement": "GBP",
"state_class": SensorStateClass.TOTAL_INCREASING,
"state_class": None,
"icon": "mdi:cash",
"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),
Expand Down Expand Up @@ -339,9 +339,12 @@ def __init__(self, device_id, name, icon, device_class, unit_of_measurement, sta
self._attr_name = name
self._attr_unique_id = slugify(device_id + "_" + name)
self._attr_icon = icon
self._attr_device_class = device_class
self._attr_native_unit_of_measurement = unit_of_measurement
self._attr_state_class = state_class
if (device_class):
self._attr_device_class = device_class
if (unit_of_measurement):
self._attr_native_unit_of_measurement = unit_of_measurement
if (state_class):
self._attr_state_class = state_class
self._attr_entity_category = entity_category
self._attr_should_poll = False

Expand Down

0 comments on commit af03465

Please sign in to comment.