from __future__ import annotations from app.ha.models import HaEntitySummary from app.rules.heating import HeatingRule from app.rules.recommender import Recommender def _sensor(entity_id: str) -> HaEntitySummary: return HaEntitySummary(entity_id=entity_id, domain="sensor") def _climate(entity_id: str) -> HaEntitySummary: return HaEntitySummary(entity_id=entity_id, domain="climate") def test_heating_rule_triggers() -> None: rule = HeatingRule() assert rule.matches([_climate("climate.living_room")]) assert rule.matches([_sensor("sensor.temperature_living")]) def test_recommender_uses_rule() -> None: recommender = Recommender(rules=[HeatingRule()]) assert recommender.run([_climate("climate.living_room")]) == [ "Prüfe Heizungsregelung: Aktiviere energiesparenden Modus bei Abwesenheit." ]