Skip to content

Commit

Permalink
Merge pull request #432 from FrancoLoco/main
Browse files Browse the repository at this point in the history
Fix Unit conversion now fails in 2024.6-rc #431
  • Loading branch information
ic-dev21 authored Jun 4, 2024
2 parents 911905b + e65807d commit b362c94
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion custom_components/hilo/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@ class EnergySensor(IntegrationSensor):
_attr_native_unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR
_attr_state_class = SensorStateClass.TOTAL_INCREASING
_attr_unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR
_attr_suggested_display_precision = 2
_attr_icon = "mdi:lightning-bolt"

def __init__(self, hilo, device):
Expand All @@ -277,7 +278,7 @@ def __init__(self, hilo, device):
old_unique_id, self._attr_unique_id, Platform.SENSOR
)
self._unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR
self._unit_prefix = None
self._suggested_display_precision = 2

if device.type == "Meter":
self._attr_name = HILO_ENERGY_TOTAL
Expand All @@ -300,6 +301,9 @@ def __init__(self, hilo, device):
unit_time="h",
device_info=self._device_info,
)
self._unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR
self._suggested_display_precision = 2

self._attr_icon = "mdi:lightning-bolt"
LOG.debug(
f"Setting up EnergySensor entity: {self._attr_name} with source {self._source}"
Expand All @@ -309,6 +313,10 @@ def __init__(self, hilo, device):
def unit_of_measurement(self):
return self._attr_unit_of_measurement

@property
def suggested_display_precision(self):
return self._attr_suggested_display_precision

async def async_added_to_hass(self) -> None:
"""Handle entity which will be added."""
LOG.debug(f"Added to hass: {self._attr_name}")
Expand Down

0 comments on commit b362c94

Please sign in to comment.