diff --git a/custom_components/bahmcloud_store/views.py b/custom_components/bahmcloud_store/views.py index 228c811..59e893c 100644 --- a/custom_components/bahmcloud_store/views.py +++ b/custom_components/bahmcloud_store/views.py @@ -214,6 +214,11 @@ class BCSApiView(HomeAssistantView): self.core: BCSCore = core async def get(self, request: web.Request) -> web.Response: + # Ensure UI state is correct even if users deleted integration folders manually. + try: + await self.core.reconcile_installed() + except Exception: + pass return web.json_response( {"ok": True, "version": self.core.version, "repos": self.core.list_repos_public()} ) @@ -334,6 +339,27 @@ class BCSUpdateView(HomeAssistantView): return web.json_response({"ok": False, "message": str(e) or "Update failed"}, status=500) +class BCSUninstallView(HomeAssistantView): + url = "/api/bcs/uninstall" + name = "api:bcs_uninstall" + requires_auth = True + + def __init__(self, core: Any) -> None: + self.core: BCSCore = core + + async def post(self, request: web.Request) -> web.Response: + repo_id = request.query.get("repo_id") + if not repo_id: + return web.json_response({"ok": False, "message": "Missing repo_id"}, status=400) + + try: + result = await self.core.uninstall_repo(repo_id) + return web.json_response(result, status=200) + except Exception as e: + _LOGGER.exception("BCS uninstall failed: %s", e) + return web.json_response({"ok": False, "message": str(e) or "Uninstall failed"}, status=500) + + class BCSRestartView(HomeAssistantView): url = "/api/bcs/restart" name = "api:bcs_restart"