From 09d79e20320ce3ebc05aa6730d3a836ff7c11893 Mon Sep 17 00:00:00 2001 From: schizza Date: Mon, 18 Aug 2025 12:50:31 +0200 Subject: [PATCH] Improves battery sensor display Updates the outside battery sensor to display an icon reflecting the battery level, enhancing the user experience by providing a visual indication of the battery status. --- custom_components/sws12500/sensors_wslink.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/custom_components/sws12500/sensors_wslink.py b/custom_components/sws12500/sensors_wslink.py index 50f8b2a..9144d83 100644 --- a/custom_components/sws12500/sensors_wslink.py +++ b/custom_components/sws12500/sensors_wslink.py @@ -46,7 +46,7 @@ from .const import ( WEEKLY_RAIN, ) from .sensors_common import WeatherSensorEntityDescription -from .utils import battery_level_to_text, wind_dir_to_text +from .utils import battery_level_to_icon, battery_level_to_text, wind_dir_to_text SENSOR_TYPES_WSLINK: tuple[WeatherSensorEntityDescription, ...] = ( WeatherSensorEntityDescription( @@ -306,10 +306,9 @@ SENSOR_TYPES_WSLINK: tuple[WeatherSensorEntityDescription, ...] = ( ), WeatherSensorEntityDescription( key=OUTSIDE_BATTERY, - name="Outside Battery", - icon="mdi:battery", - device_class=SensorDeviceClass.ENUM, - value_fn=lambda data: battery_level_to_text(int(data)) if data is not None and str(data).isdigit() else "unknown", translation_key=OUTSIDE_BATTERY, + icon=lambda data: battery_level_to_icon(battery_level_to_text(int(data))), + device_class=SensorDeviceClass.ENUM, + value_fn=lambda data: battery_level_to_text(int(data)), ), )