X-Git-Url: https://git.rvb.name/weathermon.git/blobdiff_plain/e32107a7fe79ce34f3bdf860410a6d5455efdca7..c58ad4fb6f2c4c350a6aae01b100ebb4564ad8e9:/bin/weathermon-iio?ds=sidebyside diff --git a/bin/weathermon-iio b/bin/weathermon-iio index 7fe5f68..cbf21f0 100755 --- a/bin/weathermon-iio +++ b/bin/weathermon-iio @@ -188,17 +188,20 @@ if not delay then 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