Conditional Event for scene?

I currently have a scene (Mike’s Home) that I trigger on front door lock unlock and pin code. This event turns on lights etc when I arrive home. I would like to add a condition to the event so that if it’s triggered during the daylight hrs, it doesn’t bother to turn on the lights. Any tips on how to accomplish?


This is most likely what you need:

[quote=“strangely, post:2, topic:167406”]This is most likely what you need:[/quote]

Thanks! I’ve been wanting to start coding some LUA. Do I use the LUA script in combination with the device event? ie right now I have a device event (Front Door - Pin Code Entered), do I now add a LUUP event and they work in combination - or do I need to kill the device event and code all the logic in the LUUP event?


So just enter return luup.is_night() in the LUA tab for your existing scene and save.


In the Event tab add an event based on what ever trigger event.
In the Commands tab add what ever device state changes you want to respond to the event.
TEST that the event triggers the commands you want.
Now add the code return luup.is_night() to the Luup tab.
TEST that the event triggers WHEN you want it to.

When Luup code returns true the commands in the command tab run, when the code returns false the commands do not run. In UI4 you can tell if the is_night() function will return true by looking at the sky at the top of the page. It switches to a night sky when the is_night() function returns true.


Thanks, thats a great explanation. Can you tell me what is the difference between code that goes into the Luup Tab for a scene and code that goes in the Luup event “button” in the Event tab of the scene?

thanks again!

I would suppose that the Lua code for an event is run if and only if the event fires and that the Lua code for the whole scene (‘Luup’ tab) is run if one of the events/timers fires.