work: добавил автоматический режим
This commit is contained in:
+22
-3
@@ -16,6 +16,7 @@ from .models import (
|
||||
ScheduledSettings,
|
||||
)
|
||||
|
||||
from dataclasses import replace
|
||||
|
||||
WEEKDAYS = (
|
||||
"mon",
|
||||
@@ -230,12 +231,20 @@ class ScheduleService:
|
||||
== ScheduleActionType.AUTO
|
||||
)
|
||||
|
||||
auto_fallback_speed = None
|
||||
|
||||
if auto_active:
|
||||
auto_fallback_speed = (
|
||||
current.point.action.settings.speed
|
||||
)
|
||||
|
||||
return ScheduleResolution(
|
||||
enabled=True,
|
||||
current=current,
|
||||
next=next_point,
|
||||
scheduled_settings=scheduled_settings,
|
||||
auto_active=auto_active,
|
||||
auto_fallback_speed=auto_fallback_speed,
|
||||
)
|
||||
|
||||
def _build_occurrences(
|
||||
@@ -451,18 +460,28 @@ class ScheduleService:
|
||||
return
|
||||
|
||||
# --------------------------------------------------
|
||||
# 4. Приводим Tion к ПОЛНОМУ актуальному
|
||||
# состоянию расписания
|
||||
# 4. Применяем состояние расписания
|
||||
# --------------------------------------------------
|
||||
|
||||
await self._apply_settings(resolution.scheduled_settings)
|
||||
settings = resolution.scheduled_settings
|
||||
|
||||
if resolution.auto_active:
|
||||
# В режиме AUTO скорость принадлежит
|
||||
# AutoController.
|
||||
#
|
||||
# Остальные параметры расписания
|
||||
# (power, heater, temperature, mode...)
|
||||
# должны продолжать работать.
|
||||
settings = replace(settings, speed=None)
|
||||
|
||||
await self._apply_settings(settings)
|
||||
|
||||
# Ставим только ПОСЛЕ успешного применения.
|
||||
self._last_applied_when = current.when
|
||||
self._last_error = None
|
||||
|
||||
|
||||
|
||||
async def _apply_settings(self, settings: ScheduledSettings) -> None:
|
||||
|
||||
if self._tion is None:
|
||||
|
||||
Reference in New Issue
Block a user