Always publish the temperatur

This commit is contained in:
Ollo 2022-01-20 22:06:03 +01:00
parent 2322276745
commit aba8e21406

View File

@ -6,8 +6,6 @@ tcol=nil
-- Mqtt variable -- Mqtt variable
local mMqttClient=nil local mMqttClient=nil
local mMqttConnected = false local mMqttConnected = false
-- Read Temp
local mOldTemp=nil
function handleSingleCommand(client, topic, data) function handleSingleCommand(client, topic, data)
if (data == "ON") then if (data == "ON") then
@ -222,7 +220,6 @@ function startMqttClient()
end) end)
lSetupTimer:start() lSetupTimer:start()
local loldBrightness=0 local loldBrightness=0
mOldTemp=0
local lMqttTimer = tmr.create() local lMqttTimer = tmr.create()
local tempCounter=0 local tempCounter=0
-- Check every 12 seconds -- Check every 12 seconds
@ -253,8 +250,7 @@ function startMqttClient()
tempCounter = tempCounter + 1 tempCounter = tempCounter + 1
end end
collectgarbage() collectgarbage()
if (temperatur ~= nil and temperatur ~= mOldTemp) then if (temperatur ~= nil) then
mOldTemp = temperatur
mMqttClient:publish(mqttPrefix .. "/temp", tostring(temperatur/100)..".".. tostring(temperatur%100), 0, 0) mMqttClient:publish(mqttPrefix .. "/temp", tostring(temperatur/100)..".".. tostring(temperatur%100), 0, 0)
else else
mMqttClient:publish(mqttPrefix .. "/heap", tostring(heapusage), 0, 0) mMqttClient:publish(mqttPrefix .. "/heap", tostring(heapusage), 0, 0)