9 os.execute(string.format("rrdtool update /home/sensordata.rrd -t temp:light:movement N:%f:%d:%d", last_temp, last_light, last_movement))
14 function parse_value(str)
15 if string.find(str,"Temp C:") then
16 last_temp = tonumber(string.sub(str,11))
17 --print(string.format("t: %f Grad Celsius",last_temp))
19 if string.find(str,"Photo:") then
20 last_light = tonumber(string.sub(str,10))
21 --print(string.format("p: %d",last_light))
23 if string.find(str,"movement") then
25 --print "something moved"
30 local socket = require("socket")
33 local client = socket.connect("127.0.0.1",2010)
34 --socket.unix = require("socket.unix")
35 --local socket = assert(socket.unix())
36 --local client = assert(socket:connect("/var/run/power_sensor.socket"))
40 local line, err = client:receive()
43 elseif err ~= "timeout" then
47 line, err = client:receive()
50 elseif err ~= "timeout" then
54 line, err = client:receive()
57 elseif err ~= "timeout" then
62 client:shutdown("both")
64 socket.select(nil, nil, 10)