main: HeatingRule auf heizungsrelevante Sensoren begrenzen
This commit is contained in:
@@ -7,9 +7,28 @@ from app.rules.recommender import Rule
|
||||
|
||||
|
||||
class HeatingRule(Rule):
|
||||
"""Heizungsregel: Nur auf heizungsrelevante Entitäten reagieren.
|
||||
|
||||
Triggert bei:
|
||||
- `climate`-Entitäten direkt
|
||||
- `sensor` mit `device_class` in {temperature, humidity}
|
||||
- `binary_sensor` mit `device_class` in {occupancy, presence}
|
||||
|
||||
Alle anderen Domains/Device-Klassen bleiben ohne Effekt.
|
||||
"""
|
||||
|
||||
HEATING_SENSOR_CLASSES: frozenset[str] = frozenset({"temperature", "humidity"})
|
||||
HEATING_PRESENCE_CLASSES: frozenset[str] = frozenset({"occupancy", "presence"})
|
||||
|
||||
def matches(self, entities: Sequence[HaEntitySummary]) -> bool:
|
||||
domains = {item.domain for item in entities}
|
||||
return "climate" in domains or "sensor" in domains
|
||||
for item in entities:
|
||||
if item.domain == "climate":
|
||||
return True
|
||||
if item.domain == "sensor" and item.device_class in self.HEATING_SENSOR_CLASSES:
|
||||
return True
|
||||
if item.domain == "binary_sensor" and item.device_class in self.HEATING_PRESENCE_CLASSES:
|
||||
return True
|
||||
return False
|
||||
|
||||
def recommendation(self, entities: Sequence[HaEntitySummary]) -> str:
|
||||
return "Prüfe Heizungsregelung: Aktiviere energiesparenden Modus bei Abwesenheit."
|
||||
Reference in New Issue
Block a user