From d0715e8df234cd624bc68596fe68a2ffc296ec12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20M=C3=BCller?= Date: Mon, 27 Apr 2026 15:25:58 +0200 Subject: [PATCH] Bugfix 3-5 --- .../custom_components/sternwarte/coordinator.py | 9 ++++++++- .../custom_components/sternwarte/cover.py | 14 ++++++++++++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/sternwarte-homeassistant-integration/custom_components/sternwarte/coordinator.py b/sternwarte-homeassistant-integration/custom_components/sternwarte/coordinator.py index e566a3c..899a1b8 100644 --- a/sternwarte-homeassistant-integration/custom_components/sternwarte/coordinator.py +++ b/sternwarte-homeassistant-integration/custom_components/sternwarte/coordinator.py @@ -71,6 +71,7 @@ class SternwarteDataUpdateCoordinator(DataUpdateCoordinator[SternwarteState]): self._pending_open_task: asyncio.Task | None = None self._pending_close_task: asyncio.Task | None = None self._roof_was_closed = False + self._last_roof_direction: str | None = None async def async_config_entry_first_refresh(self) -> None: """Load persisted runtime state before first refresh.""" @@ -262,6 +263,7 @@ class SternwarteDataUpdateCoordinator(DataUpdateCoordinator[SternwarteState]): async with self._command_lock: self._cancel_pending_open_task() self._cancel_pending_close_task() + self._last_roof_direction = None await self.api.set_output(10, True) await self.api.set_output(9, False) await self.api.set_output(11, False) @@ -323,6 +325,7 @@ class SternwarteDataUpdateCoordinator(DataUpdateCoordinator[SternwarteState]): if state.roof_moving: raise HomeAssistantError("Dach bewegt sich bereits") + self._last_roof_direction = "opening" await self.api.set_output(9, True) await self.api.set_output(10, False) await self.api.set_output(11, False) @@ -331,6 +334,10 @@ class SternwarteDataUpdateCoordinator(DataUpdateCoordinator[SternwarteState]): if not state.roof_power: raise HomeAssistantError("Dachsteuerung ist ausgeschaltet") + if state.roof_moving: + raise HomeAssistantError("Dach bewegt sich bereits") + + self._last_roof_direction = "closing" await self.api.set_output(11, True) await self.api.set_output(10, False) await self.api.set_output(9, False) @@ -339,7 +346,7 @@ class SternwarteDataUpdateCoordinator(DataUpdateCoordinator[SternwarteState]): return not state.roof_moving and not state.roof_open and not state.raining def _can_auto_close(self, state: SternwarteState) -> bool: - return state.roof_power + return state.roof_power and not state.roof_moving and not state.roof_closed def _is_roof_open(self, state: SternwarteState) -> bool: return state.roof_open and not state.roof_closed diff --git a/sternwarte-homeassistant-integration/custom_components/sternwarte/cover.py b/sternwarte-homeassistant-integration/custom_components/sternwarte/cover.py index 37e6c76..c1012fa 100644 --- a/sternwarte-homeassistant-integration/custom_components/sternwarte/cover.py +++ b/sternwarte-homeassistant-integration/custom_components/sternwarte/cover.py @@ -42,11 +42,21 @@ class SternwarteRoofCover(SternwarteEntity, CoverEntity): @property def is_opening(self) -> bool: - return self.coordinator.data.roof_moving and not self.coordinator.data.roof_open + if not self.coordinator.data.roof_moving or self.coordinator.data.roof_open: + return False + direction = self.coordinator._last_roof_direction + if direction is not None: + return direction == "opening" + return not self.coordinator.data.roof_closed @property def is_closing(self) -> bool: - return self.coordinator.data.roof_moving and not self.coordinator.data.roof_closed + if not self.coordinator.data.roof_moving or self.coordinator.data.roof_closed: + return False + direction = self.coordinator._last_roof_direction + if direction is not None: + return direction == "closing" + return not self.coordinator.data.roof_open @property def current_cover_position(self) -> int | None: