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)
17 if string.find(str,"Sensor T: Temp C:") then
18 last_temp = tonumber(string.sub(str,18))
19 os.execute(string.format("rrdtool update /home/sensordata.rrd -t temp N:%f", last_temp))
20 print(string.format("t: %f Grad Celsius",last_temp))
22 if string.find(str,"Sensor P: Photo:") then
23 last_light = tonumber(string.sub(str,17))
24 os.execute(string.format("rrdtool update /home/sensordata.rrd -t light N:%d", last_light))
25 print(string.format("p: %d",last_light))
27 if string.find(str,"movement") then
29 os.execute(string.format("rrdtool update /home/sensordata.rrd -t movement N:%d", 1))
34 local socket_factory = require("socket.unix");
35 local socket = socket_factory()
39 local client = socket.connect("/var/run/powersensordaemon/cmd.sock")
41 client:send("listen sensor\n")
42 --client:settimeout(30)
44 local line, err = client:receive()
47 elseif err ~= "timeout" then
51 client:shutdown("both")
54 socket.select(nil, nil, 10)