Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix programme wall thermostat #46

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion maxcube/cube.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
28 changes: 27 additions & 1 deletion maxcube/wallthermostat.py
Original file line number Diff line number Diff line change
@@ -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):
Expand All @@ -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",
Expand All @@ -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())