From 9abb4ffc97ee418ecd78eab5e8b86e349bfc9436 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=85ke=20Strandberg?= Date: Fri, 9 May 2025 11:52:30 +0200 Subject: [PATCH] Add drying step sensor for Miele tumble dryers (#144515) Add drying step sensor for tumple dryers --- homeassistant/components/miele/const.py | 14 ++++++++++++++ homeassistant/components/miele/icons.json | 3 +++ homeassistant/components/miele/sensor.py | 18 ++++++++++++++++++ homeassistant/components/miele/strings.json | 13 +++++++++++++ 4 files changed, 48 insertions(+) diff --git a/homeassistant/components/miele/const.py b/homeassistant/components/miele/const.py index 1802c6c9cd0..69e0ab1876e 100644 --- a/homeassistant/components/miele/const.py +++ b/homeassistant/components/miele/const.py @@ -339,6 +339,20 @@ class StateProgramType(MieleEnum): unknown = -9999 +class StateDryingStep(MieleEnum): + """Defines drying steps.""" + + extra_dry = 0 + normal_plus = 1 + normal = 2 + slightly_dry = 3 + hand_iron_1 = 4 + hand_iron_2 = 5 + machine_iron = 6 + smoothing = 7 + unknown = -9999 + + WASHING_MACHINE_PROGRAM_ID: dict[int, str] = { -1: "no_program", # Extrapolated from other device types. 0: "no_program", # Returned by the API when no program is selected. diff --git a/homeassistant/components/miele/icons.json b/homeassistant/components/miele/icons.json index a0fb1daaedd..02374a10f90 100644 --- a/homeassistant/components/miele/icons.json +++ b/homeassistant/components/miele/icons.json @@ -32,6 +32,9 @@ "core_target_temperature": { "default": "mdi:thermometer-probe" }, + "drying_step": { + "default": "mdi:water-outline" + }, "program_id": { "default": "mdi:selection-ellipse-arrow-inside" }, diff --git a/homeassistant/components/miele/sensor.py b/homeassistant/components/miele/sensor.py index 12f035485be..22a7916d892 100644 --- a/homeassistant/components/miele/sensor.py +++ b/homeassistant/components/miele/sensor.py @@ -32,6 +32,7 @@ from .const import ( STATE_PROGRAM_PHASE, STATE_STATUS_TAGS, MieleAppliance, + StateDryingStep, StateProgramType, StateStatus, ) @@ -416,6 +417,23 @@ SENSOR_TYPES: Final[tuple[MieleSensorDefinition, ...]] = ( ), ), ), + MieleSensorDefinition( + types=( + MieleAppliance.WASHER_DRYER, + MieleAppliance.TUMBLE_DRYER, + MieleAppliance.TUMBLE_DRYER_SEMI_PROFESSIONAL, + ), + description=MieleSensorDescription( + key="state_drying_step", + translation_key="drying_step", + value_fn=lambda value: StateDryingStep( + cast(int, value.state_drying_step) + ).name, + entity_category=EntityCategory.DIAGNOSTIC, + device_class=SensorDeviceClass.ENUM, + options=sorted(StateDryingStep.keys()), + ), + ), ) diff --git a/homeassistant/components/miele/strings.json b/homeassistant/components/miele/strings.json index 7962f887e4f..764fc76a877 100644 --- a/homeassistant/components/miele/strings.json +++ b/homeassistant/components/miele/strings.json @@ -191,6 +191,19 @@ "energy_consumption": { "name": "Energy consumption" }, + "drying_step": { + "name": "Drying step", + "state": { + "extra_dry": "Extra dry", + "hand_iron_1": "Hand iron 1", + "hand_iron_2": "Hand iron 2", + "machine_iron": "Machine iron", + "normal_plus": "Normal plus", + "normal": "Normal", + "slightly_dry": "Slightly dry", + "smoothing": "Smoothing" + } + }, "program_phase": { "name": "Program phase", "state": {