work: Добваил нагрев в автоматизацию
This commit is contained in:
+17
-13
@@ -196,9 +196,7 @@ def _parse_action(
|
||||
action_type_raw = data.get("type")
|
||||
|
||||
try:
|
||||
action_type = ScheduleActionType(
|
||||
action_type_raw
|
||||
)
|
||||
action_type = ScheduleActionType(action_type_raw)
|
||||
|
||||
except ValueError as exc:
|
||||
raise ValueError(
|
||||
@@ -208,32 +206,38 @@ def _parse_action(
|
||||
|
||||
if action_type == ScheduleActionType.AUTO:
|
||||
|
||||
extra = set(data) - {
|
||||
allowed_fields = {
|
||||
"type",
|
||||
"speed",
|
||||
"target_temp",
|
||||
}
|
||||
|
||||
extra = set(data) - allowed_fields
|
||||
|
||||
if extra:
|
||||
raise ValueError(
|
||||
"AUTO action supports only "
|
||||
f"'speed': {sorted(extra)}"
|
||||
"'speed' and 'target_temp': "
|
||||
f"{sorted(extra)}"
|
||||
)
|
||||
|
||||
if "speed" not in data:
|
||||
raise ValueError(
|
||||
"AUTO action must contain "
|
||||
"fallback speed"
|
||||
"AUTO action requires 'speed'"
|
||||
)
|
||||
|
||||
settings = _parse_settings(
|
||||
{
|
||||
"speed": data["speed"],
|
||||
}
|
||||
)
|
||||
settings_data = {
|
||||
"speed": data["speed"],
|
||||
}
|
||||
|
||||
if "target_temp" in data:
|
||||
settings_data["target_temp"] = (
|
||||
data["target_temp"]
|
||||
)
|
||||
|
||||
return ScheduleAction(
|
||||
type=ScheduleActionType.AUTO,
|
||||
settings=settings,
|
||||
settings=_parse_settings(settings_data),
|
||||
)
|
||||
|
||||
settings_data = {
|
||||
|
||||
Reference in New Issue
Block a user