Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
If statement to check field value
#1
Is this the best way to check a drivers field value in an event?

Code:
If
System::EvalExpr
    P1=$(ISY-Prime.CTCL#BAT-Door-Int-Open) == True
    P2=False

Devices::FieldWrite2
    P1=ISY-Prime
    P2=LGHT#Sw_BAT-Light
    P3=False
    P4=True

End

Trigger is the for the motion sensor and motion end.  I want to verify the door IS OPEN before turning off the lights.
Reply
#2
There are pre-built V2 triggers for alarm zones.

Is Zone Alarm For
Is Zone Alarm From
Is Zone Violated
Is Zone Secured
Reply
#3
(01-25-2020, 03:13 PM)gReatAutomation Wrote: There are pre-built V2 triggers for alarm zones.

Is Zone Alarm For
Is Zone Alarm From
Is Zone Violated
Is Zone Secured

I can't use those because this is for ISY open/close not coming from a security board.

I'm using the Motion for and Motion End as the trigger and I'm wanting in the actual event to verify If the door is Open then perform the action and if Not do nothing.  

The wasp-in-a-box method doesn't work in a bathroom where people are too still to keep motion active or are out of view such as in the shower.  So I've always used a two prong approach of a motion sensor and a door sensor.  Motion has to be off and door open before turning off the light.  This will also turn the light off in case someone walks in and then back out... such as girls walking in checking hair and walking back out...
Reply
#4
You can either use Devices::ReadField or you can use $(device.moniker) syntax to get the values of a field. If you want to use in the actual filter, then use FldValueEquals, which you'd never use by itself. But if you want to check that a field is a particular value before
you react to a trigger, it can be used.
Dean Roddey
Explorans limites defectum
Reply
#5
(01-25-2020, 07:28 PM)Dean Roddey Wrote: You can either use Devices::ReadField or you can use $(device.moniker) syntax to get the values of a field. If you want to use in the actual filter, then use FldValueEquals, which you'd never use by itself. But if you want to check that a field is a particular value before
you react to a trigger, it can be used.

What I have in the ISY program logic is this:
Code:
Bathroom Lights Off - [ID 0004][Parent 0005][Not Enabled]

If
        'Bathroom / BAT-Motion' Status is Off
    And 'Bathroom / BAT-Door-Int-Closed' Status is Off

Then
        Wait  20 seconds
        Set 'Bathroom / BAT-Light' Off

Else
   - No Actions - (To add one, press 'Action')

What that does in the ISY is if motion status and door status are off then it waits for 20 seconds.  The status in the 'If' is important because if during the 'wait' period either of those change to On the 'wait' is killed and then started again when the trigger is true.  I've somewhat done something similar in my CQC event.

In CQC the Trigger is motion from ISY device and a Motion End with All being true.  The action logic I have is below.  In it I'm wanting to check the status/value of the door.  If it's True then turn off the light.  Else..nothing.  So far this seems to be working.  I'm not sure if the "IF" portion is the best way of doing this or not but it does so far... fingers crossed seems to be doing what I want.

Code:
If
System::EvalExpr
    P1=$(ISY-Prime.CTCL#BAT-Door-Int-Open) == True
    P2=False

Devices::FieldWrite2
    P1=ISY-Prime
    P2=LGHT#Sw_BAT-Light
    P3=False
    P4=True

End
Reply
#6
You could do that in the filter really. SEt the first filter for the lighting load trigger. Then add two more that check the values of those two other fields. Only then will the event be triggered. You should probably also add another to see if the light is even on.

If you do check fields in the action, don't use something like the expression evaluation do:

If System::Equals($(mon.fld), True)
EndIf;
Dean Roddey
Explorans limites defectum
Reply
#7
(01-26-2020, 07:10 AM)Dean Roddey Wrote: You could do that in the filter really. SEt the first filter for the lighting load trigger. Then add two more that check the values of those two other fields. Only then will the event be triggered.  You should probably also add another to see if the light is even on.

If you do check fields in the action, don't use something like the expression evaluation do:

If System::Equals($(mon.fld), True)
EndIf;

Cool I'll redo and try with things in the event filter.  The System::Equals I think will come in handy as well.
Reply
#8
Keep in mind that each time you use that $() thing it reads the value right then. So, if you are going to use the value a number of times, use it to set a local variable and use that. That way you have lower overhead and are insured a consistent value throughout the action.
Dean Roddey
Explorans limites defectum
Reply
#9
(01-26-2020, 04:38 PM)Dean Roddey Wrote: Keep in mind that each time you use that $() thing it reads the value right then. So, if you are going to use the value a number of times, use it to set a local variable and use that. That way you have lower overhead and are insured a consistent value throughout the action.

Thanks for the heads up on possible overhead.  I went with the event filter route and so far things are great.  No false light turning off which is good.
Reply
#10
(01-26-2020, 04:38 PM)Dean Roddey Wrote: Keep in mind that each time you use that $() thing it reads the value right then. So, if you are going to use the value a number of times, use it to set a local variable and use that. That way you have lower overhead and are insured a consistent value throughout the action.

So would this come in to play when reading values from the Variables driver? That is, do you recommend we store a value from the Variables driver in to a local variable at the beginning of an action?
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Get Field Value via HTTP znelbok 3 726 06-11-2020, 03:43 PM
Last Post: Dean Roddey
  Check Box widget on WebRIVA vs Interface Viewer bryanb 1 591 04-23-2020, 06:15 AM
Last Post: bryanb
  Timers Driver / Field Time Image / Seconds gReatAutomation 1 657 03-16-2020, 05:48 PM
Last Post: Dean Roddey
  Zwave lock battery level indicator on Field Checkbox kfly 4 2,202 09-07-2019, 05:34 AM
Last Post: kfly
  Stupid question: How can I read a motion or other field state change ghurty 10 3,143 01-10-2019, 10:10 AM
Last Post: Dean Roddey
  Logic Server Field Limit zra 6 3,089 07-10-2018, 12:44 PM
Last Post: zra
  Changing Field Values in Devices Tab TurboSam 3 1,926 01-01-2018, 02:47 PM
Last Post: Dean Roddey
  If Field Exist? znelbok 5 3,253 11-18-2017, 01:03 PM
Last Post: Dean Roddey
  Simple field change trigger action Bugman 15 8,609 10-23-2017, 11:55 AM
Last Post: Dean Roddey
  Simple check before setting Elk M1 to Arm State KenC 7 4,323 10-03-2017, 05:55 PM
Last Post: Dean Roddey

Forum Jump:


Users browsing this thread: 1 Guest(s)