Posts: 341
Threads: 53
Joined: Nov 2018
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.
Posts: 720
Threads: 124
Joined: May 2019
There are pre-built V2 triggers for alarm zones.
Is Zone Alarm For
Is Zone Alarm From
Is Zone Violated
Is Zone Secured
Posts: 341
Threads: 53
Joined: Nov 2018
(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...
Posts: 40,483
Threads: 491
Joined: Aug 2002
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
Posts: 341
Threads: 53
Joined: Nov 2018
(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
Posts: 40,483
Threads: 491
Joined: Aug 2002
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
Posts: 341
Threads: 53
Joined: Nov 2018
(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.
Posts: 40,483
Threads: 491
Joined: Aug 2002
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
Posts: 341
Threads: 53
Joined: Nov 2018
(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.
Posts: 720
Threads: 124
Joined: May 2019
(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?