{"record":{"id":"6dfa2aef2b0645a4","repo":"home-assistant/core","slug":"failed-to-connect","errorCode":null,"errorMessage":"Failed to connect","messagePattern":"Failed to connect","errorType":"exception","errorClass":"HomeAssistantError","httpStatus":null,"severity":"error","filePath":"homeassistant/components/airos/button.py","lineNumber":63,"sourceCode":"        self,\n        coordinator: AirOSDataUpdateCoordinator,\n        description: ButtonEntityDescription,\n    ) -> None:\n        \"\"\"Initialize the AirOS client button.\"\"\"\n        super().__init__(coordinator)\n\n        self.entity_description = description\n        self._attr_unique_id = f\"{coordinator.data.derived.mac}_{description.key}\"\n\n    @override\n    async def async_press(self) -> None:\n        \"\"\"Handle the button press to reboot the device.\"\"\"\n        try:\n            await self.coordinator.airos_device.login()\n            result = await self.coordinator.airos_device.reboot()\n\n        except AirOSException as err:\n            raise HomeAssistantError(\n                translation_domain=DOMAIN,\n                translation_key=\"cannot_connect\",\n            ) from err\n\n        if not result:\n            raise HomeAssistantError(\n                translation_domain=DOMAIN,\n                translation_key=\"reboot_failed\",\n            ) from None\n","sourceCodeStart":45,"sourceCodeEnd":73,"githubUrl":"https://github.com/home-assistant/core/blob/58a3fdb3ea0538617f0a07efcfba6294de64fd59/homeassistant/components/airos/button.py#L45-L73","documentation":"Raised by the airos reboot button entity when async_press fails with any AirOSException while logging in to or rebooting a Ubiquiti airOS device. It wraps the underlying library exception in a HomeAssistantError with the 'cannot_connect' translation key, so the user sees a localized 'Failed to connect' message in the UI. The original exception is chained via 'from err' so it appears in logs.","triggerScenarios":"Calling async_press on the reboot button when airos_device.login() or airos_device.reboot() raises any subclass of AirOSException: wrong IP/hostname, device powered off or unreachable on the network, HTTP session setup failure, timeout, or invalid credentials (AirOSConnectionAuthenticationError is also caught here since it subclasses AirOSException).","commonSituations":"Device IP changed by DHCP, firmware update changed the login flow or cookie handling, wrong username/password in the config entry, device rebooting already, or TLS/certificate mismatch after a firmware upgrade.","solutions":["Verify the device is reachable: open its web interface at the configured host and confirm it responds.","Check the username/password stored in the airos config entry and re-configure if the device credentials changed.","Inspect the full traceback in Home Assistant logs (the chained AirOSException names the real cause, e.g. authentication vs connection setup).","If the device IP changed, set a DHCP reservation or update the config entry host.","Update the airos integration/library to the latest version in case the device firmware introduced API changes."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":"def is_airos_connect_error(err: Exception) -> bool:\n    return isinstance(err, HomeAssistantError) and getattr(err, \"translation_domain\", None) == \"airos\" and getattr(err, \"translation_key\", None) == \"cannot_connect\"","tryCatchPattern":"try:\n    await button.async_press()  # or call device.reboot() via airos library directly\nexcept HomeAssistantError as err:\n    if getattr(err, \"translation_key\", None) == \"cannot_connect\":\n        # connectivity problem: check host reachability before retry\n        ...\n    raise","preventionTips":["Give the airOS device a static DHCP reservation so the host never changes.","Keep device credentials in a password manager and update the config entry immediately after rotating them.","Test the device web UI after every firmware upgrade before relying on automations."],"tags":["home-assistant","airos","ubiquiti","network","button"],"backgroundTag":null,"analyzedSha":"58a3fdb3ea0538617f0a07efcfba6294de64fd59","analyzedAt":"2026-08-14T20:54:38.818Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}