3
# DigiTemp temperature and 1-wire home weather station graphing
4
# Copyright 2003 by Brian C. Lane <bcl@brianlane.com>
5
# http://www.digitemp.com
7
# Requires DigiTemp v3.1.0 or later for counter support
10
import string, os, sys, time
12
timefmt = '%Y-%m-%d %H:%M:%S'
14
# 1. Read the output of DigiTemp
15
cmd = '/home/brian/temperature/digitemp -c/home/brian/temperature/digitemp.cfg -a -q'
17
for outline in os.popen(cmd).readlines():
18
outline = outline[:-1]
21
if outline[0:1] == 'T':
22
# Parse the temperature sensor line
23
S = string.split(outline, " ")
26
# Add the reading to the database
27
sql = "INSERT INTO temperature VALUES(NULL, %s, %s, %s)"
28
sqltime = time.strftime( timefmt, time.localtime(int(S[2])))
29
cursor.execute( sql, (S[1], sqltime, S[3]) );
31
if outline[0:1] == 'C':
32
# Parse the counter line
33
S = string.split(outline, " ")
36
# Add the reading to the database
37
sql = "INSERT INTO counter VALUES(NULL, %s, %s, %s, %s)"
38
sqltime = time.strftime( timefmt, time.localtime(int(S[2])))
39
cursor.execute( sql, (S[1], sqltime, S[3], S[4]) );
41
# -----------------------------------------------------------------------
42
# Do interesting things with the just-logged information
43
# =======================================================================
46
#10E8A00E00000055 Room (grey wire)
47
#10B95E05000800AA Attic
48
#10575A050008008F Desk
49
#22B9B20500000049 DS1822
50
#286D1D2D000000EA DS18B20 (kermit)
51
#1092B9330008002E Drink
52
#1D9CB900000000B3 Rain Gauge
53
#1DFA15010000005F Wind Speed
54
#1009212E0008004B DT-1A passive sensor
57
# Dict of serial numbers and what to name them
58
sensors = {'10E8A00E00000055':'Office',
59
'10B95E05000800AA':'Attic',
60
'10575A050008008F':'Desk',
61
'22B9B20500000049':'DS1822',
62
'286D1D2D000000EA':'DS18B20',
63
'1092B9330008002E':'Drink',
64
'1009212E0008004B':'DT1A'
67
counters= {'1D9CB900000000B3':'Rain',
68
'1DFA15010000005F':'Wind'
72
f = 32.0 + ((c * 9.0) / 5.0)