diff --git a/maxcube/cube.py b/maxcube/cube.py index 5734e92..c7b3cf4 100644 --- a/maxcube/cube.py +++ b/maxcube/cube.py @@ -148,7 +148,8 @@ def parse_c_message(self, message): device.eco_temperature = data[19] / 2.0 device.max_temperature = data[20] / 2.0 device.min_temperature = data[21] / 2.0 - + device.programme = get_programme(data[22:204]) + if device and device.is_windowshutter(): # Pure Speculation based on this: # Before: [17][12][162][178][4][0][20][15]KEQ0839778 diff --git a/maxcube/wallthermostat.py b/maxcube/wallthermostat.py index c527a65..2359307 100644 --- a/maxcube/wallthermostat.py +++ b/maxcube/wallthermostat.py @@ -1,5 +1,17 @@ +from datetime import datetime +from typing import Dict, List + from maxcube.device import MODE_NAMES, MaxDevice +PROG_DAYS = [ + "monday", + "tuesday", + "wednesday", + "thursday", + "friday", + "saturday", + "sunday", +] class MaxWallThermostat(MaxDevice): def __init__(self): @@ -11,7 +23,8 @@ def __init__(self): self.actual_temperature = None self.target_temperature = None self.mode = None - + self.programme: Dict[str, List[Dict[str, int]]] = {} + def __str__(self): return self.describe( "WALLTHERMO", @@ -22,3 +35,16 @@ def __str__(self): f"comfort={self.comfort_temperature}", f"range=[{self.min_temperature},{self.max_temperature}]", ) + + def get_programmed_temp_at(self, dt: datetime): + """Retrieve the programmed temperature at the given instant.""" + weekday = PROG_DAYS[dt.weekday()] + time = f"{dt.hour:02}:{dt.minute:02}" + for point in self.programme.get(weekday, []): + if time < point["until"]: + return point["temp"] + return None + + def get_current_temp_in_auto_mode(self): + """DEPRECATED: use get_programmed_temp_at instead.""" + return self.get_programmed_temp_at(datetime.now())