Used more local variables
This commit is contained in:
parent
7941501cc5
commit
40447dd521
2
main.lua
2
main.lua
@ -84,7 +84,7 @@ function normalOperation()
|
|||||||
end
|
end
|
||||||
print("Fg Color: " .. tostring(string.byte(color,1)) .. "x" .. tostring(string.byte(color,2)) .. "x" .. tostring(string.byte(color,3)) )
|
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.
|
-- Wait to be connect to the WiFi access point.
|
||||||
local wifitimer = tmr.create()
|
local wifitimer = tmr.create()
|
||||||
wifitimer:register(5000, tmr.ALARM_SINGLE, function (t)
|
wifitimer:register(5000, tmr.ALARM_SINGLE, function (t)
|
||||||
|
7
mqtt.lua
7
mqtt.lua
@ -1,8 +1,8 @@
|
|||||||
-- Global variable
|
-- Global variable
|
||||||
m=nil
|
local m=nil
|
||||||
mqttConnected = false
|
local mqttConnected = false
|
||||||
-- Temp:
|
-- Temp:
|
||||||
t=nil
|
local t=nil
|
||||||
|
|
||||||
function handleSingleCommand(client, topic, data)
|
function handleSingleCommand(client, topic, data)
|
||||||
if (data == "ON") then
|
if (data == "ON") then
|
||||||
@ -157,7 +157,6 @@ function startMqttClient()
|
|||||||
local temp = nil
|
local temp = nil
|
||||||
if (t ~= nil) then
|
if (t ~= nil) then
|
||||||
temp=readTemp()
|
temp=readTemp()
|
||||||
print(tostring(temp) .. "°C")
|
|
||||||
end
|
end
|
||||||
if (oldBrightness ~= briPercent) then
|
if (oldBrightness ~= briPercent) then
|
||||||
m:publish(mqttPrefix .. "/brightness", tostring(briPercent), 0, 0)
|
m:publish(mqttPrefix .. "/brightness", tostring(briPercent), 0, 0)
|
||||||
|
Loading…
Reference in New Issue
Block a user