Lux, motion and door script - Help
Posted: Monday 12 March 2018 13:17
Hi there!
Can someone please help me get this working.
Cant find out why it wont Off.
My intention is when every device is closed the light is Off.
Can someone please help me get this working.
Cant find out why it wont Off.
My intention is when every device is closed the light is Off.
Code: Select all
commandArray = {}
a = 'Motion sensor'
b = 'Light'
c = 'door contact'
d = 'lux'
t = 'DUMMY'
e = 500 -- Lys på ved Lux under verdien i (e)
h = tonumber((os.date('%H')))
if (h >= 8 and h < 21)
then
x = 'Scene:Lys i yttergang 99%'
else
x = 'Scene:Lys i yttergang 40%'
end
-- verdi fra Lux sensor
V = otherdevices_svalues[d]
-- Remove charachters from datastring
function stripchars(str, chrs)
local s = str:gsub("["..chrs.."]", '')
return s end
-- Remove " Lux" from V
w = stripchars( V, " Lux" )
if (tonumber(w) <= e and devicechanged[t]=='On' or devicechanged[a]=='On' or devicechanged[c]=='On') then
commandArray[x]='On'
else
if (devicechanged[t]=='Off' and devicechanged[a]=='Off' and devicechanged[c]=='Off') then
commandArray['Scene:Yttergang Off']='On'
end
end
return commandArray