Verbessert

This commit is contained in:
2026-07-26 09:10:53 +02:00
parent a6825e1685
commit 7418941cd5
6 changed files with 66 additions and 2 deletions
+12 -1
View File
@@ -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 {
<div class="sched-readout">${seg7(this._seg7DateTime(openSched), { color: "amber", size: 0.45 })}</div>
<input id="open-schedule-input" type="datetime-local" value="${openInputV}">
<button type="button" class="kbtn" id="open-schedule-btn">SET</button>
<button type="button" class="kbtn kbtn-secondary" id="open-schedule-clear-btn">LÖSCHEN</button>
</div>
<div class="sched-row">
<span class="sched-cap">SCHLIESSEN</span>
<div class="sched-readout">${seg7(this._seg7DateTime(closeSched), { color: "amber", size: 0.45 })}</div>
<input id="close-schedule-input" type="datetime-local" value="${closeInputV}">
<button type="button" class="kbtn" id="close-schedule-btn">SET</button>
<button type="button" class="kbtn kbtn-secondary" id="close-schedule-clear-btn">LÖSCHEN</button>
</div>
<div class="sched-actions">
<button type="button" class="kbtn kbtn-secondary" id="nautical-btn">NAUTISCH</button>
@@ -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;
}
+14 -1
View File
@@ -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 {
<div class="schedule-grid">
<input id="open-schedule-input" type="datetime-local" value="${openInputValue}">
<button type="button" class="secondary" id="open-schedule-btn">\u00d6ffnen setzen</button>
<button type="button" class="secondary" id="open-schedule-clear-btn">\u00d6ffnen l\u00f6schen</button>
</div>
<div class="schedule-grid">
<input id="close-schedule-input" type="datetime-local" value="${closeInputValue}">
<button type="button" class="secondary" id="close-schedule-btn">Schlie\u00dfen setzen</button>
<button type="button" class="secondary" id="close-schedule-clear-btn">Schlie\u00dfen l\u00f6schen</button>
</div>
<div class="inline-actions">
<button type="button" class="secondary" id="nautical-btn">Nautisch setzen</button>
@@ -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);
@@ -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):
@@ -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"
@@ -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)
@@ -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.