{"record":{"id":"4c3fc5dfeda31df8","repo":"home-assistant/core","slug":"connection-error","errorCode":"connection_error","errorMessage":"connection_error","messagePattern":"connection_error","errorType":"exception","errorClass":"HomeAssistantError","httpStatus":null,"severity":"error","filePath":"homeassistant/components/bosch_alarm/services.py","lineNumber":49,"sourceCode":"SET_DATE_TIME_SCHEMA = vol.Schema(\n    {\n        vol.Required(ATTR_CONFIG_ENTRY_ID): cv.string,\n        vol.Optional(ATTR_DATETIME): validate_datetime,\n    }\n)\n\n\nasync def async_set_panel_date(call: ServiceCall) -> None:\n    \"\"\"Set the date and time on a bosch alarm panel.\"\"\"\n    value: dt.datetime = call.data.get(ATTR_DATETIME, dt_util.now())\n    config_entry: BoschAlarmConfigEntry = service.async_get_config_entry(\n        call.hass, DOMAIN, call.data[ATTR_CONFIG_ENTRY_ID]\n    )\n    panel = config_entry.runtime_data\n    try:\n        await panel.set_panel_date(value)\n    except asyncio.InvalidStateError as err:\n        raise HomeAssistantError(\n            translation_domain=DOMAIN,\n            translation_key=\"connection_error\",\n            translation_placeholders={\"target\": config_entry.title},\n        ) from err\n\n\n@callback\ndef async_setup_services(hass: HomeAssistant) -> None:\n    \"\"\"Set up the services for the bosch alarm integration.\"\"\"\n\n    hass.services.async_register(\n        DOMAIN,\n        SERVICE_SET_DATE_TIME,\n        async_set_panel_date,\n        schema=SET_DATE_TIME_SCHEMA,\n    )\n","sourceCodeStart":31,"sourceCodeEnd":66,"githubUrl":"https://github.com/home-assistant/core/blob/58a3fdb3ea0538617f0a07efcfba6294de64fd59/homeassistant/components/bosch_alarm/services.py#L31-L66","documentation":"Raised by the bosch_alarm set_panel_date service when panel.set_panel_date(value) fails with asyncio.InvalidStateError. In the bosch_alarm library this surfaces when the panel's connection state is inconsistent (futures already done/cancelled because the session died), i.e. the cached runtime panel object no longer has a live connection. The HomeAssistantError carries translation_key 'connection_error' with the panel title as placeholder.","triggerScenarios":"Calling the bosch_alarm.set_panel_date service while the panel entry is in a retry/failed state, right after a network drop, or when the coordinator hasn't reconnected yet.","commonSituations":"Panel briefly offline; service invoked during entry setup retries; stale runtime_data after a disconnect event.","solutions":["Confirm the integration entry state is Loaded (not SetupRetry/Failed) before calling the service.","Reload the bosch_alarm integration to re-establish the panel connection, then re-run the service.","Restore panel network reachability (see cannot_connect triage) so the connection stays healthy."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"entry = hass.config_entries.async_get_entry(entry_id)\nif entry.state is not ConfigEntryState.LOADED:\n    raise ServiceValidationError(\"panel_not_connected\")  # check before calling service","typeGuard":null,"tryCatchPattern":"try:\n    await panel.set_panel_date(value)\nexcept asyncio.InvalidStateError as err:\n    raise HomeAssistantError(translation_domain=DOMAIN, translation_key=\"connection_error\", ...) from err","preventionTips":["Call bosch_alarm services only when the config entry state is LOADED.","Reload the integration after panel network interruptions before retrying services."],"tags":["bosch-alarm","service","connection","home-assistant"],"backgroundTag":null,"analyzedSha":"58a3fdb3ea0538617f0a07efcfba6294de64fd59","analyzedAt":"2026-08-14T20:54:38.818Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}