Two-state switch sample trials

I’m trying to set up a two-state switch exactly like the sample Richard provides here.

You will need the following:
  1. A Program Logic Event Generator that will be setup as follows:
    Trigger - LightOn; When the Switch is turned On
    Condition - AutoOff = (LightOn;Now > 10:00) and (NOT (LightOn @ 2 < 3))

  2. An AutoOff Scene, that will turn off the light(s).
    You will need a Trigger for this scene based on this Program Logic Event Generator where the condition satisfied is AutoOff

I think most of my confusion stems from not knowing the proper terminology. For #1, I did create new PLEG device, and set a trigger (named LightOn), and set it to a specific light being turned on:

LightOn	 Hallway Light is turned on

I then created a condition, labeled ‘AutoOff’, and used “(LightOn;Now > 10) and (NOT (LightOn @ 2 < 3))” as the condition:

AutoOff	(LightOn;Now > 10) and (NOT (LightOn @ 2 < 3))

But, that’s where the confusion starts. Part 2, says create an AutoOff scene… Is that still within the PLEG device (i.e. action), or am I using the scene editor on MCV to make an entirely new scene? I tried the latter.

After saving and applying, turning on the switch left the light on indefinitely (I dropped the 10min timer to 10sec to speed up the trial).

When I went back to get a status/report on the PLEG device, it had the trigger, but the condition portion was empty - like it never saved. I know I saved it. Are there things that could cause only part of the routine to be saved? I’m getting a TON of Memory leak errors (LEAK) in the log - so I don’t know if that’s related. Coincidentally, the PLEG toolbox icon is missing.

Before I go any further in my description, I think the problem I’m experiencing has to do with how long it takes VERA to communicate with my AEON 18103 in-wall micro switch. If I toggle it using the VERA UI, it’s virtually instant. If I toggle it from my phone, same thing. But when using the PLEG script and MCV Scene Editor approach, the turn-off interval is wildly inaccurate.

For example, set to turn off 20 seconds off after turning it on via the switch itself (via the AutoOff condition in PLEG), it takes anywhere from 50 to 65 seconds. When I turn it on via MCV UI5, anywhere from 30 to 50 seconds. Is that normal? Obviously if it’s taking that long to execute a simple “turn off after X seconds” command, I don’t know how it would have the resolution to see user input that is in the sub-10 second range.

However, if I create a simple new scene (MCV scene editor) triggered by turning on the light, and turning off in 15 seconds - it works exactly as it should. Does this mean that when combining PLEG and MCV scenes, there is an inherent delay?

From PLEG Basics…

There is a special predefined term that may be used in sequence expressions. NOW is effectively an
interval timer with a one-minute period. Its presence in an expression will cause the expression to be
evaluated every minute. Now will have a timestamp of the current time when the evaluation takes
place. Note that Now is not a variable containing the current time although you could use #Now to
get its timestamp which is effectively the same thing.
LightOff LightOn and (LightOn; Now > 5:00)
LightOff will become true if LightOn remains true for 5 minutes.
Lockout Motion; Now < 2:00
Lockout will be true for two minutes after Motion becomes true.
Note that as Now only fires once per minute, it is not suitable for precise timing. The expression:
Event; Now > 1:00 could become true at any time between 1:01 and 2:00 after Event becomes true.

Thanks Bull. I read that in the PDF, and didn’t equate that with the 10 minute timer. That makes perfect sense why the inaccuracy.

Still, is there anything that can be done about the delay in how long it takes VERA to get the status change from the switch?

if you don’t mind, could you just take us through what you would like to happen from the moment the Garage Door opens.

Garage door? Maybe someone else you’re helping?

I just want to be able to turn a given light switch on/off/on - even if it’s 5 seconds in each direction, to override a timer and keep it on indefinitely - or trigger a dimmer setting, or blah…blah… blah…

sorry, I was helping someone else too.

So to do what you want reliably, you need a switch that supports instant status. That being said, you may get away with it if your switch isn’t too many hops from your vera within your wave network…

DoSomething = LightOn and (!LightOn; LightOn < 10)

translated into: DoSomething if (the light is now on) and (the light was turned on less than 10seconds from the last time it was turned off)

a quick On-OFF-ON on the switch will DoSomething.

that’s what you want?

oooo, yes. That looks delicious. Let me play with it. I’ll post back.

Thanks!

Ok, much closer. But I’m still a bit thick on understanding how to prevent one condition from overriding or interfering with another.

For example, your condition works great - but since I also have a condition that says when the light comes on (without the on/off/on routine), go out after 10 minutes, the two conditions are true even if I do initiate the override.

[code]Conditions

Name Expression State Last True Last False
TwoStageStayOn LightOn and (!LightOn; LightOn < 10) true 2014-02-18 15:47:44.147 2014-02-18 15:44:38.129
LightOn10Min LightOn true 2014-02-18 15:47:44.150 2014-02-18 15:47:38.527
[/code]

So how would you write the second condition to specifically exclude the override? This is probably my biggest struggle with PLEG - I can’t seem to express my ideas in logical terms that don’t conflict.

yeah, if you want to have two separate timer events like what you are doing, you want to look at a scene controller instead of a switch.

now, if the condition TwoStageStayOn doesn’t actually affect the light you are switching, you would be fine… I was flashing light A to have light B come on.

Is there a simple way to wrap this non-self-switching condition into a scene that would accomplish what I need - other than the example with which I originally started?

good idea.

yes.

Create a scene, record the scene number.

for the condition, create an action… go to ‘advanced’. Select the ‘PLEG device’ in the drop down and add it.

then, select for that device “run a scene” and then enter the scene number.

Save it, etc. Voila!

Just remember that a scene, once started, cannot be cancelled.

Ok, just so I’m on the right page…

Created a new scene (scene 31) using MCV scene editor. Called it 2min timer. Set a 20 second delay (for testing purposes), at which point the action is for the light to turn off. I did not define a trigger for the scene.

I then created a second condition under the PLEG device - LightOn2min = LightOn. I created an action for LightOn2min condition, going to advanced, pointing to the PLEG device, and specifying that it run scene 31.

I saved and turned the light on. After 20 seconds, it shut off. I then turned it on, waited about 3 seconds, turned it off, waited about 3 seconds, then back on. And it still shut back off again.

I guess I don’t understand how this avoids the conflict. The separate scene waits 20 seconds and then shuts off the light. It’s activated by the second condition “LightOn”. But isn’t this condition become true by virtue of the light being on? Or am I supposed to have some other definition for this second condition? Once it’s true, the action is to run scene 31, which will turn off the light in 20 seconds.

Sorry I’m so challenged with this. I appreciate your help - and feel bad I’m monopolizing your time.

I apologize, i thought I was more clear. You cannot really have a scene ‘override’ another scene. you see, If you start a PLEG timer on the switch, and it is running a scene, both the PLEG timer and the scene are going to execute as you programmed them to do.

We are playing in a space that just isn’t friendly to do what you want to do here. I’m afraid I’m not going to be able to get you what you want with that switch. Sorry.

Perhaps there is someone out there that can help you. My thought was to introduce a virtual switch that you could change the status on the TwoStageStayOn action… Turn on the “CancelSwitch” That virtual switch could be part of the condition (!CancelSwitchOn) that will prevent it from turning off.

Something like

LightOff = LightOn AND (LightOn;Now>5:00) and (!CancelSwitchOn)

wanna mess with that?

I may not have understood what you are trying to achieve. If all you want to do is have a light automatically turned off after ten minutes - unless the switch was quickly turned on/off/on, this should do it:

Triggers
LightOn Light is turned on

Conditions
AutoOff LightOn and (LightOn; Now > 10:00) and Not (!LightOn; LightOn < 10)

Actions
AutoOff Turn Light off

[quote=“Bulldoglowell, post:13, topic:179618”]Perhaps there is someone out there that can help you. My thought was to introduce a virtual switch that you could change the status on the TwoStageStayOn action… Turn on the “CancelSwitch” That virtual switch could be part of the condition (!CancelSwitchOn) that will prevent it from turning off.

Something like

LightOff = LightOn AND (LightOn;Now>5:00) and (!CancelSwitchOn)

wanna mess with that?[/quote]

I’m playing with that same type of condition (using multiswitch as my “virtual switch”) in order to only turn on and subsequently turn off my foyer light if it was turned on by opening the front door (by entering a pin for the lock). I do think the above will work, but I warn you that it will likely take some tinkering with it. Mine is still not fully working (But mainly because the trigger “when a pin is entered” is always true which is causing me issues). If I find a solution for my issues I will post it back here as to help anyone out (But right now I think my logic would do more harm than good since it isn’t working 100% yet).

[quote=“SirMeili, post:15, topic:179618”][quote=“Bulldoglowell, post:13, topic:179618”]Perhaps there is someone out there that can help you. My thought was to introduce a virtual switch that you could change the status on the TwoStageStayOn action… Turn on the “CancelSwitch” That virtual switch could be part of the condition (!CancelSwitchOn) that will prevent it from turning off.

Something like

LightOff = LightOn AND (LightOn;Now>5:00) and (!CancelSwitchOn)

wanna mess with that?[/quote]

I’m playing with that same type of condition (using multiswitch as my “virtual switch”) in order to only turn on and subsequently turn off my foyer light if it was turned on by opening the front door (by entering a pin for the lock). I do think the above will work, but I warn you that it will likely take some tinkering with it. Mine is still not fully working (But mainly because the trigger “when a pin is entered” is always true which is causing me issues). If I find a solution for my issues I will post it back here as to help anyone out (But right now I think my logic would do more harm than good since it isn’t working 100% yet).[/quote]

SirMeilli

So, rather than test if the “when a pin is entered” is true, test when it became true (i.e. it became true just now).

Trigger

DoorUnLocked (door unlocked with a pin)

Condition

DoSomething = DoorUnLocked AND (DoorUnLocked; Now <30)

will return true for about 30seconds after the door is opened using the pin (not including the time variation for NOW)

[quote=“RexBeckett, post:14, topic:179618”]I may not have understood what you are trying to achieve. If all you want to do is have a light automatically turned off after ten minutes - unless the switch was quickly turned on/off/on, this should do it:

Triggers
LightOn Light is turned on

Conditions
AutoOff LightOn and (LightOn; Now > 10:00) and Not (!LightOn; LightOn < 10)

Actions
AutoOff Turn Light off[/quote]

Just tried this, and it’s still shutting down after the timer expires. Let me see if I get the logic:

AutoOff becomes true when: The light is on, and it has been more than 10 min since the light was turned on, but not if it’s true that the light was turned on less than 10 seconds since it was not on.

Man I confuse myself way too easily.

Bulldoglowell,

Here is the issue: When a pin is entered, I used to have it turn on the light no matter what, and after 10 minutes turn the light off. That worked well, but then we put an old computer in the foyer for the 5 y/o to play on and having the light turn off after 10 minutes was annoying (it’s a dark foyer, not a lot if natural light…YET!).

So, I set off to make it only turn off the light if it was turned on by the unlocking of the door by a pin (which means I also have to check if it was already one before setting the multiswitch). So I have this:

Triggers:
FrontDoorClosed Front Door Sensor is not tripped
FrontDoorUnlockedByPin1 PIN Code #* is entered on Front Door
FrontDoorUnlocked1 Front Door is opened
FrontDoorLocked1 Front Door is closed
FoyerLightsOn Entryway Lights is turned on
FoyerLightAutoOn MultiSwitch(n) Switch 3 is turned on

Conditions:
DoorUnockedTooLong_cond FrontDoorUnlocked1 AND (FrontDoorUnlocked1; NOW > 10:00) AND LockDoor2 AND FrontDoorClosed AND ( FrontDoorClosed; NOW > 2:00 )
_TurnOnFoyerLightFromPin FrontDoorUnlockedByPin1 AND !FoyerLightsOn
_turnOffFoyerLight FoyerLightAutoOn AND DoorUnockedTooLong_cond

The issue is the second condittion. It fires when either the FrontDoorUnlockedByPin1 becomes true OR when FoyerLightsOn becomes true. So what happens is that if I turn the lights off…because FrontDoorUnlockedByPin is ALWAYS true, it fires it, turning the light back on. It’s a vicious cycle. My next step it so mess with sequences to get it to only fire if foyer lights were off before the front door was unlocked…I think it shoud go like:

_TurnOnFoyerLightFromPin FrontDoorUnlockedByPin1 AND !FoyerLightsOn AND (!FoyerLightsOn;FrontDoorUnlockedByPin1)

Actually, I’m going to test that now!

@erkme73: I’m not trying to take over your thread at all. If my above works, I think I can get you working properly.

No problem at all. You’re struggling with exactly the same issue I see with nearly every PLEG condition I try - I step all over myself, and can’t seem to get out of my own way. I’m glad to see I’m not the only one who finds these catch-22s. I’m eager to see how you solve your issue as well…

[quote=“SirMeili, post:18, topic:179618”]Bulldoglowell,

Here is the issue: When a pin is entered, I used to have it turn on the light no matter what, and after 10 minutes turn the light off. That worked well, but then we put an old computer in the foyer for the 5 y/o to play on and having the light turn off after 10 minutes was annoying (it’s a dark foyer, not a lot if natural light…YET!).

So, I set off to make it only turn off the light if it was turned on by the unlocking of the door by a pin (which means I also have to check if it was already one before setting the multiswitch). So I have this:

Triggers:
FrontDoorClosed Front Door Sensor is not tripped
FrontDoorUnlockedByPin1 PIN Code #* is entered on Front Door
FrontDoorUnlocked1 Front Door is opened
FrontDoorLocked1 Front Door is closed
FoyerLightsOn Entryway Lights is turned on
FoyerLightAutoOn MultiSwitch(n) Switch 3 is turned on

Conditions:
DoorUnockedTooLong_cond FrontDoorUnlocked1 AND (FrontDoorUnlocked1; NOW > 10:00) AND LockDoor2 AND FrontDoorClosed AND ( FrontDoorClosed; NOW > 2:00 )
_TurnOnFoyerLightFromPin FrontDoorUnlockedByPin1 AND !FoyerLightsOn
_turnOffFoyerLight FoyerLightAutoOn AND DoorUnockedTooLong_cond

The issue is the second condittion. It fires when either the FrontDoorUnlockedByPin1 becomes true OR when FoyerLightsOn becomes true. So what happens is that if I turn the lights off…because FrontDoorUnlockedByPin is ALWAYS true, it fires it, turning the light back on. It’s a vicious cycle. My next step it so mess with sequences to get it to only fire if foyer lights were off before the front door was unlocked…I think it shoud go like:

_TurnOnFoyerLightFromPin FrontDoorUnlockedByPin1 AND !FoyerLightsOn AND (!FoyerLightsOn;FrontDoorUnlockedByPin1)

Actually, I’m going to test that now!

@erkme73: I’m not trying to take over your thread at all. If my above works, I think I can get you working properly.[/quote]

So I am clear… you come home, you unlock the door (DoorIsUnlocked) and open it (DoorIsOpened) and you want the light on (LightOn), unless it is already on (!LightOn) (kid at computer)

Condition
AutoOn = (DoorIsUnlocked;Now<30) AND DoorIsOpened AND !FoyerLightOn [AND IsNight?]
Action: Turn Light On

returns true if you just unlocked the door, the door then opened and the light is off.

And, you want the light to turn off in 10min (AutoOff) only if it was turned on by the AutoOn

Condition
AutoOff = AutoOn AND (AutoOn; NOW>10:00)
Action: Turn Light Off

No?