{"record":{"id":"0e0886ba6cdf59de","repo":"home-assistant/core","slug":"failed-to-set-preset-mode-to-preset-mode","errorCode":null,"errorMessage":"Failed to set preset mode to {preset_mode}.","messagePattern":"Failed to set preset mode to (.+?)\\.","errorType":"exception","errorClass":"ServiceValidationError","httpStatus":null,"severity":"error","filePath":"homeassistant/components/airobot/climate.py","lineNumber":175,"sourceCode":"\n    @override\n    async def async_set_preset_mode(self, preset_mode: str) -> None:\n        \"\"\"Set new preset mode.\"\"\"\n        try:\n            if preset_mode == PRESET_BOOST:\n                # Enable boost mode\n                if not self._settings.setting_flags.boost_enabled:\n                    await self.coordinator.client.set_boost_mode(True)\n            else:\n                # Disable boost mode if it's enabled\n                if self._settings.setting_flags.boost_enabled:\n                    await self.coordinator.client.set_boost_mode(False)\n\n                # Set the mode (HOME or AWAY)\n                await self.coordinator.client.set_mode(_PRESET_MODE_2_MODE[preset_mode])\n\n        except AirobotError as err:\n            raise ServiceValidationError(\n                translation_domain=DOMAIN,\n                translation_key=\"set_preset_mode_failed\",\n                translation_placeholders={\"preset_mode\": preset_mode},\n            ) from err\n\n        await self.coordinator.async_request_refresh()\n","sourceCodeStart":157,"sourceCodeEnd":182,"githubUrl":"https://github.com/home-assistant/core/blob/58a3fdb3ea0538617f0a07efcfba6294de64fd59/homeassistant/components/airobot/climate.py#L157-L182","documentation":"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.","triggerScenarios":"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.","commonSituations":"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).","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"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"attrs = hass.states.get(entity_id).attributes\nif preset_mode not in attrs.get(\"preset_modes\", []):\n    raise ValueError(f\"Unsupported preset {preset_mode}\")","typeGuard":"def is_valid_preset(preset_mode: str, preset_modes: list[str]) -> bool:\n    return preset_mode in preset_modes","tryCatchPattern":"from homeassistant.exceptions import ServiceValidationError\n\ntry:\n    await hass.services.async_call(\"climate\", \"set_preset_mode\", {...}, blocking=True)\nexcept ServiceValidationError as err:\n    _LOGGER.warning(\"Airobot set_preset_mode rejected: %s\", err)","preventionTips":["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"],"tags":["airobot","home-assistant","climate","preset-mode"],"backgroundTag":null,"analyzedSha":"58a3fdb3ea0538617f0a07efcfba6294de64fd59","analyzedAt":"2026-08-14T20:54:38.818Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}