Remove door state from Whirlpool machine state sensor

Breaking change: The door state is now reported as a binary sensor instead of being part of the main machine state sensor, which now reports only the cycle states. Users relying on this state in automations or scripts will need to update their configurations to use the new binary sensor.
This commit is contained in:
abmantis
2025-05-01 22:54:04 +01:00
parent 883ab44437
commit c469720166
4 changed files with 2 additions and 46 deletions

View File

@@ -61,15 +61,11 @@ STATE_CYCLE_SENSING = "cycle_sensing"
STATE_CYCLE_SOAKING = "cycle_soaking"
STATE_CYCLE_SPINNING = "cycle_spinning"
STATE_CYCLE_WASHING = "cycle_washing"
STATE_DOOR_OPEN = "door_open"
def washer_dryer_state(washer_dryer: WasherDryer) -> str | None:
"""Determine correct states for a washer/dryer."""
if washer_dryer.get_door_open():
return STATE_DOOR_OPEN
machine_state = washer_dryer.get_machine_state()
if machine_state == MachineState.RunningMainCycle:
@@ -104,7 +100,6 @@ WASHER_DRYER_STATE_OPTIONS = [
STATE_CYCLE_SOAKING,
STATE_CYCLE_SPINNING,
STATE_CYCLE_WASHING,
STATE_DOOR_OPEN,
]
WASHER_SENSORS: tuple[WhirlpoolSensorEntityDescription, ...] = (

View File

@@ -74,8 +74,7 @@
"cycle_sensing": "Cycle sensing",
"cycle_soaking": "Cycle soaking",
"cycle_spinning": "Cycle spinning",
"cycle_washing": "Cycle washing",
"door_open": "Door open"
"cycle_washing": "Cycle washing"
}
},
"dryer_state": {
@@ -105,8 +104,7 @@
"cycle_sensing": "[%key:component::whirlpool::entity::sensor::washer_state::state::cycle_sensing%]",
"cycle_soaking": "[%key:component::whirlpool::entity::sensor::washer_state::state::cycle_soaking%]",
"cycle_spinning": "[%key:component::whirlpool::entity::sensor::washer_state::state::cycle_spinning%]",
"cycle_washing": "[%key:component::whirlpool::entity::sensor::washer_state::state::cycle_washing%]",
"door_open": "[%key:component::whirlpool::entity::sensor::washer_state::state::door_open%]"
"cycle_washing": "[%key:component::whirlpool::entity::sensor::washer_state::state::cycle_washing%]"
}
},
"whirlpool_tank": {

View File

@@ -80,7 +80,6 @@
'cycle_soaking',
'cycle_spinning',
'cycle_washing',
'door_open',
]),
}),
'config_entry_id': <ANY>,
@@ -142,7 +141,6 @@
'cycle_soaking',
'cycle_spinning',
'cycle_washing',
'door_open',
]),
}),
'context': <ANY>,
@@ -297,7 +295,6 @@
'cycle_soaking',
'cycle_spinning',
'cycle_washing',
'door_open',
]),
}),
'config_entry_id': <ANY>,
@@ -359,7 +356,6 @@
'cycle_soaking',
'cycle_spinning',
'cycle_washing',
'door_open',
]),
}),
'context': <ANY>,

View File

@@ -256,39 +256,6 @@ async def test_washer_dryer_running_states(
assert state.state == expected_state
@pytest.mark.parametrize(
("entity_id", "mock_fixture"),
[
("sensor.washer_state", "mock_washer_api"),
("sensor.dryer_state", "mock_dryer_api"),
],
)
async def test_washer_dryer_door_open_state(
hass: HomeAssistant,
entity_id: str,
mock_fixture: str,
request: pytest.FixtureRequest,
) -> None:
"""Test Washer/Dryer machine state when door is open."""
mock_instance = request.getfixturevalue(mock_fixture)
await init_integration(hass)
state = hass.states.get(entity_id)
assert state.state == "running_maincycle"
mock_instance.get_door_open.return_value = True
await trigger_attr_callback(hass, mock_instance)
state = hass.states.get(entity_id)
assert state.state == "door_open"
mock_instance.get_door_open.return_value = False
await trigger_attr_callback(hass, mock_instance)
state = hass.states.get(entity_id)
assert state.state == "running_maincycle"
@pytest.mark.parametrize(
("entity_id", "mock_fixture", "mock_method_name", "values"),
[