From 19bdbd1b9a4473e6a42119dd8cb983a2c6b772dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Bachmann?= Date: Sun, 18 Jan 2026 18:53:30 +0000 Subject: [PATCH] 0.6.5 --- custom_components/bahmcloud_store/views.py | 38 +++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/custom_components/bahmcloud_store/views.py b/custom_components/bahmcloud_store/views.py index ce7fca5..2dac305 100644 --- a/custom_components/bahmcloud_store/views.py +++ b/custom_components/bahmcloud_store/views.py @@ -215,7 +215,12 @@ class BCSApiView(HomeAssistantView): async def get(self, request: web.Request) -> web.Response: return web.json_response( - {"ok": True, "version": self.core.version, "repos": self.core.list_repos_public()} + { + "ok": True, + "version": self.core.version, + "settings": self.core.get_settings_public(), + "repos": self.core.list_repos_public(), + } ) async def post(self, request: web.Request) -> web.Response: @@ -248,6 +253,37 @@ class BCSApiView(HomeAssistantView): return web.json_response({"ok": False, "message": "Unknown operation"}, status=400) +class BCSSettingsView(HomeAssistantView): + """Persistent UI settings (e.g. toggles).""" + + url = "/api/bcs/settings" + name = "api:bcs_settings" + requires_auth = True + + def __init__(self, core: Any) -> None: + self.core: BCSCore = core + + async def get(self, request: web.Request) -> web.Response: + return web.json_response({"ok": True, "settings": self.core.get_settings_public()}) + + async def post(self, request: web.Request) -> web.Response: + try: + data = await request.json() + except Exception: + data = {} + + updates: dict[str, Any] = {} + if "hacs_enabled" in data: + updates["hacs_enabled"] = bool(data.get("hacs_enabled")) + + try: + settings = await self.core.set_settings(updates) + return web.json_response({"ok": True, "settings": settings}) + except Exception as e: + _LOGGER.exception("BCS set settings failed: %s", e) + return web.json_response({"ok": False, "message": str(e) or "Failed"}, status=500) + + class BCSCustomRepoView(HomeAssistantView): url = "/api/bcs/custom_repo" name = "api:bcs_custom_repo"