Lux, motion and door script - Help

Moderator: leecollings

Post Reply
frankh
Posts: 2
Joined: Monday 12 March 2018 13:04
Target OS: -
Domoticz version:
Contact:

Lux, motion and door script - Help

Post by frankh »

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.

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
frankh
Posts: 2
Joined: Monday 12 March 2018 13:04
Target OS: -
Domoticz version:
Contact:

Re: Lux, motion and door script - [SOLVED]

Post by frankh »

I did find out :D

if (devicechanged[t]=='Off' and otherdevices[a]=='Off' and otherdevices[c]=='Off') then
commandArray['Scene:Yttergang Off']='On'

:lol:
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 1 guest