comparison web/log.py @ 425:eb685e1afcbb

ui tweaks, add fridge values
author Matt Johnston <matt@ucc.asn.au>
date Thu, 11 Oct 2012 19:19:24 +0800
parents 96bec5482294
children 719d5669ab27
comparison
equal deleted inserted replaced
424:96bec5482294 425:eb685e1afcbb
32 if 'voltage' in sensor_id: 32 if 'voltage' in sensor_id:
33 args = [ 33 args = [
34 '--step', '3600', 34 '--step', '3600',
35 'DS:temp:GAUGE:7200:1:10', 35 'DS:temp:GAUGE:7200:1:10',
36 'RRA:AVERAGE:0.5:1:87600'] 36 'RRA:AVERAGE:0.5:1:87600']
37 elif 'fridge_on' in sensor_id:
38 args = [
39 '--step', '300',
40 'DS:temp:GAUGE:600:-100:500',
41 'RRA:LAST:0.5:1:1051200']
37 else: 42 else:
38 args = [ 43 args = [
39 '--step', '300', 44 '--step', '300',
40 'DS:temp:GAUGE:600:-100:500', 45 'DS:temp:GAUGE:600:-100:500',
41 'RRA:AVERAGE:0.5:1:1051200'] 46 'RRA:AVERAGE:0.5:1:1051200']
60 rrds = all_sensors() 65 rrds = all_sensors()
61 66
62 graph_args = [] 67 graph_args = []
63 have_volts = False 68 have_volts = False
64 for n, (rrdfile, sensor) in enumerate(rrds): 69 for n, (rrdfile, sensor) in enumerate(rrds):
70 unit = None
65 if 'avrtemp' in sensor: 71 if 'avrtemp' in sensor:
66 continue 72 continue
67 if 'voltage' in sensor: 73 if 'voltage' in sensor:
68 have_volts = True 74 have_volts = True
69 vname = 'scalevolts' 75 vname = 'scalevolts'
70 graph_args.append('DEF:%(vname)s=%(rrdfile)s:temp:AVERAGE:step=3600' % locals()) 76 graph_args.append('DEF:%(vname)s=%(rrdfile)s:temp:AVERAGE:step=3600' % locals())
71 unit = 'V' 77 unit = 'V'
78 elif 'fridge_on' in sensor:
79 vname = 'fridge_on'
80 graph_args.append('DEF:raw%(vname)s=%(rrdfile)s:temp:LAST' % locals())
81 graph_args.append('CDEF:%(vname)s=raw%(vname)s,3,+' % locals())
72 else: 82 else:
73 vname = 'temp%d' % n 83 vname = 'temp%d' % n
74 graph_args.append('DEF:raw%(vname)s=%(rrdfile)s:temp:AVERAGE' % locals()) 84 graph_args.append('DEF:raw%(vname)s=%(rrdfile)s:temp:AVERAGE' % locals())
75 # limit max temp to 50 85 # limit max temp to 50
76 graph_args.append('CDEF:%(vname)s=raw%(vname)s,35,GT,UNKN,raw%(vname)s,0.1,*,2,+,IF' % locals()) 86 graph_args.append('CDEF:%(vname)s=raw%(vname)s,35,GT,UNKN,raw%(vname)s,0.1,*,2,+,IF' % locals())
77 unit = '<span face="Liberation Serif">º</span>C' 87 unit = '<span face="Liberation Serif">º</span>C'
78 88
79 try: 89 format_last_value = None
80 last_value = float(rrdtool.info(rrdfile)['ds[temp].last_ds']) 90 if unit:
81 format_last_value = ('%f' % last_value).rstrip('0') + unit 91 try:
82 except ValueError: 92 last_value = float(rrdtool.info(rrdfile)['ds[temp].last_ds'])
83 format_last_value = 'Bad' 93 format_last_value = ('%f' % last_value).rstrip('0.') + unit
94 except ValueError:
95 pass
84 width = config.LINE_WIDTH 96 width = config.LINE_WIDTH
85 legend = config.SENSOR_NAMES.get(sensor, sensor) 97 legend = config.SENSOR_NAMES.get(sensor, sensor)
86 colour = config.SENSOR_COLOURS.get(legend, colour_from_string(sensor)) 98 colour = config.SENSOR_COLOURS.get(legend, colour_from_string(sensor))
87 print_legend = '%s (%s)' % (legend, format_last_value) 99 if format_last_value:
100 print_legend = '%s (%s)' % (legend, format_last_value)
101 else:
102 print_legend = legend
88 graph_args.append('LINE%(width)f:%(vname)s#%(colour)s:%(print_legend)s' % locals()) 103 graph_args.append('LINE%(width)f:%(vname)s#%(colour)s:%(print_legend)s' % locals())
89 104
90 end = int(start+length) 105 end = int(start+length)
91 start = int(start) 106 start = int(start)
92 107
232 247
233 if 'voltage' in entries: 248 if 'voltage' in entries:
234 voltage = 0.001 * int(entries['voltage']) 249 voltage = 0.001 * int(entries['voltage'])
235 sensor_update('voltage', [voltage], time.time(), 1) 250 sensor_update('voltage', [voltage], time.time(), 1)
236 251
252 if 'fridge_status' in entries:
253 fridge_on = int(entries['fridge_status'])
254 sensor_update('fridge_on', [fridge_on], time.time(), 1)
255
256 if 'fridge' in entries:
257 fridge_setpoint = float(entries['fridge'])
258 sensor_update('fridge_setpoint', [fridge_setpoint], time.time(), 1)
237 #sqlite 259 #sqlite
238 # - time 260 # - time
239 # - voltage 261 # - voltage
240 # - boot time 262 # - boot time
241 263