{"record":{"id":"461696629a8eb2fa","repo":"home-assistant/core","slug":"sync-time-failed","errorCode":"sync_time_failed","errorMessage":"Failed to sync time for {device_name}: {error}","messagePattern":"Failed to sync time for (.+?): (.+?)","errorType":"exception","errorClass":"HomeAssistantError","httpStatus":null,"severity":"warning","filePath":"homeassistant/components/bsblan/helpers.py","lineNumber":33,"sourceCode":"\n    Args:\n        client: The BSB-LAN client instance.\n        device_name: The name of the device (used in error messages).\n\n    Raises:\n        HomeAssistantError: If the time sync operation fails.\n\n    \"\"\"\n    try:\n        device_time = await client.time()\n        current_time = dt_util.now()\n        current_time_str = current_time.strftime(\"%d.%m.%Y %H:%M:%S\")\n\n        # Only sync if device time differs from HA time\n        if device_time.time.value != current_time_str:\n            await client.set_time(current_time_str)\n    except BSBLANError as err:\n        raise HomeAssistantError(\n            translation_domain=DOMAIN,\n            translation_key=\"sync_time_failed\",\n            translation_placeholders={\n                \"device_name\": device_name,\n                \"error\": str(err),\n            },\n        ) from err\n","sourceCodeStart":15,"sourceCodeEnd":41,"githubUrl":"https://github.com/home-assistant/core/blob/58a3fdb3ea0538617f0a07efcfba6294de64fd59/homeassistant/components/bsblan/helpers.py#L15-L41","documentation":"Raised by the bsblan `sync_time` helper (used by the `bsblan.sync_time` service/action) when reading `client.time()` or writing `client.set_time(...)` raises BSBLANError. It is wrapped in HomeAssistantError with translation key `sync_time_failed` and placeholders for the device name and the underlying error string, so the action call shows a clear failure in the UI.","triggerScenarios":"Invoking the `bsblan.sync_time` action while the device is unreachable, rejects the time write, or returns an unexpected response. The comparison `device_time.time.value != current_time_str` gates the write, so a matching clock does not attempt it.","commonSituations":"Automations that sync time on a schedule (e.g. after device power loss) firing while the device is offline or busy; devices whose firmware does not expose the time parameter in the expected form.","solutions":["Confirm the device is online (state entities updating) before running the sync action.","Run the action again once reachable; it is idempotent — no write happens when times already match.","In automations that call sync_time, tolerate failure by continuing on error rather than aborting the sequence.","Update BSB-LAN firmware if the time parameter is consistently rejected."],"exampleFix":"// automation script: don't abort the whole sequence on time-sync failure\nservice: bsblan.sync_time\ndata:\n  device_id: \"...\"\ncontinue_on_error: true","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    await async_sync_time(hass, client, device_name)\nexcept HomeAssistantError:\n    LOGGER.warning(\"Time sync skipped for %s\", device_name)","preventionTips":["Schedule sync_time automations for times the device is reliably awake (not during reboot windows).","Set continue_on_error on sync_time actions in larger automations.","Sync is idempotent — identical clocks cause no write, so periodic retries are cheap."],"tags":["home-assistant","bsblan","time-sync","service-action"],"backgroundTag":null,"analyzedSha":"58a3fdb3ea0538617f0a07efcfba6294de64fd59","analyzedAt":"2026-08-14T20:54:38.818Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}