Handle cpd_enabled error in Tessie (#155322)

This commit is contained in:
Brett Adams
2025-10-28 21:42:53 +10:00
committed by GitHub
parent 2fe697486d
commit 8ce9238f7a
3 changed files with 22 additions and 0 deletions

View File

@@ -21,6 +21,7 @@ TRANSLATED_ERRORS = {
"already inactive": "already_inactive",
"incorrect pin": "incorrect_pin",
"no cable": "no_cable",
"cpd_enabled": "cpd_enabled",
}

View File

@@ -517,6 +517,9 @@
"command_failed": {
"message": "Command failed, {message}"
},
"cpd_enabled": {
"message": "Child presence detection has blocked the command, remove weight from seats."
},
"incorrect_pin": {
"message": "Incorrect PIN for {name}."
},

View File

@@ -130,3 +130,21 @@ async def test_errors(hass: HomeAssistant) -> None:
)
mock_set.assert_called_once()
assert error.value.__cause__ == ERROR_UNKNOWN
# Test setting climate with child presence detection error
with (
patch(
"homeassistant.components.tessie.climate.start_climate_preconditioning",
return_value={"result": False, "reason": "cpd_enabled"},
) as mock_set,
pytest.raises(HomeAssistantError) as error,
):
await hass.services.async_call(
CLIMATE_DOMAIN,
SERVICE_SET_HVAC_MODE,
{ATTR_ENTITY_ID: [entity_id], ATTR_HVAC_MODE: HVACMode.HEAT_COOL},
blocking=True,
)
mock_set.assert_called_once()
assert error.value.translation_domain == "tessie"
assert error.value.translation_key == "cpd_enabled"