From 5eb6f646237ad678673681792fb221799ed38928 Mon Sep 17 00:00:00 2001 From: maxyvon Date: Thu, 4 Apr 2024 19:04:08 -0400 Subject: [PATCH 1/2] =?UTF-8?q?Link=20le=20sensor=20d'energy=20=C3=A0=20so?= =?UTF-8?q?n=20device?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- custom_components/hilo/sensor.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/custom_components/hilo/sensor.py b/custom_components/hilo/sensor.py index 9522670..2c17d34 100755 --- a/custom_components/hilo/sensor.py +++ b/custom_components/hilo/sensor.py @@ -1,4 +1,5 @@ """Support for various Hilo sensors.""" + from __future__ import annotations from datetime import datetime, timedelta, timezone @@ -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 @@ -275,6 +277,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, @@ -284,6 +289,7 @@ def __init__(self, hilo, device): unique_id=self._attr_unique_id, unit_prefix="k", unit_time="h", + device_info=self._device_info, ) LOG.debug( f"Setting up EnergySensor entity: {self._attr_name} with source {self._source}" From e36812482260f5925937f75cb58e74762dc296cf Mon Sep 17 00:00:00 2001 From: maxyvon Date: Thu, 4 Apr 2024 19:06:31 -0400 Subject: [PATCH 2/2] =?UTF-8?q?D=C3=A9placer=20l'assignation=20de=20l'icon?= =?UTF-8?q?=20apr=C3=A8s=20l'init=20de=20IntegrationSensor?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- custom_components/hilo/sensor.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/custom_components/hilo/sensor.py b/custom_components/hilo/sensor.py index 2c17d34..a31a934 100755 --- a/custom_components/hilo/sensor.py +++ b/custom_components/hilo/sensor.py @@ -257,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 @@ -291,6 +290,7 @@ def __init__(self, hilo, device): 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}" )