From c0aac16e379f968dd868932c2327bec033bad47b Mon Sep 17 00:00:00 2001 From: Bastian Neumann Date: Fri, 30 May 2025 15:23:50 +0000 Subject: [PATCH 1/2] fix: handle charger connection status in battery range sensor --- custom_components/smarthashtag/sensor.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/custom_components/smarthashtag/sensor.py b/custom_components/smarthashtag/sensor.py index 4063ba2..4d04457 100644 --- a/custom_components/smarthashtag/sensor.py +++ b/custom_components/smarthashtag/sensor.py @@ -1104,6 +1104,8 @@ def native_unit_of_measurement(self) -> str: ) if "charging_status" in self.entity_description.key: return None + if "charger_connection_status" in self.entity_description.key: + return None if isinstance(data, ValueWithUnit): return data.unit From 9206e98073a58a60375fce6432e9d1ea743bf80a Mon Sep 17 00:00:00 2001 From: Bastian Neumann Date: Fri, 30 May 2025 16:22:20 +0000 Subject: [PATCH 2/2] fix: move charger connection status to binary sensor --- custom_components/smarthashtag/binary_sensor.py | 8 ++++++++ custom_components/smarthashtag/sensor.py | 6 ------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/custom_components/smarthashtag/binary_sensor.py b/custom_components/smarthashtag/binary_sensor.py index 5ae4ce2..bde3fc1 100644 --- a/custom_components/smarthashtag/binary_sensor.py +++ b/custom_components/smarthashtag/binary_sensor.py @@ -138,6 +138,14 @@ class SmartHashtagBinarySensorEntityDescription(BinarySensorEntityDescription): icon="mdi:car-back", is_on_fn=lambda state, key: state.safety.trunk_open_status == 1, ), + SmartHashtagBinarySensorEntityDescription( + key="is_charger_connected", + translation_key="is_charger_connected", + name="is charger connected", + device_class=BinarySensorDeviceClass.BATTERY_CHARGING, + icon="mdi:power-plug-battery", + is_on_fn=lambda state, key: state.battery.is_charger_connected, + ), ) diff --git a/custom_components/smarthashtag/sensor.py b/custom_components/smarthashtag/sensor.py index 4d04457..1f89858 100644 --- a/custom_components/smarthashtag/sensor.py +++ b/custom_components/smarthashtag/sensor.py @@ -86,12 +86,6 @@ device_class=SensorDeviceClass.ENUM, entity_registry_enabled_default=False, ), - SensorEntityDescription( - key="is_charger_connected", - translation_key="is_charger_connected", - name="is charger connected", - icon="mdi:power-plug-battery", - ), SensorEntityDescription( key="charging_voltage", translation_key="charging_voltage",