10 os.execute(string.format("rrdtool update /home/sensordata.rrd -t temp:light:movement N:%f:%d:%d", last_temp, last_light, last_movement))
15 function parse_value(str)
16 if string.find(str,"Temp C:") then
17 last_temp = tonumber(string.sub(str,11))
18 --print(string.format("t: %f Grad Celsius",last_temp))
20 if string.find(str,"Photo:") then
21 last_light = tonumber(string.sub(str,10))
22 --print(string.format("p: %d",last_light))
24 if string.find(str,"movement") then
26 --print "something moved"
31 local socket = require("socket")
34 local client = socket.connect("127.0.0.1",2010)
35 --socket.unix = require("socket.unix")
36 --local socket = assert(socket.unix())
37 --local client = assert(socket:connect("/var/run/power_sensor.socket"))
41 local line, err = client:receive()
44 elseif err ~= "timeout" then
48 line, err = client:receive()
51 elseif err ~= "timeout" then
55 line, err = client:receive()
58 elseif err ~= "timeout" then
63 client:shutdown("both")
65 socket.select(nil, nil, 10)