From 7418941cd53b28a3f534c571d51296df75ec8b07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20M=C3=BCller?= Date: Sun, 26 Jul 2026 09:10:53 +0200 Subject: [PATCH] Verbessert --- .../dist/sternwarte-card-retro.js | 13 ++++++++++- .../dist/sternwarte-card.js | 15 ++++++++++++- .../custom_components/sternwarte/__init__.py | 22 +++++++++++++++++++ .../custom_components/sternwarte/const.py | 2 ++ .../sternwarte/coordinator.py | 8 +++++++ .../sternwarte/services.yaml | 8 +++++++ 6 files changed, 66 insertions(+), 2 deletions(-) diff --git a/sternwarte-homeassistant-card/dist/sternwarte-card-retro.js b/sternwarte-homeassistant-card/dist/sternwarte-card-retro.js index c5cab21..99becb8 100644 --- a/sternwarte-homeassistant-card/dist/sternwarte-card-retro.js +++ b/sternwarte-homeassistant-card/dist/sternwarte-card-retro.js @@ -185,6 +185,13 @@ class SternwarteCardRetro extends HTMLElement { } } + _clearScheduleField(key, domain, service) { + const f = this._scheduleFieldState(key); + f.draft = ""; f.editing = false; f.pending = false; + this._call(domain, service); + this._requestRender(); + } + _beginScheduleEdit(k, fb) { const f = this._scheduleFieldState(k); f.editing = true; f.pending = false; @@ -732,12 +739,14 @@ class SternwarteCardRetro extends HTMLElement {
${seg7(this._seg7DateTime(openSched), { color: "amber", size: 0.45 })}
+
SCHLIESSEN
${seg7(this._seg7DateTime(closeSched), { color: "amber", size: 0.45 })}
+
@@ -767,6 +776,8 @@ class SternwarteCardRetro extends HTMLElement { }); this._bindClick("open-schedule-btn", () => this._setDateTime(openSchedEid, "open-schedule-input", "open")); this._bindClick("close-schedule-btn", () => this._setDateTime(closeSchedEid, "close-schedule-input", "close")); + this._bindClick("open-schedule-clear-btn", () => this._clearScheduleField("open", "sternwarte", "clear_open_schedule")); + this._bindClick("close-schedule-clear-btn", () => this._clearScheduleField("close", "sternwarte", "clear_close_schedule")); this._bindMoreInfo("wind-btn", this.config.wind); this._bindMoreInfo("pos-gauge", this.config.roofPosition); this._bindMoreInfo("moon-scope", this.config.roofStatus); @@ -1440,7 +1451,7 @@ class SternwarteCardRetro extends HTMLElement { } .sched-row { display: grid; - grid-template-columns: 90px minmax(0, 1fr) minmax(150px, 200px) 70px; + grid-template-columns: 90px minmax(0, 1fr) minmax(150px, 200px) max-content max-content; gap: 10px; align-items: center; } diff --git a/sternwarte-homeassistant-card/dist/sternwarte-card.js b/sternwarte-homeassistant-card/dist/sternwarte-card.js index 8a696ee..8c0805a 100644 --- a/sternwarte-homeassistant-card/dist/sternwarte-card.js +++ b/sternwarte-homeassistant-card/dist/sternwarte-card.js @@ -186,6 +186,15 @@ class SternwarteCard extends HTMLElement { } } + _clearScheduleField(key, domain, service) { + const field = this._scheduleFieldState(key); + field.draft = ""; + field.editing = false; + field.pending = false; + this._call(domain, service); + this._requestRender(); + } + _beginScheduleEdit(key, fallbackState) { const field = this._scheduleFieldState(key); field.editing = true; @@ -1234,7 +1243,7 @@ class SternwarteCard extends HTMLElement { } .schedule-grid { display: grid; - grid-template-columns: minmax(0, 196px) max-content; + grid-template-columns: minmax(0, 196px) max-content max-content; gap: 8px; align-items: center; justify-content: start; @@ -1540,10 +1549,12 @@ class SternwarteCard extends HTMLElement {
+
+
@@ -1582,6 +1593,8 @@ class SternwarteCard extends HTMLElement { }); this._bindClick("open-schedule-btn", () => this._setDateTime(openScheduleEntityId, "open-schedule-input", "open")); this._bindClick("close-schedule-btn", () => this._setDateTime(closeScheduleEntityId, "close-schedule-input", "close")); + this._bindClick("open-schedule-clear-btn", () => this._clearScheduleField("open", "sternwarte", "clear_open_schedule")); + this._bindClick("close-schedule-clear-btn", () => this._clearScheduleField("close", "sternwarte", "clear_close_schedule")); this._bindMoreInfo("wind-stat", this.config.wind); this._bindMoreInfo("rain-badge", this.config.rain); this._bindScheduleInput("open", "open-schedule-input", openSchedule); diff --git a/sternwarte-homeassistant-integration/custom_components/sternwarte/__init__.py b/sternwarte-homeassistant-integration/custom_components/sternwarte/__init__.py index 3411691..602fe50 100644 --- a/sternwarte-homeassistant-integration/custom_components/sternwarte/__init__.py +++ b/sternwarte-homeassistant-integration/custom_components/sternwarte/__init__.py @@ -10,6 +10,8 @@ from homeassistant.core import HomeAssistant, ServiceCall from .const import ( DOMAIN, + SERVICE_CLEAR_CLOSE_SCHEDULE, + SERVICE_CLEAR_OPEN_SCHEDULE, SERVICE_CLEAR_SCHEDULE, SERVICE_CLOSE_ROOF, SERVICE_OPEN_ROOF, @@ -63,6 +65,14 @@ async def _async_handle_clear_schedule(hass: HomeAssistant, call: ServiceCall) - await _async_call_on_all(hass, "async_clear_schedule") +async def _async_handle_clear_open_schedule(hass: HomeAssistant, call: ServiceCall) -> None: + await _async_call_on_all(hass, "async_clear_open_schedule") + + +async def _async_handle_clear_close_schedule(hass: HomeAssistant, call: ServiceCall) -> None: + await _async_call_on_all(hass, "async_clear_close_schedule") + + async def _async_handle_set_nautical_schedule(hass: HomeAssistant, call: ServiceCall) -> None: await _async_call_on_all(hass, "async_set_next_nautical_schedule") @@ -81,6 +91,16 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: hass.services.async_register(DOMAIN, SERVICE_POWER_ON, partial(_async_handle_power_on, hass)) hass.services.async_register(DOMAIN, SERVICE_POWER_OFF, partial(_async_handle_power_off, hass)) hass.services.async_register(DOMAIN, SERVICE_CLEAR_SCHEDULE, partial(_async_handle_clear_schedule, hass)) + hass.services.async_register( + DOMAIN, + SERVICE_CLEAR_OPEN_SCHEDULE, + partial(_async_handle_clear_open_schedule, hass), + ) + hass.services.async_register( + DOMAIN, + SERVICE_CLEAR_CLOSE_SCHEDULE, + partial(_async_handle_clear_close_schedule, hass), + ) hass.services.async_register( DOMAIN, SERVICE_SET_NAUTICAL_SCHEDULE, @@ -104,6 +124,8 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: SERVICE_POWER_ON, SERVICE_POWER_OFF, SERVICE_CLEAR_SCHEDULE, + SERVICE_CLEAR_OPEN_SCHEDULE, + SERVICE_CLEAR_CLOSE_SCHEDULE, SERVICE_SET_NAUTICAL_SCHEDULE, ): if hass.services.has_service(DOMAIN, service): diff --git a/sternwarte-homeassistant-integration/custom_components/sternwarte/const.py b/sternwarte-homeassistant-integration/custom_components/sternwarte/const.py index 0e061ad..def4b4e 100644 --- a/sternwarte-homeassistant-integration/custom_components/sternwarte/const.py +++ b/sternwarte-homeassistant-integration/custom_components/sternwarte/const.py @@ -33,6 +33,8 @@ SERVICE_STOP_ROOF = "stop_roof" SERVICE_POWER_ON = "power_on" SERVICE_POWER_OFF = "power_off" SERVICE_CLEAR_SCHEDULE = "clear_schedule" +SERVICE_CLEAR_OPEN_SCHEDULE = "clear_open_schedule" +SERVICE_CLEAR_CLOSE_SCHEDULE = "clear_close_schedule" SERVICE_SET_NAUTICAL_SCHEDULE = "set_nautical_schedule" ENTITY_ROOF_COVER: Final = "roof" diff --git a/sternwarte-homeassistant-integration/custom_components/sternwarte/coordinator.py b/sternwarte-homeassistant-integration/custom_components/sternwarte/coordinator.py index 76da6d5..de1e123 100644 --- a/sternwarte-homeassistant-integration/custom_components/sternwarte/coordinator.py +++ b/sternwarte-homeassistant-integration/custom_components/sternwarte/coordinator.py @@ -200,6 +200,14 @@ class SternwarteDataUpdateCoordinator(DataUpdateCoordinator[SternwarteState]): await self._async_save_runtime_state() await self.async_request_refresh() + async def async_clear_open_schedule(self) -> None: + """Clear only the open schedule.""" + await self.async_set_open_schedule(None) + + async def async_clear_close_schedule(self) -> None: + """Clear only the close schedule.""" + await self.async_set_close_schedule(None) + async def async_set_close_schedule(self, when: datetime | None) -> None: """Persist close schedule.""" when = self._normalize_user_schedule_datetime(when) diff --git a/sternwarte-homeassistant-integration/custom_components/sternwarte/services.yaml b/sternwarte-homeassistant-integration/custom_components/sternwarte/services.yaml index 69ab79c..f1f88d3 100644 --- a/sternwarte-homeassistant-integration/custom_components/sternwarte/services.yaml +++ b/sternwarte-homeassistant-integration/custom_components/sternwarte/services.yaml @@ -22,6 +22,14 @@ clear_schedule: name: Zeitplanung löschen description: Löscht die geplanten Öffnen- und Schließen-Termine. +clear_open_schedule: + name: Öffnen-Termin löschen + description: Löscht nur den geplanten Öffnen-Termin. + +clear_close_schedule: + name: Schließen-Termin löschen + description: Löscht nur den geplanten Schließen-Termin. + set_nautical_schedule: name: Nautische Dämmerung setzen description: Setzt Öffnen und Schließen auf die nächste nautische Abend- und Morgendämmerung.