Page 1 of 1
Lights on when LUX <=500 else off
Posted: Sunday 30 December 2018 15:32
by EdwinK
I know I've seen such a script here somewhere, but searching for it doesn't find any.
What I need to do is when the LUX is below a set level (500 for example) it needs to turn on the outside lights. When the level is above the set level then turn it off again.
(The 500 is arbitrary, it could well be another level that I need, think twilight or dusk).
Re: Lights on when LUX <=500 else off
Posted: Sunday 30 December 2018 15:56
by waaren
EdwinK wrote: Sunday 30 December 2018 15:32
I know I've seen such a script here somewhere, but searching for it doesn't find any.
What I need to do is when the LUX is below a set level (500 for example) it needs to turn on the outside lights. When the level is above the set level then turn it off again.
(The 500 is arbitrary, it could well be another level that I need, think twilight or dusk).
In its most simple form
Code: Select all
-- outside lights
return {
on = { timer = { "every 15 minutes" } },
execute = function(dz)
lowerLux = 400
upperLux = 500
currentLux = dz.devices("lux device name").lux
outsideLight = dz.devices("outside light name")
if currentLux < lowerLux then
outsideLight.switchOn().checkFirst()
elseif currentLux > upperLux then
outsideLight.switchOff().checkFirst()
end
end
}
Re: Lights on when LUX <=500 else off
Posted: Sunday 30 December 2018 16:07
by EdwinK
Thanks. I like the most simple form's

. Just I have several switches. One called 'Lamp - Berging' and the others 'Buiten - 1' and 'Buiten - 2' Should have said that before

Re: Lights on when LUX <=500 else off
Posted: Sunday 30 December 2018 16:21
by waaren
EdwinK wrote: Sunday 30 December 2018 16:07
Thanks. I like the most simple form's

. Just I have several switches. One called 'Lamp - Berging' and the others 'Buiten - 1' and 'Buiten - 2' Should have said that before
If you always want to switch them together then probably easier to put them in a group. Please send me a PM if you want to discuss further
Re: Lights on when LUX <=500 else off
Posted: Sunday 30 December 2018 16:27
by EdwinK
Let's see if I can get that to work
Re: Lights on when LUX <=500 else off
Posted: Sunday 30 December 2018 17:32
by havnegata
Please, @waaren, continue to share your knowledge here in the forum and not by PM's. That way lots of people can learn, and I for sure have learned a lot from you!
Re: Lights on when LUX <=500 else off
Posted: Sunday 30 December 2018 17:41
by waaren
havnegata wrote: Sunday 30 December 2018 17:32
Please, @waaren, continue to share your knowledge here in the forum and not by PM's. That way lots of people can learn, and I for sure have learned a lot from you!
I will but sometimes the process of getting to a result require a lot of communication that is not very interesting for many.
I always ask to share the end-result when it can be of any use to others.
and.. thx for the compliment.
Re: Lights on when LUX <=500 else off
Posted: Sunday 30 December 2018 18:22
by EdwinK
O.. I will put the end result
Code: Select all
-- outside lights
return {
on = { timer = { "every 15 minutes" } },
execute = function(dz)
lowerLux = 400
upperLux = 500
currentLux = dz.devices("LUX").lux
outsideLights = dz.groups("Buitenlampen") --This should be a group, not a scene!!
if currentLux < lowerLux then
outsideLights.switchOn().checkFirst()
elseif currentLux > upperLux then
outsideLights.switchOff().checkFirst()
end
end
}
Now it looks real simple.
Re: Lights on when LUX <=500 else off
Posted: Sunday 30 December 2018 21:28
by havnegata
Thanks!