From: Roman Bazalevsky Date: Thu, 15 Sep 2016 14:45:13 +0000 (+0300) Subject: Добавлена опциональная авторизация MQTT X-Git-Url: https://git.rvb.name/weathermon.git/commitdiff_plain/554351304ba5039e6b97f33729b3909eac0618d3 Добавлена опциональная авторизация MQTT --- diff --git a/weathermon.lua b/weathermon.lua index c979830..5e19348 100755 --- 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_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 @@ -129,6 +132,7 @@ function submitValue(type,id,param,val) command = command.." \""..url.."\"" os.execute(command) + print() 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_user then + mqtt_client:auth(mqtt_user, mqtt_passwd) + end mqtt_client:connect(mqtt_id) json = require( "json" ) end