home-assistant/core · error · HomeAssistantError
connection_error
connection_error
Error message
connection_error
What it means
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.
Source
Thrown at homeassistant/components/bosch_alarm/services.py:49
SET_DATE_TIME_SCHEMA = vol.Schema(
{
vol.Required(ATTR_CONFIG_ENTRY_ID): cv.string,
vol.Optional(ATTR_DATETIME): validate_datetime,
}
)
async def async_set_panel_date(call: ServiceCall) -> None:
"""Set the date and time on a bosch alarm panel."""
value: dt.datetime = call.data.get(ATTR_DATETIME, dt_util.now())
config_entry: BoschAlarmConfigEntry = service.async_get_config_entry(
call.hass, DOMAIN, call.data[ATTR_CONFIG_ENTRY_ID]
)
panel = config_entry.runtime_data
try:
await panel.set_panel_date(value)
except asyncio.InvalidStateError as err:
raise HomeAssistantError(
translation_domain=DOMAIN,
translation_key="connection_error",
translation_placeholders={"target": config_entry.title},
) from err
@callback
def async_setup_services(hass: HomeAssistant) -> None:
"""Set up the services for the bosch alarm integration."""
hass.services.async_register(
DOMAIN,
SERVICE_SET_DATE_TIME,
async_set_panel_date,
schema=SET_DATE_TIME_SCHEMA,
)
View on GitHub (pinned to 58a3fdb3ea)
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.
Defensive patterns
Strategy: validation
Validate before calling
entry = hass.config_entries.async_get_entry(entry_id)
if entry.state is not ConfigEntryState.LOADED:
raise ServiceValidationError("panel_not_connected") # check before calling service Try / catch
try:
await panel.set_panel_date(value)
except asyncio.InvalidStateError as err:
raise HomeAssistantError(translation_domain=DOMAIN, translation_key="connection_error", ...) from err Prevention
- Call bosch_alarm services only when the config entry state is LOADED.
- Reload the integration after panel network interruptions before retrying services.
When it happens
Trigger: 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.
Common situations: Panel briefly offline; service invoked during entry setup retries; stale runtime_data after a disconnect event.
Related errors
- api_error
- Connection failed during update for zone {self.state.zn}
- connection_failed
- cannot_connect
- authentication_failed
AI-assisted analysis of home-assistant/core@58a3fdb3ea (2026-08-14).
Data as JSON: /api/errors/4c3fc5dfeda31df8.
Report an issue: GitHub.