Nested 'OR' Condition

I have Reactor device created to turn on my garage lights only when

It is after sunset and before sunrise and GarageDoorLeft or GarageDoorMiddle or GarageDoorRight has been opened.

The question I have is 2 things.
Is the ‘OR’ condition correct for what I want done and is the status correct for when the garage doors are open.

I used the chevron drop down at selected the “device is opened” but it does not seem to change the value

image

I have included my summary report

Blockquote

*************************************************** REACTOR LOGIC SUMMARY REPORT ***************************************************
   Version: 3.0 config 301 cdata 19082 ui 19125 pluginDevice 325
    System: Vera version 1.7.4453 on Sercomm G450; loadtime 1557408668; systemReady 1557408689; Lua 5.1
Local time: 2019-05-09T09:53:47-0400; DST=1
House mode: plugin 1; system 1; tracking off
  Sun data: { "stamp": 2019129, "civdawn": 1557393969, "nautdawn": 1557391502, "sunset": 1557448265, "nautdusk": 1557452704, "latitude": 44.3001, "astrodusk": 1557455508, "longitude": -79.6496, "civdusk": 1557450238, "astrodawn": 1557388699, "sunrise": 1557395941 }
  Geofence: not running
====================================================================================================================================
GarageLightTurnOn03 (#383)
    Version 19082.1557408498 05/09/19 09:28:18
    Message/status: Not tripped
    Condition group "GarageMiddleLightON" (AND) false as of 09:13:17 <root>
      &-F-sun bet sunset+0,sunrise+0 [1557408698 => 1557409058 at 09:37:38; F/F as of 05:59:00/05:59:00] <cond0>
      &-T-service GarageDoorMiddle (239) urn:micasaverde-com:serviceId:DoorLock1/Status = 1 (match case) [0 => 1 at 09:26:26; T/T as of 09:26:26/09:26:26] <condcwarf69>
      &-T-group "GarageRightLightON" (OR) TRUE as of 09:27:30 <grpcwbxti2>
      |     |-F-sun bet sunset+0,sunrise+0 [1557408698 => 1557409058 at 09:37:38; F/F as of 05:59:00/05:59:00] <condcwbyc2k>
      |     |-F-service GarageDoorRight (240) urn:micasaverde-com:serviceId:DoorLock1/Status = 1 (match case) [1 => 0 at 09:37:38; F/F as of 09:37:38/09:37:38] <condcwbyvj2>
      |     |-T-group "GarageLeftLightON" (OR) TRUE as of 09:27:30 <grpcww5wj3>
      |     |     |-F-sun bet sunset+0,sunrise+0 [1557408698 => 1557409058 at 09:37:38; F/F as of 09:27:30/09:27:30] <condcww6m0v>
      |     |     |-T-service GarageDoorLeft (241) urn:micasaverde-com:serviceId:DoorLock1/Status = 1 (match case) [1 at 09:27:30; T/T as of 09:27:30/09:27:30] <condcww73xj>
    Activity grpcww5wj3.true
        Device 96 (Garage Lights) action urn:upnp-org:serviceId:SwitchPower1/SetTarget( newTargetValue=1 )
        Delay 60 inline
        Device 96 (Garage Lights) action urn:upnp-org:serviceId:SwitchPower1/SetTarget( newTargetValue=0 )
    Activity grpcwbxti2.true
        Device 96 (Garage Lights) action urn:upnp-org:serviceId:SwitchPower1/SetTarget( newTargetValue=1 )
        Delay 60 inline
        Device 96 (Garage Lights) action urn:upnp-org:serviceId:SwitchPower1/SetTarget( newTargetValue=0 )
    Activity grpcwtdwdc.true
        Device 96 (Garage Lights) action urn:upnp-org:serviceId:SwitchPower1/SetTarget( newTargetValue=1 )
        Delay 60 inline
        Device 96 (Garage Lights) action urn:upnp-org:serviceId:SwitchPower1/SetTarget( newTargetValue=0 )
    Activity root.true
        Device 96 (Garage Lights) action urn:upnp-org:serviceId:SwitchPower1/SetTarget( newTargetValue=1 )
        Delay 60 inline
        Device 96 (Garage Lights) action urn:upnp-org:serviceId:SwitchPower1/SetTarget( newTargetValue=0 )
    Events
        05/09/19 09:31:24 start: 
        05/09/19 09:31:37 devicewatch: device=240, old="0", name=GarageDoorRight, var=urn:micasaverde-com:serviceId:DoorLock1/Status, new="1"
        05/09/19 09:31:38 condchange: newState=true, cond=condcwbyvj2, oldState=false
        05/09/19 09:31:38 evalchange: newState=true, cond=condcwbyvj2, oldState=false
        05/09/19 09:37:37 devicewatch: device=240, old="1", name=GarageDoorRight, var=urn:micasaverde-com:serviceId:DoorLock1/Status, new="0"
        05/09/19 09:37:38 condchange: newState=false, cond=condcwbyvj2, oldState=true
        05/09/19 09:37:38 evalchange: newState=false, cond=condcwbyvj2, oldState=true

Blockquote

Assuming I understand your objective correctly, let me rewrite your equation with parentheses, so that the precedence is more clear:

It is after sunset and before sunrise and ( GarageDoorLeft has been opened or GarageDoorMiddle has been opened or GarageDoorRight has been opened )

The “after sunset and before sunrise” could also be written between sunset and sunrise.

When you write the expression this way, every set of parentheses is a group. So…
Root group - “AND” operator, let’s name it “Garage Light Control”

  • Condition: sunrise/sunset, between sunset and sunrise
  • Group - “Any Door Open” - OR operator
    • Condition: device state, GarageDoorLeft is opened
    • Condition: device state, GarageDoorMiddle is opened
    • Condition: device state, GarageDoorRight is opened

Should look something like this (ignore the specific device and variable names–I don’t have your devices–just look at the structure of the conditions and groups)::

image

Put your actions in the “Garage Light Control” activities (the activities of the root group in this case).

I used the chevron drop down at selected the “device is opened” but it does not seem to change the value

I’m not sure what you mean by this. Your screen shot seems to be correct for the operation. The values shown makes sense for testing that the door is open.

Thanks for the reply.
I changed my condition to the way you recommended. Less lines of code :slight_smile:

What does the ‘ignore case’ mean after selecting “Device is Open” for a garage door?
Do I leave what is prefilled in from the drop down list on the values and the check box of “Ignore case” ?

Hi Rigpapa,

If I wanted to reduce the amount of Reactor devices created.
Could I put my actions together like this ?

I want a condition to check between sunset and sundown AND Front Door Opened to Turn on Foyer Lights

OR

Between 3am - 5:35am AND Foyer PIR is Tripped . Action is to Turn on Foyer Light

image

Blockquote

*************************************************** REACTOR LOGIC SUMMARY REPORT ***************************************************
   Version: 3.0 config 301 cdata 19082 ui 19125 pluginDevice 325
    System: Vera version 1.7.4453 on Sercomm G450; loadtime 1557417368; systemReady 1557417390; Lua 5.1
Local time: 2019-05-09T12:18:28-0400; DST=1
House mode: plugin 1; system 1; tracking off
  Sun data: { "stamp": 2019129, "civdawn": 1557393969, "nautdawn": 1557391502, "sunset": 1557448265, "nautdusk": 1557452704, "latitude": 44.3001, "astrodusk": 1557455508, "longitude": -79.6496, "civdusk": 1557450238, "astrodawn": 1557388699, "sunrise": 1557395941 }
  Geofence: not running
====================================================================================================================================
FoyerLightsON (#386)
    Version 19082.1557418658 05/09/19 12:17:38
    Message/status: Not tripped
    Condition group "FoyerLightsAfterSunset" (AND) false as of 12:12:08 <root>
      &-F-sun bet sunset+0,sunrise+0 [1557418434 => 1557418659 at 12:17:39; F/F as of 11:59:09/11:59:09] <condcx1b9p7>
      &-F-service Front Door Sensor (5) urn:micasaverde-com:serviceId:SecuritySensor1/Tripped = 1 [0 at 11:59:09; F/F as of 11:59:09/11:59:09] <condcx1m15t>
      &-F-service Front Door Camera (284) urn:micasaverde-com:serviceId:SecuritySensor1/Tripped = 1 [0 at 12:00:02; F/F as of 12:00:02/12:00:02] <condcx1nzzt>
      &-F-group "FoyerPIRMovement" (OR) false as of 12:12:35 <grpcx1yhbq>
      |     |-F-trange bet ,,,3,0,,,,5,35 [1557418434 => 1557418659 at 12:17:39; F/F as of 12:09:00/12:09:00] <condcx1ykr2>
      |     |-F-service Foyer PIR (346) urn:micasaverde-com:serviceId:SecuritySensor1/Tripped = 1 [1 => 0 at 12:13:54; F/F as of 12:13:54/12:13:54] <condcx1zsq7>
    Activity grpcwzobzf.true
        Device 90 (Foyer Hallway Lights) action urn:upnp-org:serviceId:SwitchPower1/SetTarget( newTargetValue=1 )
        Delay 300 inline
        Device 90 (Foyer Hallway Lights) action urn:upnp-org:serviceId:SwitchPower1/SetTarget( newTargetValue=0 )
    Activity grpcwzgunh.true
        Device 90 (Foyer Hallway Lights) action urn:upnp-org:serviceId:SwitchPower1/SetTarget( newTargetValue=1 )
        Delay 300 inline
        Device 90 (Foyer Hallway Lights) action urn:upnp-org:serviceId:SwitchPower1/SetTarget( newTargetValue=0 )
    Activity grpcx1yhbq.true
        Device 388 (FoyerLightManualOn) action urn:toggledbits-com:serviceId:DelayLightTimer/Trigger(  )
    Activity root.true
        Device 388 (FoyerLightManualOn) action urn:toggledbits-com:serviceId:DelayLightTimer/Trigger(  )
    Events
        05/09/19 11:56:25 start: 
        05/09/19 11:56:26 sensorstate: 
        05/09/19 11:59:08 configchange: 
        05/09/19 11:59:09 condchange: newState=false, cond=condcx1b9p7
        05/09/19 11:59:09 evalchange: newState=false, cond=condcx1b9p7
        05/09/19 11:59:09 condchange: newState=false, cond=condcx1m15t
        05/09/19 11:59:09 evalchange: newState=false, cond=condcx1m15t
        05/09/19 11:59:09 condchange: newState=false, cond=root, oldState=true
        05/09/19 11:59:09 evalchange: newState=false, cond=root, oldState=true
        05/09/19 12:00:01 configchange: 
        05/09/19 12:00:02 condchange: newState=false, cond=condcx1nzzt
        05/09/19 12:00:02 evalchange: newState=false, cond=condcx1nzzt
        05/09/19 12:01:00 configchange: 
        05/09/19 12:08:59 configchange: 
        05/09/19 12:09:00 condchange: newState=false, cond=condcx1ykr2
        05/09/19 12:09:00 evalchange: newState=false, cond=condcx1ykr2
        05/09/19 12:09:00 condchange: newState=false, cond=condcx1zsq7
        05/09/19 12:09:00 evalchange: newState=false, cond=condcx1zsq7
        05/09/19 12:09:00 condchange: newState=false, cond=grpcx1yhbq
        05/09/19 12:09:00 evalchange: newState=false, cond=grpcx1yhbq
        05/09/19 12:09:41 configchange: 
        05/09/19 12:10:36 devicewatch: device=346, old="0", name=Foyer PIR, var=urn:micasaverde-com:serviceId:SecuritySensor1/Tripped, new="1"
        05/09/19 12:10:37 condchange: newState=true, cond=condcx1zsq7, oldState=false
        05/09/19 12:10:37 evalchange: newState=true, cond=condcx1zsq7, oldState=false
        05/09/19 12:10:37 condchange: newState=true, cond=grpcx1yhbq, oldState=false
        05/09/19 12:10:37 evalchange: newState=true, cond=grpcx1yhbq, oldState=false
        05/09/19 12:10:37 condchange: newState=true, cond=root, oldState=false
        05/09/19 12:10:37 evalchange: newState=true, cond=root, oldState=false
        05/09/19 12:10:37 startscene: scene=grpcx1yhbq.true, sceneName=grpcx1yhbq.true
        05/09/19 12:10:37 runscene: scene=grpcx1yhbq.true, sceneName=grpcx1yhbq.true, group=1, notice=Starting scene group 1
        05/09/19 12:10:37 endscene: scene=grpcx1yhbq.true, sceneName=grpcx1yhbq.true
        05/09/19 12:10:37 sensorstate: state=true
        05/09/19 12:10:37 startscene: scene=root.true, sceneName=root.true
        05/09/19 12:10:37 runscene: scene=root.true, sceneName=root.true, group=1, notice=Starting scene group 1
        05/09/19 12:10:37 endscene: scene=root.true, sceneName=root.true
        05/09/19 12:12:07 configchange: 
        05/09/19 12:12:08 condchange: newState=false, cond=root, oldState=true
        05/09/19 12:12:08 evalchange: newState=false, cond=root, oldState=true
        05/09/19 12:12:08 sensorstate: state=false
        05/09/19 12:12:34 configchange: 
        05/09/19 12:12:35 condchange: newState=false, cond=grpcx1yhbq, oldState=true
        05/09/19 12:12:35 evalchange: newState=false, cond=grpcx1yhbq, oldState=true
        05/09/19 12:13:53 devicewatch: device=346, old="1", name=Foyer PIR, var=urn:micasaverde-com:serviceId:SecuritySensor1/Tripped, new="0"
        05/09/19 12:13:54 condchange: newState=false, cond=condcx1zsq7, oldState=true
        05/09/19 12:13:54 evalchange: newState=false, cond=condcx1zsq7, oldState=true
        05/09/19 12:17:38 configchange: 

Blockquote

All state variable values in Vera are strings. So equals and not equals (and a few of the other operators) have “ignore case” available for the string comparison. In the case of the magnitude comparisons (>, >=, <, <=), the “ignore case” option goes away, and Reactor will convert the string value to a number in order to make the comparison.

Generally, yes, but in this case it doesn’t matter, because there’s no such thing as uppercase 1 and lowercase 1 – 1 is 1 and that’s that, so the option has no effect.

between sunset and sundown AND Front Door Opened

OR

Between 3am - 5:35am AND Foyer PIR is Tripped

The parent group should be OR, with two subgroups that are AND (that’s not what your screen shot shows).

So should the screen shot be like this?
this seems to not to trigger the light coming on via the Foyer PIR being triggered during the daytime.

image

No, it’s incorrect. Re-read my previous reply.

Hint #1: You need two subgroups, you have only one.

Hint #2: There isn’t an OR anywhere to be found in your last screen grab

Hint #3: The group FoyerPIRMovement is correctly set up and fine as it is.

Question: where did the camera enter into this? I didn’t notice it in your first screen shot, but it’s not described at all in your (English-written) logic. So this whole discussion may be off based on whatever you are trying to accomplish with the camera.

I watched your youtube videos and based on that I will have to split up my conditions and create 2 new Reactor sensors.

No, you don’t need to do that. Absolutely not.

You didn’t answer my question about the camera. Where does that enter into the equation? Tell me IN ENGLISH (no screenshots/logic summaries) what you are trying to accomplish.

What I was trying to accomplish is.

Have my Foyer Lights Turn On based on 1 of the groups are true

Condition A

  • between sunset and sunrise
  • front door sensored tripped (front door opened)
  • ip camera is a sensor and will trigger if motion is detected outside front door

Or if

Condition B

  • time between 3:00am - 5:30am
  • Foyer PIR motion is tripped

So, the camera triggering on motion OR the front door opening turns on the light?

no it will be

camera triggered motion and the front door opened is true.

My camera will trigger that someone is at the front door and when i open the front door the foyer light will turn on.

OK. And how do the lights get turned off?

I setup DelayLight device for the foyer light and call it at the activities

^^^^ falls dead on the floor

So you do not think creating 2 Reactor sensors is a better approach?

No, you don’t need two RS’s.

  1. Clear everything out of your ReactorSensor, activities and conditions. Start completely clean.
  2. Change the root group’s operator to OR
  3. Create two new groups in the root group. Both will have the AND operator.
  4. In the first group, add the following conditions:
    • Sunrise/sunset: between sunset and sunrise
    • Device Action: front door sensor, Tripped equals 1
    • Device Action: front door camera, Tripped equals 1
  5. In the second group, add the following conditions:
    • Date/time: between 03:00 and 05:35
    • Device State: Foyer PIR, Tripped equals 1
  6. Do not create any activities in your ReactorSensor
  7. In your DelayLightTimer:
    • Set the ReactorSensor as the (only) trigger device
    • Set your light in both the “On” and “Off” Lists.
    • Set the auto and manual delays (the auto delay will be the delay used when triggered by the ReactorSensor, the manual delay will be used if someone turns on the light manually).
    • In the Automatic Timing Options section near the bottom of the settings tab, set the “Hold-Over Mode” to “(2) Do not start off-delay timer until triggered sensors reset” (this will keep the timer from shutting off the lights while the door is still open).

Your group structure should look like this (again, ignore device names/numbers, since I don’t have your devices, just look at structure):

image

In this configuration, you are letting DelayLight perform all the actions, and the ReactorSensor provides the triggering for the DelayLightTimer. You had way too much going on in your ReactorSensor activities in your last attempt–unnecessarily complex, redundant, and stomping on each other. Just let DelayLight do its thing.

Wow this seems less complex doing it this way then the way i was trying to do it.
I will try this out and report back.

Thanks so much.

Excellent. So, you see how it hangs together?