annotate py/config.py @ 305:6087c692d381

turn the fridge off if both sensors are broken
author Matt Johnston <matt@ucc.asn.au>
date Wed, 24 Jul 2019 23:24:51 +0800
parents 9e2181e3ce6d
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
162
d73077e8cd67 Add daemon mode with locking, add "disabled" parameter
Matt Johnston <matt@ucc.asn.au>
parents: 160
diff changeset
1 import os.path
148
b32e5a11a4cb few updates, seems to run
Matt Johnston <matt@ucc.asn.au>
parents: 145
diff changeset
2
220
251524081924 make the fridge off timer more robust
Matt Johnston <matt@ucc.asn.au>
parents: 176
diff changeset
3 FRIDGE_SLEEP = 60 # this value works. may affect the algorithm
251524081924 make the fridge off timer more robust
Matt Johnston <matt@ucc.asn.au>
parents: 176
diff changeset
4 SENSOR_SLEEP = 15 # same for this.
251524081924 make the fridge off timer more robust
Matt Johnston <matt@ucc.asn.au>
parents: 176
diff changeset
5 UPLOAD_SLEEP = 83 # nice and prime
148
b32e5a11a4cb few updates, seems to run
Matt Johnston <matt@ucc.asn.au>
parents: 145
diff changeset
6
220
251524081924 make the fridge off timer more robust
Matt Johnston <matt@ucc.asn.au>
parents: 176
diff changeset
7 FRIDGE_DELAY = 600 # 10 mins, to avoid fridge damage from frequent cycling off/on
305
6087c692d381 turn the fridge off if both sensors are broken
Matt Johnston <matt@ucc.asn.au>
parents: 285
diff changeset
8
6087c692d381 turn the fridge off if both sensors are broken
Matt Johnston <matt@ucc.asn.au>
parents: 285
diff changeset
9 # time to wait before just using fridge for fallback
6087c692d381 turn the fridge off if both sensors are broken
Matt Johnston <matt@ucc.asn.au>
parents: 285
diff changeset
10 FRIDGE_WORT_INVALID_TIME = 180 # 3 minutes
6087c692d381 turn the fridge off if both sensors are broken
Matt Johnston <matt@ucc.asn.au>
parents: 285
diff changeset
11 # time to wait before turning it off if neither sensors work.
6087c692d381 turn the fridge off if both sensors are broken
Matt Johnston <matt@ucc.asn.au>
parents: 285
diff changeset
12 # must be > FRIDGE_WORT_INVALID_TIME
6087c692d381 turn the fridge off if both sensors are broken
Matt Johnston <matt@ucc.asn.au>
parents: 285
diff changeset
13 ALL_INVALID_TIME = 480 # 8 minutes
145
6517ddee3187 few more bits
Matt Johnston <matt@ucc.asn.au>
parents: 144
diff changeset
14
220
251524081924 make the fridge off timer more robust
Matt Johnston <matt@ucc.asn.au>
parents: 176
diff changeset
15 # 12 hours of "offline" readings stored
264
205809a8872f integer division
Matt Johnston <matt@ucc.asn.au>
parents: 259
diff changeset
16 MAX_READINGS = 12*60*60 // SENSOR_SLEEP
160
256505f98c4d uploader works
Matt Johnston <matt@ucc.asn.au>
parents: 153
diff changeset
17
162
d73077e8cd67 Add daemon mode with locking, add "disabled" parameter
Matt Johnston <matt@ucc.asn.au>
parents: 160
diff changeset
18 PARAMS_FILE = os.path.join(os.path.dirname(__file__), 'tempserver.conf')
148
b32e5a11a4cb few updates, seems to run
Matt Johnston <matt@ucc.asn.au>
parents: 145
diff changeset
19
285
9e2181e3ce6d back to w1_bus_master1
Matt Johnston <matt@ucc.asn.au>
parents: 282
diff changeset
20 SENSOR_BASE_DIR = '/sys/devices/w1_bus_master1'
228
d9e81a563923 porting to asyncio
Matt Johnston <matt@ucc.asn.au>
parents: 220
diff changeset
21 FRIDGE_GPIO_PIN = 17
266
20c89630be6c emergency change sensor config
Matt Johnston <matt@ucc.asn.au>
parents: 264
diff changeset
22 #WORT_NAME = '28-0000042cf4dd'
20c89630be6c emergency change sensor config
Matt Johnston <matt@ucc.asn.au>
parents: 264
diff changeset
23 #FRIDGE_NAME = '28-0000042cccc4'
20c89630be6c emergency change sensor config
Matt Johnston <matt@ucc.asn.au>
parents: 264
diff changeset
24 #AMBIENT_NAME = '28-0000042c6dbb'
20c89630be6c emergency change sensor config
Matt Johnston <matt@ucc.asn.au>
parents: 264
diff changeset
25 AMBIENT_NAME = 'missingambient'
282
d3ebdb1d6a55 fridge sensor is back
Matt Johnston <matt@ucc.asn.au>
parents: 274
diff changeset
26 FRIDGE_NAME = '28-0000042c6dbb'
266
20c89630be6c emergency change sensor config
Matt Johnston <matt@ucc.asn.au>
parents: 264
diff changeset
27 WORT_NAME = '28-0000042cccc4' # was fridge
151
e114b38c8a55 internal temperature sensor
Matt Johnston <matt@ucc.asn.au>
parents: 149
diff changeset
28 INTERNAL_TEMPERATURE = '/sys/class/thermal/thermal_zone0/temp'
160
256505f98c4d uploader works
Matt Johnston <matt@ucc.asn.au>
parents: 153
diff changeset
29
256505f98c4d uploader works
Matt Johnston <matt@ucc.asn.au>
parents: 153
diff changeset
30 HMAC_KEY = "a key"
259
26eee8591f61 long polling works
Matt Johnston <matt@ucc.asn.au>
parents: 253
diff changeset
31 SERVER_URL = 'https://evil.ucc.asn.au/~matt/templog'
253
0a1b642e3086 long polling config updates
Matt Johnston <matt@ucc.asn.au>
parents: 228
diff changeset
32 UPDATE_URL = "%s/update" % SERVER_URL
259
26eee8591f61 long polling works
Matt Johnston <matt@ucc.asn.au>
parents: 253
diff changeset
33 SETTINGS_URL = "%s/get_settings" % SERVER_URL
160
256505f98c4d uploader works
Matt Johnston <matt@ucc.asn.au>
parents: 153
diff changeset
34
220
251524081924 make the fridge off timer more robust
Matt Johnston <matt@ucc.asn.au>
parents: 176
diff changeset
35 # site-local values overridden in localconfig, eg WORT_NAME, HMAC_KEY
160
256505f98c4d uploader works
Matt Johnston <matt@ucc.asn.au>
parents: 153
diff changeset
36 try:
256505f98c4d uploader works
Matt Johnston <matt@ucc.asn.au>
parents: 153
diff changeset
37 from localconfig import *
256505f98c4d uploader works
Matt Johnston <matt@ucc.asn.au>
parents: 153
diff changeset
38 except ImportError:
256505f98c4d uploader works
Matt Johnston <matt@ucc.asn.au>
parents: 153
diff changeset
39 pass