Scenes - triggers

Hi everyone,

can anyone confirm, when you create a scene, and you set up multiple triggers, are the triggers dealt with as an ‘and’ statement, or an ‘or’ statement?

For example, I have a trigger that checks the status of a switch, and also the time is 11:30pm, if the switch is turned off, then scene should run, and turn on a socket. If the switch is set to yes, it shouldn’t run.

Thanks
Tony

Short answer: “or”.

Long answer: A trigger occupies an instantaneous moment in time. It’s by definition not possible for two triggers to happen simultaneously: there will always be a finite amount of time between two triggers. What you’re asking for isn’t really an “and”; it’s a “while”. If, at the instant 11.30 occurs, the switch is currently in the “off” state, allow the scene to proceed. Making a scene behave like this generally requires a plugin or Luup code.

Take a read of this fine thread for many many examples: http://forum.micasaverde.com/index.php/topic,18679.0.html

Edit: got on/off backwards

Thanks Futzle,

I was trying to avoid using luup code, if possible :slight_smile: The tests always seem to fail, yet the code works fine on my new VL, with UI7.

If the code then does fail, when attached to a scene, it then bricks the VL, and I have to factory reset, and then restore. The restore is hit and miss, sometimes it will, sometimes it won’t :frowning: Even if backed up to local pc.

Thanks
Tony

No worries. There are two further options that encapsulate the Luup in a plugin and which might be safe for you. One is PLEG, in which you can express arbitrarily complex conditions. PLEG has its own subforum where you can likely get all the help you need. The other option is my Combination Switch plugin, which does only one thing well, but that one thing is to filter an event on a condition, coincidentally just what you want. The Combination Switch has a (long) single topic which you can find some examples in.

Hi,

As a relatively new Z Wave and Forum member I am surprised how often this gets asked… In fact I wondered the same thing, what amazes me more is that Vera have not implemented And/Or as it’s likely to be needed by lots of people.

I’m playing with PLEG and it’s pretty straightforward.

I would think a lot of questions would have to be answered in order for “and” triggers to be implemented.

Do you require that both triggers be on at the same time? Triggers (as described above by Futzle) are momentary events (i.e. a light turning on is a momentary event), so it would be impossible for both momentary triggers happening at the same time.

Or do you just say that after both triggers have triggered, run the scene. But what if the first trigger happened two days ago?

You can simulate the “and” by simply checking to see if the other trigger has triggered. Or in other words, you could check to see if the first light is on or not in the second triggers LUA code. Or use PLEG.

PLEG handles has two constructs for dealing with the time aspect of triggers.

  1. If you have the expression:
    “XXX and YYY”
    This is triggered by either the XXX or YYY event.
    It is true if BOTH triggers are currently true.

  2. PLEG has a sequence operator when you need to control your automation based on the ordered of events.

Isn’t this because technically PLEG is using a state versus a trigger? Triggers are a moment in time, state lasts a lot longer.

(What I mean is a state is “Light is currently on” versus a trigger “Light just turned on”. Vera (non-PLEG) only uses triggers.)

PLEG - Evaluates at the point in time as a Vera Trigger. … But retains the “STATE” (last value) of other variables.

In actuality a trigger happens when some associated Device parameter changes. So I monitor them and if they change again I can determine when the
trigger is no longer valid.