projects
/
weathermon.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
9b024ef
)
Обработка сообщений MQTT в формате rtl_433
author
Roman Bazalevsky
<rvb@rvb.name>
Tue, 2 Jun 2020 14:16:25 +0000
(17:16 +0300)
committer
Roman Bazalevsky
<rvb@rvb.name>
Tue, 2 Jun 2020 14:16:25 +0000
(17:16 +0300)
server/weathermon-mqtt
patch
|
blob
|
history
diff --git
a/server/weathermon-mqtt
b/server/weathermon-mqtt
index 025deec54de5d4e3f5773fead99f765233409cc2..809b4e9521e85354b6fcc10e6945184122a717c2 100755
(executable)
--- a/
server/weathermon-mqtt
+++ b/
server/weathermon-mqtt
@@
-15,15
+15,25
@@
end
function process_MSG(mid, topic, payload)
print(topic, payload)
pcall(function(topic,payload)
function process_MSG(mid, topic, payload)
print(topic, payload)
pcall(function(topic,payload)
+ print(payload)
payload = json.decode(payload)
local time = os.date(payload['Time'])
payload = json.decode(payload)
local time = os.date(payload['Time'])
+ if not time then time = os.date(payload['time']); end
+ local model = payload['model']
+ local id = payload['id']
for sensor_type,sensor_data in pairs(payload) do
for sensor_type,sensor_data in pairs(payload) do
- if sensor_type ~= "Time" and sensor_type ~= "TempUnit" then
- for param,value in pairs(sensor_data) do
- conn:execute(string.format("CALL meteo.submit_mqtt('%s','%s','%s','%s',NULL)", topic,
sensor_type,param,value
))
+ if sensor_type ~= "Time" and sensor_type ~= "TempUnit"
and sensor_type ~= "model" and sensor_type ~="id" and sensor_type ~= "time"
then
+ if model then
+ conn:execute(string.format("CALL meteo.submit_mqtt('%s','%s','%s','%s',NULL)", topic,
model,sensor_type,sensor_data
))
conn:commit()
conn:commit()
- print(topic,sensor_type,param,value)
- end
+ print(topic,model,sensor_type,sensor_data)
+ else
+ for param,value in pairs(sensor_data) do
+ conn:execute(string.format("CALL meteo.submit_mqtt('%s','%s','%s','%s',NULL)", topic,sensor_type,param,value))
+ conn:commit()
+ print(topic,sensor_type,param,value)
+ end
+ end
end
end
end, topic, payload)
end
end
end, topic, payload)