Skip to content

Commit 8ce9238

Browse files
authored
Handle cpd_enabled error in Tessie (home-assistant#155322)
1 parent 2fe6974 commit 8ce9238

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

homeassistant/components/tessie/const.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"already inactive": "already_inactive",
2222
"incorrect pin": "incorrect_pin",
2323
"no cable": "no_cable",
24+
"cpd_enabled": "cpd_enabled",
2425
}
2526

2627

homeassistant/components/tessie/strings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -517,6 +517,9 @@
517517
"command_failed": {
518518
"message": "Command failed, {message}"
519519
},
520+
"cpd_enabled": {
521+
"message": "Child presence detection has blocked the command, remove weight from seats."
522+
},
520523
"incorrect_pin": {
521524
"message": "Incorrect PIN for {name}."
522525
},

tests/components/tessie/test_climate.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,3 +130,21 @@ async def test_errors(hass: HomeAssistant) -> None:
130130
)
131131
mock_set.assert_called_once()
132132
assert error.value.__cause__ == ERROR_UNKNOWN
133+
134+
# Test setting climate with child presence detection error
135+
with (
136+
patch(
137+
"homeassistant.components.tessie.climate.start_climate_preconditioning",
138+
return_value={"result": False, "reason": "cpd_enabled"},
139+
) as mock_set,
140+
pytest.raises(HomeAssistantError) as error,
141+
):
142+
await hass.services.async_call(
143+
CLIMATE_DOMAIN,
144+
SERVICE_SET_HVAC_MODE,
145+
{ATTR_ENTITY_ID: [entity_id], ATTR_HVAC_MODE: HVACMode.HEAT_COOL},
146+
blocking=True,
147+
)
148+
mock_set.assert_called_once()
149+
assert error.value.translation_domain == "tessie"
150+
assert error.value.translation_key == "cpd_enabled"

0 commit comments

Comments
 (0)