summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDerf Null <derf@finalrewind.org>2023-04-23 20:09:33 +0200
committerDerf Null <derf@finalrewind.org>2023-04-23 20:09:33 +0200
commitc04c0e3a4074bb83fa61bca3840068a9eafd5189 (patch)
tree090d51948305a9cecf9f6302f8e291d7fad96f1d
parent9efbca177a1c113bfc7370b3c86e34f4066b56bd (diff)
do not re-use old influx_str if no data is available
-rw-r--r--init.lua3
1 files changed, 2 insertions, 1 deletions
diff --git a/init.lua b/init.lua
index 4c38550..68c8e3c 100644
--- a/init.lua
+++ b/init.lua
@@ -80,9 +80,10 @@ function uart_callback(data)
end
local json_str = string.format('{"rssi_dbm":%d,"period":"%s"', wifi.sta.getrssi(), work_period)
+ local influx_str = ""
if sds011.pm2_5i ~= nil then
json_str = string.format('%s,"pm2_5_ugm3":%d.%d,"pm10_ugm3":%d.%d', json_str, sds011.pm2_5i, sds011.pm2_5f, sds011.pm10i, sds011.pm10f)
- local influx_str = string.format("pm2_5_ugm3=%d.%d,pm10_ugm3=%d.%d", sds011.pm2_5i, sds011.pm2_5f, sds011.pm10i, sds011.pm10f)
+ influx_str = string.format("pm2_5_ugm3=%d.%d,pm10_ugm3=%d.%d", sds011.pm2_5i, sds011.pm2_5f, sds011.pm10i, sds011.pm10f)
end
json_str = json_str .. '}'