-
Notifications
You must be signed in to change notification settings - Fork 3
/
state.py
48 lines (43 loc) · 916 Bytes
/
state.py
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
import joblib as joblib
from devices.fan import MAX_SPEED
from datetime import datetime
STATE_PATH = 'state.joblib'
STATE = {
'fan': {
'top': MAX_SPEED,
'bottom': MAX_SPEED
},
'thermometer': {
'top': None,
'bottom': None,
'external': None
},
'light': {
'1': 'OFF',
'2': 'OFF'
},
'humidity': {
'humidity': None,
'temperature': None
},
'co2': {
'co2': None,
'temperature': None
},
'soil_moisture': {
'top': None,
'bottom': None
},
'last_watering_time': {
'top': datetime.now(),
'bottom': datetime.now()
},
'heat': None
}
try:
_state = joblib.load(STATE_PATH)
STATE['last_watering_time'] = _state['last_watering_time']
STATE['light'] = _state['light']
STATE['heat'] = _state['heat']
except FileNotFoundError:
pass