-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathwallthermostat.py
More file actions
50 lines (44 loc) · 1.57 KB
/
Copy pathwallthermostat.py
File metadata and controls
50 lines (44 loc) · 1.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
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):
super(MaxWallThermostat, self).__init__()
self.comfort_temperature = None
self.eco_temperature = None
self.max_temperature = None
self.min_temperature = None
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",
f"mode={MODE_NAMES.get(self.mode, str(self.mode))}",
f"actual={self.actual_temperature}",
f"target={self.target_temperature}",
f"eco={self.eco_temperature}",
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())