The Vera Community forums have moved!

Advanced => Programming => Scene Scripting => Topic started by: Frasier on August 02, 2011, 09:50:53 am

Title: Timer AND sensor scenes
Post by: Frasier on August 02, 2011, 09:50:53 am
I want to set up a scene when at night Vera turns on an appliance module for a period of time if a Everspring SP103 detects motion - a relatively common scenario I would imagine.

I was hoping to do this with one scene: using a timer that activates 'after sunset' and then using an 'event' of the SP103 to turn on the applicance module. When I tried it out the SP103 activated the appliance module ok but it seems to ignore the time of day. Is there a way of setting up a single scene so that the event trigger (motion sensor tripped) AND timer must both be active?

I presume the other solution is to set up two scenes which arm & disarm the SP103 at dusk & dawn and then the 3rd scene which activates the appliance module when the armed SP103 is triggered? Just seems like a lot of scenes for a simple function?
Title: Re: Timer AND sensor scenes
Post by: mcvflorin on August 02, 2011, 10:11:21 am
Create your scene to turn on the light if the motion sensor is tripped and add this Lua code in the scene's Luup tab:

Code: [Select]
return luup.is_night()

This checks if it's night based on your location and if it's night, the scene will run, otherwise the scene won't run.

You can find more info here:
    http://wiki.micasaverde.com/index.php/Luup_Declarations#scene (http://wiki.micasaverde.com/index.php/Luup_Declarations#scene)
and here:
    http://wiki.micasaverde.com/index.php/Luup_Lua_extensions#function:_is_night (http://wiki.micasaverde.com/index.php/Luup_Lua_extensions#function:_is_night)
Title: Re: Timer AND sensor scenes
Post by: Frasier on August 02, 2011, 04:30:50 pm
Thanks!! This works a treat.

It's a pity this functionality is not selectable direct from the scene options rather than relying on expert knowledge for such a common scenario.

Is it on a list for a future release?
 
Title: Re: Timer AND sensor scenes
Post by: mcvflorin on August 03, 2011, 04:25:08 am
It will surely be added in a future release.