I try to make my first LUA script to warn me if the temperature is bellow/ower a number
the script works perfect in my LUA editor ZeroBrane Studio (with temp as a variable), but when I try it in Domoticz I got this message:
Error: EventSystem: in Kjøleskap alarm: [string " ..."]:18: attempt to compare number with nil
Code: Select all
--- Configuration
local temp = 'Kjøleskap'
local upper_temp_limit = 15
local lower_temp_limit = 2
local upper_temp_limit_warning_msg = "Øvre temperaturgrense " .. upper_temp_limit .. "ºC er nådd!"
local lower_temp_limit_warning_msg = "Nedre temperaturgrense " .. upper_temp_limit .. "ºC er nådd!"
--commandArray = {}
temp = tonumber(temp)
if (warning_sent == nil) then
warning_sent = false
end
if (upper_temp_limit < temp and warning_sent ~= true) then
print(upper_temp_limit_warning_msg)
warning_sent = true
elseif (lower_temp_limit > temp and warning_sent ~= true) then
print(lower_temp_limit_warning_msg)
warning_sent = true
elseif (upper_temp_limit > temp and lower_temp_limit < temp) then
print("Temp ok")
warning_sent = false
end
--return commandArray
Anyone se what's wrong? also, do I need the CommandArray thing? (gives the same result with and without)