config_name = "weathermon"
end
-web_id = uci.get(config_name,"web","devid")
+web_id = get_devid(config_name)
parameters = init(config_name)
delay = 60
end
+io.stdout:setvbuf('no')
+
while true do
- values = get_parameters(parameters)
- records = {}
- records[web_id] = {}
- for key,record in pairs(values) do
- records[web_id][key] = record
- records[web_id]["timestamp"] = os.date("%Y-%m-%dT%H:%M:%S")
- end
- for key,value in pairs(values) do
- value["device"] = key
- print(json.encode(value))
+ if pcall(function () values = get_parameters(parameters) end) then
+ records = {}
+ records[web_id] = {}
+ for key,record in pairs(values) do
+ records[web_id][key] = record
+ records[web_id]["timestamp"] = os.date("%Y-%m-%dT%H:%M:%S")
+ end
+ for key,value in pairs(values) do
+ value["device"] = key
+ print(json.encode(value))
+ end
end
socket.sleep(delay)
end