comparison web/log.py @ 582:cebec9b40ad2

merge
author Matt Johnston <matt@ucc.asn.au>
date Mon, 30 Nov 2015 21:45:17 +0800
parents b4d6f1ae0b9e
children 61269311ed3d
comparison
equal deleted inserted replaced
580:2ab866ee4f8c 582:cebec9b40ad2
48 else: 48 else:
49 args = [ 49 args = [
50 '--step', '300', 50 '--step', '300',
51 'DS:temp:GAUGE:600:-100:500', 51 'DS:temp:GAUGE:600:-100:500',
52 'RRA:AVERAGE:0.5:1:1051200'] 52 'RRA:AVERAGE:0.5:1:1051200']
53
54 print>>sys.stderr, sensor_rrd_path(sensor_id)
55 53
56 rrdtool.create(sensor_rrd_path(sensor_id), 54 rrdtool.create(sensor_rrd_path(sensor_id),
57 '--start', 'now-60d', 55 '--start', 'now-60d',
58 *args) 56 *args)
59 57
141 139
142 # lines are done afterwards so they can be layered 140 # lines are done afterwards so they can be layered
143 sensor_lines.sort(key = lambda (legend, line): "Wort" in legend) 141 sensor_lines.sort(key = lambda (legend, line): "Wort" in legend)
144 graph_args += (line for (legend, line) in sensor_lines) 142 graph_args += (line for (legend, line) in sensor_lines)
145 143
146 print>>sys.stderr, '\n'.join(graph_args) 144 #print>>sys.stderr, '\n'.join(graph_args)
147
148 145
149 end = int(start+length) 146 end = int(start+length)
150 start = int(start) 147 start = int(start)
151 148
152 tempf = tempfile.NamedTemporaryFile() 149 tempf = tempfile.NamedTemporaryFile()
287 284
288 timedelta = time.time() - start_time 285 timedelta = time.time() - start_time
289 debugf.write("Updated sensors in %.2f secs\n" % timedelta) 286 debugf.write("Updated sensors in %.2f secs\n" % timedelta)
290 debugf.flush() 287 debugf.flush()
291 288
289 # types used here define the type of a field
292 _FIELD_DEFAULTS = { 290 _FIELD_DEFAULTS = {
293 'fridge_setpoint': 16.0, 291 'fridge_setpoint': 16.0,
294 'fridge_difference': 0.2, 292 'fridge_difference': 0.2,
295 'overshoot_delay': 720, # 12 minutes 293 'overshoot_delay': 720, # 12 minutes
296 'overshoot_factor': 1, # ºC 294 'overshoot_factor': 1.0, # ºC
297 'disabled': False, 295 'disabled': False,
298 'nowort': True, 296 'nowort': True,
299 'fridge_range_lower': 3, 297 'fridge_range_lower': 3,
300 'fridge_range_upper': 3, 298 'fridge_range_upper': 3,
301 } 299 }
302 300
303 def get_params(): 301 def get_params():
302 """ Can return None if there aren't any parameters yet,
303 otherwise returns the parameter list """
304 304
305 r = [] 305 r = []
306 306
307 vals = read_current_params() 307 vals = read_current_params()
308 if not vals:
309 return None
308 310
309 for k, v in _FIELD_DEFAULTS.iteritems(): 311 for k, v in _FIELD_DEFAULTS.iteritems():
310 n = {'name': k, 'value': type(v)(vals[k])} 312 n = {'name': k, 'value': type(v)(vals[k])}
311 if type(v) is bool: 313 if type(v) is bool:
312 kind = 'yesno' 314 kind = 'yesno'