mirror of
https://github.com/home-assistant/core.git
synced 2026-12-02 11:33:11 -04:00
Refuse Whirlpool oven cook mode changes while cooking (#195882)
Co-authored-by: armandkd <4838021+armandkd@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
armandkd
Claude Opus 5.5
parent
e2e9099031
commit
0ba123bebb
@@ -139,6 +139,14 @@ class WhirlpoolOvenCookModeSelect(WhirlpoolOvenEntity, SelectEntity):
|
||||
# the current cook, not by starting a "standby" cook.
|
||||
result = await self._appliance.stop_cook(self.cavity)
|
||||
else:
|
||||
current = self._appliance.get_cook_mode(self.cavity)
|
||||
if current not in (None, CookMode.Standby, mode):
|
||||
# Like the Whirlpool app, the oven doesn't change the mode
|
||||
# of a running cook: it ignores the command.
|
||||
raise ServiceValidationError(
|
||||
translation_domain=DOMAIN,
|
||||
translation_key="cook_mode_change_while_cooking",
|
||||
)
|
||||
target = self._appliance.get_target_temp(self.cavity)
|
||||
if target is None:
|
||||
target = DEFAULT_OVEN_TEMP
|
||||
|
||||
@@ -290,6 +290,9 @@
|
||||
"cannot_connect": {
|
||||
"message": "[%key:common::config_flow::error::cannot_connect%]"
|
||||
},
|
||||
"cook_mode_change_while_cooking": {
|
||||
"message": "The cook mode cannot be changed while the oven is cooking. Stop the current cook first."
|
||||
},
|
||||
"invalid_auth": {
|
||||
"message": "[%key:common::config_flow::error::invalid_auth%]"
|
||||
},
|
||||
|
||||
@@ -154,6 +154,7 @@ async def test_oven_cook_mode_select(
|
||||
"""Test selecting a cook mode issues a cook command."""
|
||||
entity_id, mock_fixture, cavity = oven_cook_mode_entity
|
||||
mock = request.getfixturevalue(mock_fixture)
|
||||
mock.get_cook_mode.return_value = whirlpool.oven.CookMode.Standby
|
||||
await init_integration(hass)
|
||||
|
||||
await hass.services.async_call(
|
||||
@@ -170,6 +171,31 @@ async def test_oven_cook_mode_select(
|
||||
)
|
||||
|
||||
|
||||
async def test_oven_cook_mode_select_while_cooking(
|
||||
hass: HomeAssistant,
|
||||
oven_cook_mode_entity: tuple[str, str, whirlpool.oven.Cavity],
|
||||
request: pytest.FixtureRequest,
|
||||
) -> None:
|
||||
"""Test changing the mode of a running cook is refused."""
|
||||
entity_id, mock_fixture, _ = oven_cook_mode_entity
|
||||
mock = request.getfixturevalue(mock_fixture)
|
||||
await init_integration(hass)
|
||||
|
||||
with pytest.raises(ServiceValidationError) as err:
|
||||
await hass.services.async_call(
|
||||
SELECT_DOMAIN,
|
||||
SelectService.SELECT_OPTION,
|
||||
{
|
||||
TargetKey.ENTITY_ID: entity_id,
|
||||
SelectServiceArgument.OPTION: "broil",
|
||||
},
|
||||
blocking=True,
|
||||
)
|
||||
assert err.value.translation_key == "cook_mode_change_while_cooking"
|
||||
mock.set_cook.assert_not_called()
|
||||
mock.stop_cook.assert_not_called()
|
||||
|
||||
|
||||
async def test_oven_cook_mode_select_from_idle(
|
||||
hass: HomeAssistant,
|
||||
oven_cook_mode_entity: tuple[str, str, whirlpool.oven.Cavity],
|
||||
@@ -178,6 +204,7 @@ async def test_oven_cook_mode_select_from_idle(
|
||||
"""Test selecting a mode with no target set uses the default temperature."""
|
||||
entity_id, mock_fixture, cavity = oven_cook_mode_entity
|
||||
mock = request.getfixturevalue(mock_fixture)
|
||||
mock.get_cook_mode.return_value = whirlpool.oven.CookMode.Standby
|
||||
mock.get_target_temp.return_value = None
|
||||
await init_integration(hass)
|
||||
|
||||
@@ -226,6 +253,7 @@ async def test_oven_cook_mode_select_value_error(
|
||||
"""Test a ValueError while setting the cook mode raises ServiceValidationError."""
|
||||
entity_id, mock_fixture, _ = oven_cook_mode_entity
|
||||
mock = request.getfixturevalue(mock_fixture)
|
||||
mock.get_cook_mode.return_value = whirlpool.oven.CookMode.Standby
|
||||
mock.set_cook.side_effect = ValueError
|
||||
await init_integration(hass)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user