diff --git a/homeassistant/components/miele/const.py b/homeassistant/components/miele/const.py index bda276c6d8a..fd2f8631cd2 100644 --- a/homeassistant/components/miele/const.py +++ b/homeassistant/components/miele/const.py @@ -1294,3 +1294,30 @@ STATE_PROGRAM_ID: dict[int, dict[int, str]] = { MieleAppliance.ROBOT_VACUUM_CLEANER: ROBOT_VACUUM_CLEANER_PROGRAM_ID, MieleAppliance.COFFEE_SYSTEM: COFFEE_SYSTEM_PROGRAM_ID, } + + +class PlatePowerStep(MieleEnum): + """Plate power settings.""" + + plate_step_0 = 0 + plate_step_warming = 110, 220 + plate_step_1 = 1 + plate_step_2 = 2 + plate_step_3 = 3 + plate_step_4 = 4 + plate_step_5 = 5 + plate_step_6 = 6 + plate_step_7 = 7 + plate_step_8 = 8 + plate_step_9 = 9 + plate_step_10 = 10 + plate_step_11 = 11 + plate_step_12 = 12 + plate_step_13 = 13 + plate_step_14 = 4 + plate_step_15 = 15 + plate_step_16 = 16 + plate_step_17 = 17 + plate_step_18 = 18 + plate_step_boost = 117, 118, 218 + missing2none = -9999 diff --git a/homeassistant/components/miele/icons.json b/homeassistant/components/miele/icons.json index 1806fe688d6..44b51a67c24 100644 --- a/homeassistant/components/miele/icons.json +++ b/homeassistant/components/miele/icons.json @@ -56,30 +56,27 @@ "plate": { "default": "mdi:circle-outline", "state": { - "0": "mdi:circle-outline", - "110": "mdi:alpha-w-circle-outline", - "220": "mdi:alpha-w-circle-outline", - "1": "mdi:circle-slice-1", - "2": "mdi:circle-slice-1", - "3": "mdi:circle-slice-2", - "4": "mdi:circle-slice-2", - "5": "mdi:circle-slice-3", - "6": "mdi:circle-slice-3", - "7": "mdi:circle-slice-4", - "8": "mdi:circle-slice-4", - "9": "mdi:circle-slice-5", - "10": "mdi:circle-slice-5", - "11": "mdi:circle-slice-5", - "12": "mdi:circle-slice-6", - "13": "mdi:circle-slice-6", - "14": "mdi:circle-slice-6", - "15": "mdi:circle-slice-7", - "16": "mdi:circle-slice-7", - "17": "mdi:circle-slice-8", - "18": "mdi:circle-slice-8", - "117": "mdi:alpha-b-circle-outline", - "118": "mdi:alpha-b-circle-outline", - "217": "mdi:alpha-b-circle-outline" + "plate_step_0": "mdi:circle-outline", + "plate_step_warming": "mdi:alpha-w-circle-outline", + "plate_step_1": "mdi:circle-slice-1", + "plate_step_2": "mdi:circle-slice-1", + "plate_step_3": "mdi:circle-slice-2", + "plate_step_4": "mdi:circle-slice-2", + "plate_step_5": "mdi:circle-slice-3", + "plate_step_6": "mdi:circle-slice-3", + "plate_step_7": "mdi:circle-slice-4", + "plate_step_8": "mdi:circle-slice-4", + "plate_step_9": "mdi:circle-slice-5", + "plate_step_10": "mdi:circle-slice-5", + "plate_step_11": "mdi:circle-slice-5", + "plate_step_12": "mdi:circle-slice-6", + "plate_step_13": "mdi:circle-slice-6", + "plate_step_14": "mdi:circle-slice-6", + "plate_step_15": "mdi:circle-slice-7", + "plate_step_16": "mdi:circle-slice-7", + "plate_step_17": "mdi:circle-slice-8", + "plate_step_18": "mdi:circle-slice-8", + "plate_step_boost": "mdi:alpha-b-circle-outline" } }, "program_type": { diff --git a/homeassistant/components/miele/sensor.py b/homeassistant/components/miele/sensor.py index d5085ae606f..ff72b791735 100644 --- a/homeassistant/components/miele/sensor.py +++ b/homeassistant/components/miele/sensor.py @@ -33,6 +33,7 @@ from .const import ( STATE_PROGRAM_PHASE, STATE_STATUS_TAGS, MieleAppliance, + PlatePowerStep, StateDryingStep, StateProgramType, StateStatus, @@ -46,34 +47,6 @@ _LOGGER = logging.getLogger(__name__) DISABLED_TEMPERATURE = -32768 -PLATE_POWERS = [ - "0", - "110", - "220", - "1", - "2", - "3", - "4", - "5", - "6", - "7", - "8", - "9", - "10", - "11", - "12", - "13", - "14", - "15", - "16", - "17", - "18", - "117", - "118", - "217", -] - - DEFAULT_PLATE_COUNT = 4 PLATE_COUNT = { @@ -543,8 +516,8 @@ SENSOR_TYPES: Final[tuple[MieleSensorDefinition, ...]] = ( translation_placeholders={"plate_no": str(i)}, zone=i, device_class=SensorDeviceClass.ENUM, - options=PLATE_POWERS, - value_fn=lambda value: value.state_plate_step[0].value_raw, + options=sorted(PlatePowerStep.keys()), + value_fn=lambda value: None, ), ) for i in range(1, 7) @@ -683,12 +656,19 @@ class MielePlateSensor(MieleSensor): def native_value(self) -> StateType: """Return the state of the plate sensor.""" # state_plate_step is [] if all zones are off - plate_power = ( - self.device.state_plate_step[self.entity_description.zone - 1].value_raw + + return ( + PlatePowerStep( + cast( + int, + self.device.state_plate_step[ + self.entity_description.zone - 1 + ].value_raw, + ) + ).name if self.device.state_plate_step - else 0 + else PlatePowerStep.plate_step_0 ) - return str(plate_power) class MieleStatusSensor(MieleSensor): diff --git a/homeassistant/components/miele/strings.json b/homeassistant/components/miele/strings.json index 94aef8d6d3f..97035da6d5f 100644 --- a/homeassistant/components/miele/strings.json +++ b/homeassistant/components/miele/strings.json @@ -203,30 +203,27 @@ "plate": { "name": "Plate {plate_no}", "state": { - "0": "0", - "110": "Warming", - "220": "[%key:component::miele::entity::sensor::plate::state::110%]", - "1": "1", - "2": "1\u2022", - "3": "2", - "4": "2\u2022", - "5": "3", - "6": "3\u2022", - "7": "4", - "8": "4\u2022", - "9": "5", - "10": "5\u2022", - "11": "6", - "12": "6\u2022", - "13": "7", - "14": "7\u2022", - "15": "8", - "16": "8\u2022", - "17": "9", - "18": "9\u2022", - "117": "Boost", - "118": "[%key:component::miele::entity::sensor::plate::state::117%]", - "217": "[%key:component::miele::entity::sensor::plate::state::117%]" + "power_step_0": "0", + "power_step_warm": "Warming", + "power_step_1": "1", + "power_step_2": "1\u2022", + "power_step_3": "2", + "power_step_4": "2\u2022", + "power_step_5": "3", + "power_step_6": "3\u2022", + "power_step_7": "4", + "power_step_8": "4\u2022", + "power_step_9": "5", + "power_step_10": "5\u2022", + "power_step_11": "6", + "power_step_12": "6\u2022", + "power_step_13": "7", + "power_step_14": "7\u2022", + "power_step_15": "8", + "power_step_16": "8\u2022", + "power_step_17": "9", + "power_step_18": "9\u2022", + "power_step_boost": "Boost" } }, "drying_step": { diff --git a/tests/components/miele/snapshots/test_sensor.ambr b/tests/components/miele/snapshots/test_sensor.ambr index 6984fcc4c50..b1691c28b19 100644 --- a/tests/components/miele/snapshots/test_sensor.ambr +++ b/tests/components/miele/snapshots/test_sensor.ambr @@ -97,30 +97,26 @@ 'area_id': None, 'capabilities': dict({ 'options': list([ - '0', - '110', - '220', - '1', - '2', - '3', - '4', - '5', - '6', - '7', - '8', - '9', - '10', - '11', - '12', - '13', - '14', - '15', - '16', - '17', - '18', - '117', - '118', - '217', + 'plate_step_0', + 'plate_step_1', + 'plate_step_10', + 'plate_step_11', + 'plate_step_12', + 'plate_step_13', + 'plate_step_15', + 'plate_step_16', + 'plate_step_17', + 'plate_step_18', + 'plate_step_2', + 'plate_step_3', + 'plate_step_4', + 'plate_step_5', + 'plate_step_6', + 'plate_step_7', + 'plate_step_8', + 'plate_step_9', + 'plate_step_boost', + 'plate_step_warming', ]), }), 'config_entry_id': , @@ -158,30 +154,26 @@ 'device_class': 'enum', 'friendly_name': 'Hob with extraction Plate 1', 'options': list([ - '0', - '110', - '220', - '1', - '2', - '3', - '4', - '5', - '6', - '7', - '8', - '9', - '10', - '11', - '12', - '13', - '14', - '15', - '16', - '17', - '18', - '117', - '118', - '217', + 'plate_step_0', + 'plate_step_1', + 'plate_step_10', + 'plate_step_11', + 'plate_step_12', + 'plate_step_13', + 'plate_step_15', + 'plate_step_16', + 'plate_step_17', + 'plate_step_18', + 'plate_step_2', + 'plate_step_3', + 'plate_step_4', + 'plate_step_5', + 'plate_step_6', + 'plate_step_7', + 'plate_step_8', + 'plate_step_9', + 'plate_step_boost', + 'plate_step_warming', ]), }), 'context': , @@ -189,7 +181,7 @@ 'last_changed': , 'last_reported': , 'last_updated': , - 'state': '0', + 'state': 'plate_step_0', }) # --- # name: test_hob_sensor_states[platforms0-hob.json][sensor.hob_with_extraction_plate_2-entry] @@ -199,30 +191,26 @@ 'area_id': None, 'capabilities': dict({ 'options': list([ - '0', - '110', - '220', - '1', - '2', - '3', - '4', - '5', - '6', - '7', - '8', - '9', - '10', - '11', - '12', - '13', - '14', - '15', - '16', - '17', - '18', - '117', - '118', - '217', + 'plate_step_0', + 'plate_step_1', + 'plate_step_10', + 'plate_step_11', + 'plate_step_12', + 'plate_step_13', + 'plate_step_15', + 'plate_step_16', + 'plate_step_17', + 'plate_step_18', + 'plate_step_2', + 'plate_step_3', + 'plate_step_4', + 'plate_step_5', + 'plate_step_6', + 'plate_step_7', + 'plate_step_8', + 'plate_step_9', + 'plate_step_boost', + 'plate_step_warming', ]), }), 'config_entry_id': , @@ -260,30 +248,26 @@ 'device_class': 'enum', 'friendly_name': 'Hob with extraction Plate 2', 'options': list([ - '0', - '110', - '220', - '1', - '2', - '3', - '4', - '5', - '6', - '7', - '8', - '9', - '10', - '11', - '12', - '13', - '14', - '15', - '16', - '17', - '18', - '117', - '118', - '217', + 'plate_step_0', + 'plate_step_1', + 'plate_step_10', + 'plate_step_11', + 'plate_step_12', + 'plate_step_13', + 'plate_step_15', + 'plate_step_16', + 'plate_step_17', + 'plate_step_18', + 'plate_step_2', + 'plate_step_3', + 'plate_step_4', + 'plate_step_5', + 'plate_step_6', + 'plate_step_7', + 'plate_step_8', + 'plate_step_9', + 'plate_step_boost', + 'plate_step_warming', ]), }), 'context': , @@ -291,7 +275,7 @@ 'last_changed': , 'last_reported': , 'last_updated': , - 'state': '110', + 'state': 'plate_step_warming', }) # --- # name: test_hob_sensor_states[platforms0-hob.json][sensor.hob_with_extraction_plate_3-entry] @@ -301,30 +285,26 @@ 'area_id': None, 'capabilities': dict({ 'options': list([ - '0', - '110', - '220', - '1', - '2', - '3', - '4', - '5', - '6', - '7', - '8', - '9', - '10', - '11', - '12', - '13', - '14', - '15', - '16', - '17', - '18', - '117', - '118', - '217', + 'plate_step_0', + 'plate_step_1', + 'plate_step_10', + 'plate_step_11', + 'plate_step_12', + 'plate_step_13', + 'plate_step_15', + 'plate_step_16', + 'plate_step_17', + 'plate_step_18', + 'plate_step_2', + 'plate_step_3', + 'plate_step_4', + 'plate_step_5', + 'plate_step_6', + 'plate_step_7', + 'plate_step_8', + 'plate_step_9', + 'plate_step_boost', + 'plate_step_warming', ]), }), 'config_entry_id': , @@ -362,30 +342,26 @@ 'device_class': 'enum', 'friendly_name': 'Hob with extraction Plate 3', 'options': list([ - '0', - '110', - '220', - '1', - '2', - '3', - '4', - '5', - '6', - '7', - '8', - '9', - '10', - '11', - '12', - '13', - '14', - '15', - '16', - '17', - '18', - '117', - '118', - '217', + 'plate_step_0', + 'plate_step_1', + 'plate_step_10', + 'plate_step_11', + 'plate_step_12', + 'plate_step_13', + 'plate_step_15', + 'plate_step_16', + 'plate_step_17', + 'plate_step_18', + 'plate_step_2', + 'plate_step_3', + 'plate_step_4', + 'plate_step_5', + 'plate_step_6', + 'plate_step_7', + 'plate_step_8', + 'plate_step_9', + 'plate_step_boost', + 'plate_step_warming', ]), }), 'context': , @@ -393,7 +369,7 @@ 'last_changed': , 'last_reported': , 'last_updated': , - 'state': '8', + 'state': 'plate_step_8', }) # --- # name: test_hob_sensor_states[platforms0-hob.json][sensor.hob_with_extraction_plate_4-entry] @@ -403,30 +379,26 @@ 'area_id': None, 'capabilities': dict({ 'options': list([ - '0', - '110', - '220', - '1', - '2', - '3', - '4', - '5', - '6', - '7', - '8', - '9', - '10', - '11', - '12', - '13', - '14', - '15', - '16', - '17', - '18', - '117', - '118', - '217', + 'plate_step_0', + 'plate_step_1', + 'plate_step_10', + 'plate_step_11', + 'plate_step_12', + 'plate_step_13', + 'plate_step_15', + 'plate_step_16', + 'plate_step_17', + 'plate_step_18', + 'plate_step_2', + 'plate_step_3', + 'plate_step_4', + 'plate_step_5', + 'plate_step_6', + 'plate_step_7', + 'plate_step_8', + 'plate_step_9', + 'plate_step_boost', + 'plate_step_warming', ]), }), 'config_entry_id': , @@ -464,30 +436,26 @@ 'device_class': 'enum', 'friendly_name': 'Hob with extraction Plate 4', 'options': list([ - '0', - '110', - '220', - '1', - '2', - '3', - '4', - '5', - '6', - '7', - '8', - '9', - '10', - '11', - '12', - '13', - '14', - '15', - '16', - '17', - '18', - '117', - '118', - '217', + 'plate_step_0', + 'plate_step_1', + 'plate_step_10', + 'plate_step_11', + 'plate_step_12', + 'plate_step_13', + 'plate_step_15', + 'plate_step_16', + 'plate_step_17', + 'plate_step_18', + 'plate_step_2', + 'plate_step_3', + 'plate_step_4', + 'plate_step_5', + 'plate_step_6', + 'plate_step_7', + 'plate_step_8', + 'plate_step_9', + 'plate_step_boost', + 'plate_step_warming', ]), }), 'context': , @@ -495,7 +463,7 @@ 'last_changed': , 'last_reported': , 'last_updated': , - 'state': '15', + 'state': 'plate_step_15', }) # --- # name: test_hob_sensor_states[platforms0-hob.json][sensor.hob_with_extraction_plate_5-entry] @@ -505,30 +473,26 @@ 'area_id': None, 'capabilities': dict({ 'options': list([ - '0', - '110', - '220', - '1', - '2', - '3', - '4', - '5', - '6', - '7', - '8', - '9', - '10', - '11', - '12', - '13', - '14', - '15', - '16', - '17', - '18', - '117', - '118', - '217', + 'plate_step_0', + 'plate_step_1', + 'plate_step_10', + 'plate_step_11', + 'plate_step_12', + 'plate_step_13', + 'plate_step_15', + 'plate_step_16', + 'plate_step_17', + 'plate_step_18', + 'plate_step_2', + 'plate_step_3', + 'plate_step_4', + 'plate_step_5', + 'plate_step_6', + 'plate_step_7', + 'plate_step_8', + 'plate_step_9', + 'plate_step_boost', + 'plate_step_warming', ]), }), 'config_entry_id': , @@ -566,30 +530,26 @@ 'device_class': 'enum', 'friendly_name': 'Hob with extraction Plate 5', 'options': list([ - '0', - '110', - '220', - '1', - '2', - '3', - '4', - '5', - '6', - '7', - '8', - '9', - '10', - '11', - '12', - '13', - '14', - '15', - '16', - '17', - '18', - '117', - '118', - '217', + 'plate_step_0', + 'plate_step_1', + 'plate_step_10', + 'plate_step_11', + 'plate_step_12', + 'plate_step_13', + 'plate_step_15', + 'plate_step_16', + 'plate_step_17', + 'plate_step_18', + 'plate_step_2', + 'plate_step_3', + 'plate_step_4', + 'plate_step_5', + 'plate_step_6', + 'plate_step_7', + 'plate_step_8', + 'plate_step_9', + 'plate_step_boost', + 'plate_step_warming', ]), }), 'context': , @@ -597,7 +557,7 @@ 'last_changed': , 'last_reported': , 'last_updated': , - 'state': '117', + 'state': 'plate_step_boost', }) # --- # name: test_sensor_states[platforms0][sensor.freezer-entry]