We have moved at community.getvera.com

Author Topic: Making a Scene  (Read 13719 times)

Offline CMRancho

  • Hero Member
  • *****
  • Posts: 1008
  • Karma: +1/-0
Making a Scene
« on: September 21, 2009, 11:51:29 am »
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!
Vera123beta; Schlage, Kwikset, TZEMT400; Linksys cams, Smarteye cams, HSM100; Aeon, Everspring, Cooper, Leviton, Intermatic, FortrezZ, Global Caché, USB-UIRT, Somfy, etc.

Offline LibraSun

  • Hero Member
  • *****
  • Posts: 574
  • Karma: +2/-0
Re: Making a Scene
« Reply #1 on: September 21, 2009, 10:26:09 pm »
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??
Vera Model I running UI4 (Firmware 1.1.1338), died in 2015
Vera Plus running UI7 (Firmware 1.7.2935)

Offline Chimpware

  • Sr. Member
  • ****
  • Posts: 426
  • Karma: +0/-0
Re: Making a Scene
« Reply #2 on: September 22, 2009, 06:36:39 am »
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:

http://wiki.micasaverde.com/index.php/Luup_Scenes_Events

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.

Offline CMRancho

  • Hero Member
  • *****
  • Posts: 1008
  • Karma: +1/-0
Re: Making a Scene
« Reply #3 on: September 22, 2009, 09:39:24 am »
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!



Vera123beta; Schlage, Kwikset, TZEMT400; Linksys cams, Smarteye cams, HSM100; Aeon, Everspring, Cooper, Leviton, Intermatic, FortrezZ, Global Caché, USB-UIRT, Somfy, etc.

Offline Chimpware

  • Sr. Member
  • ****
  • Posts: 426
  • Karma: +0/-0
Re: Making a Scene
« Reply #4 on: September 22, 2009, 10:00:38 am »
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.

Offline Ap15e

  • Beta Testers
  • Hero Member
  • *****
  • Posts: 1998
  • Karma: +12/-0
Re: Making a Scene
« Reply #5 on: September 22, 2009, 03:35:52 pm »
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.

Offline Ap15e

  • Beta Testers
  • Hero Member
  • *****
  • Posts: 1998
  • Karma: +12/-0
Re: Making a Scene
« Reply #6 on: September 22, 2009, 05:39:48 pm »
> 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 ...

Offline Chimpware

  • Sr. Member
  • ****
  • Posts: 426
  • Karma: +0/-0
Re: Making a Scene
« Reply #7 on: September 22, 2009, 05:55:34 pm »
> 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 ...

Good point, forgot about that.

Offline Boyo

  • Full Member
  • ***
  • Posts: 180
  • Karma: +0/-0
Re: Making a Scene
« Reply #8 on: September 22, 2009, 09:49:56 pm »
What about using the relative to sunset/sunrise time?
Vera UI4 1.1.1183; Schalge Link Door Handle; HA18WD 3-Way/Single-Pole Switch x2; WDHA-12R - Wireless Gateway Module; Trane Thermostat; Retired: WDTC-20 - Z-Wave Enabled Thermostat

Offline denix

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1088
  • Karma: +1/-0
Re: Making a Scene
« Reply #9 on: September 22, 2009, 09:53:26 pm »
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... :)
Veras (1, 2, 3, Lite, Plus), lots of different Z-Wave modules, Luup plugins and theater/security integration.

Offline JimMac

  • Sr. Member
  • ****
  • Posts: 309
  • Karma: +2/-1
Re: Making a Scene
« Reply #10 on: September 23, 2009, 11:22:09 am »
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?

Offline micasaverde

  • Hero Member
  • *****
  • Posts: 1666
  • Karma: +15/-1
Re: Making a Scene
« Reply #11 on: September 23, 2009, 11:54:25 pm »
To test Luup code click the 'test luup code' button under devices, Luup plugins.  See the somfy walkthrough wiki for details.