{"record":{"id":"a7342fd3c0670c38","repo":"home-assistant/core","slug":"failed-to-turn-on-switch","errorCode":null,"errorMessage":"Failed to turn on {switch}.","messagePattern":"Failed to turn on (.+?)\\.","errorType":"exception","errorClass":"HomeAssistantError","httpStatus":null,"severity":"error","filePath":"homeassistant/components/airobot/switch.py","lineNumber":101,"sourceCode":"    ) -> None:\n        \"\"\"Initialize the switch.\"\"\"\n        super().__init__(coordinator)\n        self.entity_description = description\n        self._attr_unique_id = f\"{coordinator.data.status.device_id}_{description.key}\"\n\n    @property\n    @override\n    def is_on(self) -> bool:\n        \"\"\"Return true if the switch is on.\"\"\"\n        return self.entity_description.is_on_fn(self.coordinator)\n\n    @override\n    async def async_turn_on(self, **kwargs: Any) -> None:\n        \"\"\"Turn the switch on.\"\"\"\n        try:\n            await self.entity_description.turn_on_fn(self.coordinator)\n        except AirobotError as err:\n            raise HomeAssistantError(\n                translation_domain=DOMAIN,\n                translation_key=\"switch_turn_on_failed\",\n                translation_placeholders={\"switch\": self.entity_description.key},\n            ) from err\n        await self.coordinator.async_request_refresh()\n\n    @override\n    async def async_turn_off(self, **kwargs: Any) -> None:\n        \"\"\"Turn the switch off.\"\"\"\n        try:\n            await self.entity_description.turn_off_fn(self.coordinator)\n        except AirobotError as err:\n            raise HomeAssistantError(\n                translation_domain=DOMAIN,\n                translation_key=\"switch_turn_off_failed\",\n                translation_placeholders={\"switch\": self.entity_description.key},\n            ) from err\n        await self.coordinator.async_request_refresh()","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/home-assistant/core/blob/58a3fdb3ea0538617f0a07efcfba6294de64fd59/homeassistant/components/airobot/switch.py#L83-L119","documentation":"Raised by the Airobot switch entity's async_turn_on when the entity_description.turn_on_fn call raises AirobotError. HomeAssistantError with translation key switch_turn_on_failed names the switch's description key so the user knows which switch failed.","triggerScenarios":"Toggling an Airobot switch (e.g. enabling a robot feature) while the corresponding cloud API call fails: device offline, rejected command, or auth error surfacing through the generic AirobotError catch.","commonSituations":"Turning features on/off while the robot is unreachable, or after credentials expired but before the coordinator has triggered reauth.","solutions":["Verify the robot is online and retry","If other calls also fail with auth-like errors, complete the reauth flow","Reload the integration to resync state","Inspect the chained exception in logs for the specific API error"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    await hass.services.async_call(\"switch\", \"turn_on\", {\"entity_id\": eid}, blocking=True)\nexcept HomeAssistantError as err:\n    _LOGGER.warning(\"Airobot switch turn_on failed: %s\", err)","preventionTips":["Verify robot connectivity before control automations","Idempotent designs: re-assert desired switch state on next cycle instead of alerting per failure","Keep integration authenticated"],"tags":["airobot","home-assistant","switch","cloud-api"],"backgroundTag":null,"analyzedSha":"58a3fdb3ea0538617f0a07efcfba6294de64fd59","analyzedAt":"2026-08-14T20:54:38.818Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}