work: Добваил нагрев в автоматизацию
This commit is contained in:
+13
-49
@@ -191,15 +191,9 @@ class ScheduleService:
|
||||
|
||||
# Недели назад достаточно,
|
||||
# поскольку расписание повторяется каждые 7 дней.
|
||||
start_date = (
|
||||
now.date()
|
||||
- timedelta(days=7)
|
||||
)
|
||||
start_date = now.date() - timedelta(days=7)
|
||||
|
||||
end_date = (
|
||||
now.date()
|
||||
+ timedelta(days=7)
|
||||
)
|
||||
end_date = now.date() + timedelta(days=7)
|
||||
|
||||
occurrences = self._build_occurrences(
|
||||
start_date,
|
||||
@@ -231,17 +225,14 @@ class ScheduleService:
|
||||
)
|
||||
)
|
||||
|
||||
auto_active = (
|
||||
current.point.action.type
|
||||
== ScheduleActionType.AUTO
|
||||
)
|
||||
auto_active = current.point.action.type == ScheduleActionType.AUTO
|
||||
|
||||
auto_fallback_speed = None
|
||||
auto_target_temp = None
|
||||
|
||||
if auto_active:
|
||||
auto_fallback_speed = (
|
||||
current.point.action.settings.speed
|
||||
)
|
||||
auto_fallback_speed = current.point.action.settings.speed
|
||||
auto_target_temp = current.point.action.settings.target_temp
|
||||
|
||||
return ScheduleResolution(
|
||||
enabled=True,
|
||||
@@ -250,6 +241,7 @@ class ScheduleService:
|
||||
scheduled_settings=scheduled_settings,
|
||||
auto_active=auto_active,
|
||||
auto_fallback_speed=auto_fallback_speed,
|
||||
auto_target_temp=auto_target_temp,
|
||||
)
|
||||
|
||||
def _build_occurrences(
|
||||
@@ -384,39 +376,6 @@ class ScheduleService:
|
||||
except Exception as exc:
|
||||
self._last_error = f"{type(exc).__name__}: {exc}"
|
||||
|
||||
# async def _process(self, *, initial: bool = False) -> None:
|
||||
#
|
||||
# resolution = self.resolve()
|
||||
#
|
||||
# if not resolution.enabled:
|
||||
# return
|
||||
#
|
||||
# current = resolution.current
|
||||
#
|
||||
# if current is None:
|
||||
# return
|
||||
#
|
||||
# # Эта точка уже применена.
|
||||
# if (
|
||||
# not initial
|
||||
# and self._last_applied_when == current.when
|
||||
# ):
|
||||
# return
|
||||
#
|
||||
# # AUTO пока только распознаём.
|
||||
# # Сам AutoController подключим позже.
|
||||
# if (
|
||||
# current.point.action.type
|
||||
# == ScheduleActionType.AUTO
|
||||
# ):
|
||||
# self._last_applied_when = current.when
|
||||
# return
|
||||
#
|
||||
# settings = resolution.scheduled_settings
|
||||
#
|
||||
# await self._apply_settings(settings)
|
||||
#
|
||||
# self._last_applied_when = current.when
|
||||
|
||||
async def _process(self) -> None:
|
||||
now = datetime.now()
|
||||
@@ -477,7 +436,12 @@ class ScheduleService:
|
||||
# Остальные параметры расписания
|
||||
# (power, heater, temperature, mode...)
|
||||
# должны продолжать работать.
|
||||
settings = replace(settings, speed=None)
|
||||
settings = replace(
|
||||
settings,
|
||||
speed=None,
|
||||
heater=None,
|
||||
target_temp=None,
|
||||
)
|
||||
|
||||
await self._apply_settings(settings)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user