home-assistant/core · error · ServiceValidationError
Failed to set preset mode to {preset_mode}.
Error message
Failed to set preset mode to {preset_mode}. What it means
Raised by Airobot climate's async_set_preset_mode when the sequence of API calls needed to enter/leave a preset (boost mode toggling plus set_mode) raises AirobotError. ServiceValidationError with translation key set_preset_mode_failed names the requested preset_mode.
Source
Thrown at homeassistant/components/airobot/climate.py:175
@override
async def async_set_preset_mode(self, preset_mode: str) -> None:
"""Set new preset mode."""
try:
if preset_mode == PRESET_BOOST:
# Enable boost mode
if not self._settings.setting_flags.boost_enabled:
await self.coordinator.client.set_boost_mode(True)
else:
# Disable boost mode if it's enabled
if self._settings.setting_flags.boost_enabled:
await self.coordinator.client.set_boost_mode(False)
# Set the mode (HOME or AWAY)
await self.coordinator.client.set_mode(_PRESET_MODE_2_MODE[preset_mode])
except AirobotError as err:
raise ServiceValidationError(
translation_domain=DOMAIN,
translation_key="set_preset_mode_failed",
translation_placeholders={"preset_mode": preset_mode},
) from err
await self.coordinator.async_request_refresh()
View on GitHub (pinned to 58a3fdb3ea)
Solutions
- Use only the preset modes listed on the entity (check its preset_modes attribute)
- Ensure the robot is online, then retry
- Reload the integration if the error repeats, to refresh tokens and cached settings
- Inspect logs for the chained AirobotError identifying which sub-command failed
Defensive patterns
Strategy: validation
Validate before calling
attrs = hass.states.get(entity_id).attributes
if preset_mode not in attrs.get("preset_modes", []):
raise ValueError(f"Unsupported preset {preset_mode}") Type guard
def is_valid_preset(preset_mode: str, preset_modes: list[str]) -> bool:
return preset_mode in preset_modes Try / catch
from homeassistant.exceptions import ServiceValidationError
try:
await hass.services.async_call("climate", "set_preset_mode", {...}, blocking=True)
except ServiceValidationError as err:
_LOGGER.warning("Airobot set_preset_mode rejected: %s", err) Prevention
- Read preset_modes from the entity instead of hardcoding preset names
- Verify the robot is online before preset-switching automations
- Reload the integration after reauth so preset state is fresh
When it happens
Trigger: Calling climate.set_preset_mode with HOME/AWAY/boost presets when any of set_boost_mode(True/False) or set_mode(...) fails — device offline, cloud error, or an unknown preset_mode key mapping.
Common situations: Switching presets while the robot is unreachable, or requesting a preset the integration's _PRESET_MODE_2_MODE mapping does not contain (which would raise KeyError before this, but malformed preset names reach here via the API path).
Related errors
- Failed to set temperature to {temperature}.
- Unsupported preset mode {preset_mode}
- Failed to press {button} button.
- Authentication failed, please reauthenticate.
- Failed to communicate with device.
AI-assisted analysis of home-assistant/core@58a3fdb3ea (2026-08-14).
Data as JSON: /api/errors/0e0886ba6cdf59de.
Report an issue: GitHub.