From 40447dd521533e2d984bb409e5a7fbd296e653ea Mon Sep 17 00:00:00 2001 From: Ollo Date: Wed, 10 Feb 2021 19:45:28 +0100 Subject: [PATCH] Used more local variables --- main.lua | 2 +- mqtt.lua | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/main.lua b/main.lua index 1f04a16..7bb98a4 100644 --- a/main.lua +++ b/main.lua @@ -84,7 +84,7 @@ function normalOperation() end print("Fg Color: " .. tostring(string.byte(color,1)) .. "x" .. tostring(string.byte(color,2)) .. "x" .. tostring(string.byte(color,3)) ) - connect_counter=0 + local connect_counter=0 -- Wait to be connect to the WiFi access point. local wifitimer = tmr.create() wifitimer:register(5000, tmr.ALARM_SINGLE, function (t) diff --git a/mqtt.lua b/mqtt.lua index 7346850..ae5efc4 100644 --- a/mqtt.lua +++ b/mqtt.lua @@ -1,8 +1,8 @@ -- Global variable -m=nil -mqttConnected = false +local m=nil +local mqttConnected = false -- Temp: -t=nil +local t=nil function handleSingleCommand(client, topic, data) if (data == "ON") then @@ -157,7 +157,6 @@ function startMqttClient() local temp = nil if (t ~= nil) then temp=readTemp() - print(tostring(temp) .. "°C") end if (oldBrightness ~= briPercent) then m:publish(mqttPrefix .. "/brightness", tostring(briPercent), 0, 0)