Skip to content

Commit

Permalink
Merge pull request #410 from maxyvon/link_energysensor_devices
Browse files Browse the repository at this point in the history
Link energysensor devices
  • Loading branch information
ic-dev21 authored Apr 5, 2024
2 parents 8c66ce1 + e368124 commit f577439
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion custom_components/hilo/sensor.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Support for various Hilo sensors."""

from __future__ import annotations

from datetime import datetime, timedelta, timezone
Expand All @@ -24,6 +25,7 @@
UnitOfTemperature,
)
from homeassistant.core import HomeAssistant
from homeassistant.helpers.device_registry import DeviceInfo
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.restore_state import RestoreEntity
from homeassistant.util import Throttle, slugify
Expand Down Expand Up @@ -255,7 +257,6 @@ 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_icon = "mdi:lightning-bolt"

def __init__(self, hilo, device):
self._device = device
Expand All @@ -275,6 +276,9 @@ def __init__(self, hilo, device):
initial_state = 0
self._attr_native_value = initial_state
self._attr_last_valid_state = initial_state
self._device_info = DeviceInfo(
identifiers={(DOMAIN, self._device.identifier)},
)

super().__init__(
integration_method=METHOD_LEFT,
Expand All @@ -284,7 +288,9 @@ def __init__(self, hilo, device):
unique_id=self._attr_unique_id,
unit_prefix="k",
unit_time="h",
device_info=self._device_info,
)
self._attr_icon = "mdi:lightning-bolt"
LOG.debug(
f"Setting up EnergySensor entity: {self._attr_name} with source {self._source}"
)
Expand Down

0 comments on commit f577439

Please sign in to comment.