X-Git-Url: https://git.rvb.name/weathermon.git/blobdiff_plain/333cb703da2fbe639e6eb9d630e4f4221cc26d36..7edb3771717d15f7c36d8459fa12b3d6f76d7d9a:/weathermon.lua diff --git a/weathermon.lua b/weathermon.lua index 72e4895..3208e30 100755 --- a/weathermon.lua +++ b/weathermon.lua @@ -1,7 +1,7 @@ #!/usr/bin/lua -require("json") -require("socket") +json = require("json") +socket = require("socket") function startswith(String,Start) if String then @@ -211,6 +211,10 @@ function processJson(str) end end + if not sensor_id then + sensor_id = web_devid + end + if not (sensor_type==nil or sensor_id==nil or sensor_type=='' or sensor_id=='') then if next(sensor)==nil then sensor["command"]="alarm" @@ -237,7 +241,7 @@ function processJson(str) end end else - printLog("Cannot parse sensor input: "..msg_body) + printLog("Cannot parse sensor input: "..str) end end @@ -371,7 +375,7 @@ else return end while 1 do - line=serialin:read() + line=serialin:read("*l") if line == nil then break end @@ -379,6 +383,6 @@ while 1 do if startswith(line,'{') then processJson(line) else - processLine(line) + processLine(line) end end