From 30a2295fb14fc5ec35593ca43ce599ea0dc9c188 Mon Sep 17 00:00:00 2001 From: MassiPi <2384381+MassiPi@users.noreply.github.com> Date: Mon, 17 Jul 2023 21:56:50 +0200 Subject: [PATCH 1/2] Update cube.py - Getting program also from wall thermostat Getting weekly program also for wall thermostat. The C message is slightly different for wall thermostat, the programme starts with byte 22, but it's lenght must be fixed to 182 since is followed by 3 unknown bytes --- maxcube/cube.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 From fdaa93ec0f81435cb70d951eef2dcc4c02020c00 Mon Sep 17 00:00:00 2001 From: MassiPi <2384381+MassiPi@users.noreply.github.com> Date: Mon, 17 Jul 2023 21:58:59 +0200 Subject: [PATCH 2/2] Update wallthermostat.py - Manage programme need to manage weekly program also for wall thermostats to fix error in home assistant integration --- maxcube/wallthermostat.py | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) 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())