Making a Scene

I’m having trouble setting up this Scene:

-Any user enters their PIN in the Schlage lock at the gate
-If it’s after sunset and before midnight the deck lights come on for 10 minutes, then go off

This seems simple, but I just can’t find the set of steps that accomplishes the setup. Maybe I have a mental block because I was always taught never to make a scene. Could any of you help me out? Thanks!

Vera does not currently offer IF-THEN conditionals within a Scene at this time.
However, the subject has come up a number of times elsewhere in the Forum, and is “doable” already via some crafty Luup/Lua programming… but hopefully one day Vera will learn IF-THEN’s natively.

I can’t even think up a decent work-around for you to try! Anyone else have one??

In theory you should be able to do this by adding Lua code to a scene that turns the lights on when someone opens the lock:

[url=http://wiki.micasaverde.com/index.php/Luup_Scenes_Events]http://wiki.micasaverde.com/index.php/Luup_Scenes_Events[/url]

You could use “os.time” to get the current time in theory and use relation operators to get a true/false result. I am not sure how you would get the time for sunset, you may have to use a fixed time for this like 7:00 PM.

Someone more familiar with Lua would be better to give an example of the code required to achieve this, but it should be possible.

Thanks, guys. That’s not the answer I expected at all! Okay, maybe I’ll have to learn some programming. I got no skilz but I’m sure I can learn. But until then, what if I could set up a simpler function? How would I accomplish:

Motion sensor (in 3-in-1) senses motion on deck
Lights on deck come on for 10 minutes, but only when it’s dark outside

I know this is the most basic function in the world, but I still can’t figure it out. I can make the lights come on when motion is sensed, but they do it all day. How can I limit this to only when it’s dark out?

Once again, thanks for your help!

I would use the Arm Sensor to accomplish this. So I would set up 3 scenes:

  1. Arm Sensor when light sensor is <10
  2. Disarm Sensor when Light Sensor >25
  3. Light On for 10 Minutes when Armed Sensor is tripped.

I would not make the Arm and Disarm light levels the same just to avoid potential hysteresis.

That should work, although I have not tried it out.

Some ideas for handling time intervalls in Lua are available at:
http://forum.micasaverde.com/index.php?topic=2015.0

@MCV, could you make sunrise/sunset available via a Luup Lua extension and/or via UPnP, please?

In the meantime, you could use the Lua code attached to calculate sunrise and sunset by yourself.

  1. Arm Sensor when light sensor is <10
  2. Disarm Sensor when Light Sensor >25
  3. Light On for 10 Minutes when Armed Sensor is tripped.

If you are using the same 3-in-1 sensor (for motion and light) for all three scenes,
you must make sure that scene 3 (“light on”) does not result in a light level reading > 25
as this might trigger scene 2 (even if the sun is below the horizon).

Timeline for a sensor wakeup interval of 15 min:

-10 min: new sensor report: light=5 => activate scene 1: sensor armed
0 min: motion detected => light on as sensor is armed
5 min: new sensor report: light = 30 as light is on: sensor disarmed
10 min: light off
11 min: motion detected => no light as sensor is disarmed …

[quote=“Ap15e, post:7, topic:164950”]> 1. Arm Sensor when light sensor is <10

  1. Disarm Sensor when Light Sensor >25
  2. Light On for 10 Minutes when Armed Sensor is tripped.

If you are using the same 3-in-1 sensor (for motion and light) for all three scenes,
you must make sure that scene 3 (“light on”) does not result in a light level reading > 25
as this might trigger scene 2 (even if the sun is below the horizon).

Timeline for a sensor wakeup interval of 15 min:

-10 min: new sensor report: light=5 => activate scene 1: sensor armed
0 min: motion detected => light on as sensor is armed
5 min: new sensor report: light = 30 as light is on: sensor disarmed
10 min: light off
11 min: motion detected => no light as sensor is disarmed …[/quote]

Good point, forgot about that.

What about using the relative to sunset/sunrise time?

Should work with either Lua, or by arming/disarming the motion sensor…

But if you have enough lights from nearby location and don’t want to turn additional lights by the motion sensor, because it’s bright enough, even though already after sunset, you can’t have this additional logic… :slight_smile:

I have been trying for a while to trigger a scene when light levels are below a certain value.
Here is what I have found so far using my 3in1.
A scene will trigger if the light level is , say <5%… BUT the scene will trigger the next morning when sunrise occurs since the light level at that time is also <5% (for a shot time only).

To correct this condition I have been looking creating Lua code (as per my question in one of the links provided) to only trigger during a specified time frame (night time).

current_second = os.date(‘*t’,os.time())[“hour”] * 3600 + os.date(‘*t’,os.time())[“min”] * 60
min_time_in_seconds = 15 * 3600 + 0 * 60
max_time_in_seconds = 21 * 3600 + 15 * 60

if (current_second > min_time_in_seconds) and (current_second < max_time_in_seconds)
then
return true
else
return false
end

I think you can condense the logic part of the code down to:
if (current_second > min_time_in_seconds) and (current_second < max_time_in_seconds)
else
return false
end

I have not had time to try the Lua event yet but hope to soon. I’m still looking for a simple way to test the Lua coding before placing it in Vera. Anyone know of one?

To test Luup code click the ‘test luup code’ button under devices, Luup plugins. See the somfy walkthrough wiki for details.