diff --git a/custom_components/dyson_local/sensor.py b/custom_components/dyson_local/sensor.py index 06d479d..add6ca6 100644 --- a/custom_components/dyson_local/sensor.py +++ b/custom_components/dyson_local/sensor.py @@ -59,6 +59,7 @@ async def async_setup_entry( entities.extend( [ DysonFilterLifeSensor(device, name), + DysonFilterLifeSensorPercentage(device, name), DysonParticulatesSensor(coordinator, device, name), ] ) @@ -154,6 +155,22 @@ def native_value(self) -> int: return self._device.filter_life +class DysonFilterLifeSensorPercentage(DysonSensor): + """Dyson filter life sensor (in percentage) for Pure Cool Link.""" + + _SENSOR_TYPE = "filter_life_percentage" + _SENSOR_NAME = "Filter Life Percentage" + _attr_entity_category = EntityCategory.DIAGNOSTIC + _attr_icon = "mdi:filter-outline" + _attr_native_unit_of_measurement = PERCENTAGE + _attr_suggested_display_precision = 0 + + @property + def native_value(self) -> float: + """Return the state of the sensor calculated to a %.""" + return (self._device.filter_life / 4300) * 100 + + class DysonCarbonFilterLifeSensor(DysonSensor): """Dyson carbon filter life sensor (in percentage) for Pure Cool."""