projects
/
weathermon.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Добавлена опциональная авторизация MQTT
[weathermon.git]
/
weathermon.lua
diff --git
a/weathermon.lua
b/weathermon.lua
index c97983058796ddaf275bcc6c9417d8d69b6da35a..5e193487d37bbdeeca22f122a8ed4f3b35a50a92 100755
(executable)
--- a/
weathermon.lua
+++ b/
weathermon.lua
@@
-59,6
+59,9
@@
function getConfig()
mqtt_topic = cur.get(config,"mqtt","topic")
mqtt_alarm_topic = cur.get(config,"mqtt","alarm_topic")
mqtt_topic = cur.get(config,"mqtt","topic")
mqtt_alarm_topic = cur.get(config,"mqtt","alarm_topic")
+ mqtt_user = cur.get(config,"mqtt","user")
+ mqtt_passwd = cur.get(config,"mqtt","password")
+
if mqtt_host and not mqtt_id then
mqtt_id="weather-"..web_devid
end
if mqtt_host and not mqtt_id then
mqtt_id="weather-"..web_devid
end
@@
-129,6
+132,7
@@
function submitValue(type,id,param,val)
command = command.." \""..url.."\""
os.execute(command)
command = command.." \""..url.."\""
os.execute(command)
+ print()
end
end
@@
-216,6
+220,9
@@
getConfig()
if mqtt_host then
MQTT = require "paho.mqtt"
mqtt_client = MQTT.client.create(mqtt_host, mqtt_port)
if mqtt_host then
MQTT = require "paho.mqtt"
mqtt_client = MQTT.client.create(mqtt_host, mqtt_port)
+ if mqtt_user then
+ mqtt_client:auth(mqtt_user, mqtt_passwd)
+ end
mqtt_client:connect(mqtt_id)
json = require( "json" )
end
mqtt_client:connect(mqtt_id)
json = require( "json" )
end