Files
sillyhome-next-dev/app/rules/heating.py
Otto 1cb2630cec
Some checks failed
Quality / test (push) Has been cancelled
integrate heating rule fix and quality workflow
2026-06-10 21:59:38 +02:00

32 lines
1.0 KiB
Python

from __future__ import annotations
from collections.abc import Sequence
from app.ha.models import HaEntitySummary
from app.rules.recommender import Rule
HEATING_SENSOR_DEVICE_CLASSES = frozenset({"temperature", "humidity"})
HEATING_BINARY_SENSOR_DEVICE_CLASSES = frozenset({"occupancy", "presence"})
class HeatingRule(Rule):
def matches(self, entities: Sequence[HaEntitySummary]) -> bool:
for entity in entities:
if entity.domain == "climate":
return True
if (
entity.domain == "sensor"
and entity.device_class in HEATING_SENSOR_DEVICE_CLASSES
):
return True
if (
entity.domain == "binary_sensor"
and entity.device_class in HEATING_BINARY_SENSOR_DEVICE_CLASSES
):
return True
return False
def recommendation(self, entities: Sequence[HaEntitySummary]) -> str:
return "Prüfe Heizungsregelung: Aktiviere energiesparenden Modus bei Abwesenheit."