How would i do this (conditional scenes)

Hi
I’ve done a bit of research on the forums and elsewhere on adding “Luup” code to some of my scenes, but wanted to just clarify:

Right now I have a motion sensor at the back door entryway. When someone goes through the door, it turns the light in the next room on. This part is working fine, except I don’t want the light to come on when it’s in the middle of the afternoon.

To my understanding, if I go to the advanced mode interface, then ‘automation’, then the ‘wrench’ icon of the scene I want to configure, then ‘triggers’, then ‘Luup event’, I would enter:

return luup.is_night()

So my questions are a) Where is ‘night’ defined? Does it factor in daylight saving? There are times of the year where ‘night’ should only be 8:30pm and onward, but other times it’s completely dark by 5:30pm. And b) is that the only thing I need to enter in the Code box?

I also have 2 other questions I’m hoping someone can answer. Not related to the above questions, but Vera related.

  1. When I go to http://myveraip/ it loads http://veraip/CMH/ and that interface seems to be limited (albeit in my opinion a lot more user friendly). I don’t see the ability to add any ‘luup’ code unless I switch to the ‘advanced’ interface (http://veraip/cmh_ui6). What’s the first interface for if it’s so limited?
  2. In the case of the example I gave of my scene that’s set up to turn a light on when the motion sensor is tripped, how would I set it to only keep that light on for one minute? Would I have to create another scene with the same trigger (motion sensor tripped) but set the action to turn the light off, with a delay of 1 minute?

If you are going to program in luup … you will need to learn what the luup functions do.

See:
http://wiki.micasaverde.com/index.php/Luup_Lua_extensions#function:_is_night

There are multiple ways to do this.
One scene … an immediate action to turn on, and a delayed action to turn off the scene.
You will have weird behavior with overlapping scene executions if you have multiple motion events …
You can do two scenes as you described.

Both of the above will have problems if Vera Restarts while the off timer is active … it will get lost and not run.

You can look into solutions that use the Countdown Timer, PLEG or PLTS plugins.
http://forum.micasaverde.com/index.php/topic,21603.0.html
All three can handle multiple overlapping trigger events and will not have problems if Vera restarts while active.

Thanks - I did look up the definition of the ‘is_night’ function, but just wanted to confirm it was something I could use and wouldn’t have to define ‘night’. If it works on sunset to sunrise, I’m assuming that’s using the Vera’s time zone and time?

It is based on your location and timezone settings.

Seems like sometimes it works and sometimes it doesn’t. I just came home and opened the back door, and despite it being 4:00PM and the sun still high in the sky, the light came on…

pic 1 = the trigger
pic 2 = the ‘luup code’

I’ve download PLC and PLEG, but even reading the documentation, can’t figure out where to start. How do you create a scene in the first place. I’m sure i’ll figure it out in time, but something this simple should not require PLC/PLEG (I wouldn’t think). It sounds like a powerful application, and I look forward to playing with it later.

I’ve got to say, this is the most frustrating thing. I’ve invested, at this point, over $3,500 into my “Z wave” network, from power meters, garage door sensors, relays, over 20 light switches, over 15 outlets, etc. - but seems the limitation is the controller. You’d think a basic operation “do not turn light on unless it’s after x PM” would be possible without having to generate code. I’m sorry for the vent, but I’ve never experienced something as ridiculous as this. I have a garage door tilt sensor and a relay on the garage door to close it, but I can’t set up a trigger to close the door if it’s been open for more than 30 minutes… Sigh :frowning:

PLEG was written because of the limitations of Scenes …

I would suggest you start with a trivial problem … and go through the steps.

Something like if I turn switch 1 on … cause switch 2 to come on.

For an intro to PLEG see:
http://forum.micasaverde.com/index.php/topic,21997.0.html

Once you see how how the various steps are done in PLEG … It will be much easier to apply to any automation problem.
You will never look back … Very few unsatisfied users.

K - I tried doing this:

Condition: When I turned my office light off (trigger: t1), then action c1, which is turn stairway and landing lights on. Nothing happened =(

I realize the ‘schedules’ isn’t being used right now, but I didn’t even want to try throwing a scheduled time/day in until I got this working.

Anyone? =(

First check that PLEG is armed - click the Arm button on the device tile.

Is your office light a dimmer? With some dimmers it is necessary to set a Device Property for LoadLevelStatus and check that in the Condition instead of using a Trigger:

Device Properties
OfficeLLS Office Light LoadLevelStatus

Conditions
c1 OfficeLLS == 0

Please post the results of the Status command. We can see time stamps.

If you do not have Z-Wave devices with Instant Status … it could be a number of minutes from the time you toggle the light until Vera notices the switch was changed. (Vera Polling time dependent).

If you turn off the Office Light from Vera … your Landing Light should come on right away.

Thank you - turns out you’re right, if I turn of the light in Vera, the landing and stairway lights come on right away. Seems like there’s often a very long delay for the switch to report the status back to Vera.

Is there any way to change that? The switches in my house are: Jasco 45609

If you want to use manual control of Z-Wave switches to control automation … they need to support Instant Status.

If this is important for you … you will need to swap out the switch. I use Levinton switches … but they are more expensive.

Really I can only think of one case where a light switch turned on would control automation - the rest would all be triggered by a door sensor, window sensor, or a scene controller. So I guess I can just swap out that one switch with a Levitron :confused:

Having some trouble now with my garage opener system. There’s a tilt sensor installed on the garage door, and then a relay that’s wired in parallel to the garage switch. I have the relay set to delay 5 seconds each time it’s triggered before it’s deactivated. It triggers the garage door opener perfectly, BUT the PLEG thing I set up, while it works most of the time, I’ve noticed quite often i’ll open the garage (from the garage opener on the wall), and within a few seconds the garage will close automatically. Weird bugs like that.

Should be a pretty straightforward setup from what I can understand. Anything I can put in the conditions to prevent that happening?

You need to capture the status report when it happens … or have debug turned on (log file in a separate file) then attach the log file.

You might also add a notification to the PLEG when it has satisfied condition c1 to make sure this is what is causing the problem.

Just happened a few minutes ago when I came home.

This time, I opened the garage door from the opener in the car, and the garage door ‘stopped’ opening halfway up.

Screenshot attached

I will need to see the Debug log file for this … What Version of PLEG are you running ?

Your logic seems OK.
It can be simplified a little.
Remove the GarageClosed input

Change the condition to:
GarageOpen and (GarageOpen; NOW > 10:00)

[hr]
The reasons for the above is because:

  1. GarageClose is equal to !GarageOpen
  2. (GarageClose; GarageOpen … is equal to … (!GaraOpen; GarageOpen … and is equivalent to: GarageOpen and (GarageOpen …

PLEG version 6.9 (unregistered)
PLC 6.9

Turned on debugging on the PLEG device that closes the garage door - went outside and opened/closed the door 6 or 7 times. Debug log attached. Unfortunately (just my luck) nothing out of the ordinary happened. Let me know if you see anything. will try another couple of times later this evening and see if I can duplicate.

The log never showed C1 going true … so if the switch triggered … it must be for some other reason.
Is it part of some other scene ? Or joined via associations to another another device ?