Just a simple one from me today, as I wanted a way to turn off my external lights at night.
However, I wanted to add a bit of randomness to it, rather than the whole outside of the house being plunged into darkness at a specific time every night.
Firstly, I have a Group, and a number of Switch items which belong to this group:
Group gExternalLights "External Lights" <light> Switch Light_Porch "Porch Lights [%s]" <light> (gExternalLights) Switch Light_Patio "Patio Lights [%s]" <light> (gExternalLights) Switch Light_Deck "Deck Lights [%s]" <light> (gExternalLights)
Then, this simple rule:
rule "Turn External Lights off from 23:30" when Time cron "0 30 23 ? * * *" then gExternalLights.members.forEach[ temp | var int randomTime = (new java.util.Random).nextInt(1800) createTimer(now.plusSeconds(randomTime)) [| temp.sendCommand(OFF) ] ] end
This roughly translates to: At 23:30 every day, create a random timer (0-30 minutes) for each item that belongs to the group, and after that time has elapsed, turn that light off.