From 13e71046f8675de26b1aa786f83649c2517a6e12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Bachmann?= Date: Fri, 16 Jan 2026 19:58:58 +0000 Subject: [PATCH] Add on 0.5.4 --- custom_components/bahmcloud_store/repairs.py | 55 ++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 custom_components/bahmcloud_store/repairs.py diff --git a/custom_components/bahmcloud_store/repairs.py b/custom_components/bahmcloud_store/repairs.py new file mode 100644 index 0000000..810abd4 --- /dev/null +++ b/custom_components/bahmcloud_store/repairs.py @@ -0,0 +1,55 @@ +from __future__ import annotations + +import logging + +import voluptuous as vol + +from homeassistant.components.repairs import RepairsFlow +from homeassistant.core import HomeAssistant +from homeassistant import data_entry_flow + +from .core import RESTART_REQUIRED_ISSUE_ID + +_LOGGER = logging.getLogger(__name__) + + +class BCSRestartRequiredFlow(RepairsFlow): + """Repairs flow to restart Home Assistant after BCS install/update.""" + + def __init__(self, hass: HomeAssistant) -> None: + self.hass = hass + + async def async_step_init( + self, user_input: dict[str, str] | None = None + ) -> data_entry_flow.FlowResult: + return await self.async_step_confirm(user_input) + + async def async_step_confirm( + self, user_input: dict[str, str] | None = None + ) -> data_entry_flow.FlowResult: + if user_input is not None: + _LOGGER.info("BCS repairs flow: restarting Home Assistant (user confirmed)") + await self.hass.services.async_call( + "homeassistant", + "restart", + {}, + blocking=False, + ) + return self.async_create_entry(title="", data={}) + + return self.async_show_form( + step_id="confirm", + data_schema=vol.Schema({}), + ) + + +async def async_create_fix_flow( + hass: HomeAssistant, + issue_id: str, + data: dict[str, str | int | float | None] | None, +) -> RepairsFlow: + """Create a repairs flow for BCS fixable issues.""" + if issue_id == RESTART_REQUIRED_ISSUE_ID: + return BCSRestartRequiredFlow(hass) + + raise data_entry_flow.UnknownHandler \ No newline at end of file