Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Simple check before setting Elk M1 to Arm State
#1
Using CQC version 5.1.0 w/ Elk M1 version 5.3.10 & Elk Driver version 2.21.

When Alexa/Echo hears, set Alarm to "Stay Mode", a Global Action trigger checks to see if system is ready to arm....
a) If not, voice response is "system not ready to arm", or
b) If ready, then a Stay command is sent to Elk controller.

Need some assistance, since structure below doesn't work, and tried various ways,  but no luck.    However, If I remove all the checking parts up front to validate if system is ready, the system sends out the stay command to Elk.   Don't know how to read a driver field for a given state in text form, and then have system respond w/ a given action if it matches.  Below is what I tried...  thanks, Ken

Devices::QueryDrvText
    P1=ElkM1
    P2=ElkM1.Area_CraftHome_ArmUpMode
    P3=Not Ready To Arm
    P4=%(GVar:NewVar_1)

If 
System::Equals
    P1=%(GVar:NewVar_1)
    P2=Not Ready To Arm
    P3=No Case

GlobalVars::SetVariable
    P1=GVar:EchoReply
    P2=The alarm system is not ready to arm

Else

If 
System::Equals
    P1=%(LVar:CQCActParm_2)
    P2=Stay
    P3=No Case

Devices::FieldWrite
    P1=ElkM1.InvokeCmd
    P2=ArmArea:CraftHome, Stay, 003456
    P3=True

End

End

GlobalVars::SetVariable
    P1=GVar:EchoReply
    P2=The alarm system is setting to %(LVar:CQCActParm_2) mode
Reply
#2
Replace this bit:

Code:
Devices::QueryDrvText
    P1=ElkM1
    P2=ElkM1.Area_CraftHome_ArmUpMode
    P3=Not Ready To Arm
    P4=%(GVar:NewVar_1)

With something like this:

Code:
Devices::ReadField(ElkM1.Area_CraftHome_ArmUpMode, LVar:CurUpMode, True)
If System::Equals(%(LVar:CurUpMode), Not Ready To Arm, No Case)
Else
EndIf

So you would use ReadField to get the value of a field. Also, for local temporary variables, use local variables instead of global. The locals go away immediately upon the end of the action so they stay around and pollute the variable space.

If that doesn't work for you, let me know.
Dean Roddey
Software Geek Extraordinaire
Reply
#3
(10-03-2017, 01:02 PM)Dean Roddey Wrote: Replace this bit:

Code:
Devices::QueryDrvText
   P1=ElkM1
   P2=ElkM1.Area_CraftHome_ArmUpMode
   P3=Not Ready To Arm
   P4=%(GVar:NewVar_1)

With something like this:

Code:
Devices::ReadField(ElkM1.Area_CraftHome_ArmUpMode, LVar:CurUpMode, True)
If System::Equals(%(LVar:CurUpMode), Not Ready To Arm, No Case)
Else
EndIf

So you would use ReadField to get the value of a field. Also, for local temporary variables, use local variables instead of global. The locals go away immediately upon the end of the action so they stay around and pollute the variable space.

If that doesn't work for you, let me know.

Dean,

I tried the suggestion as written below, but the action doesn't react or ignores the "Not Ready To Arm" state, and doesn't send text/voice back to Echo, "The alarm system is not ready".   The action runs commands after "Else", and sends "Stay" command to Elk, even though the field we are reading is "Not Ready To Arm".   Just to check, the command in CQC is FieldRead, and not ReadField as stated above, correct?   Any other ideas?   Ken

Code:
Devices::FieldRead
   P1=ElkM1.Area_CraftHome_ArmUpMode
   P2=LVar:CurUpMode
   P3=True

If
System::Equals
   P1=%(LVar:CurUpMode)
   P2=Not Ready To Arm
   P3=No Case

GlobalVars::SetVariable
   P1=GVar:EchoReply
   P2=The alarm system is not ready to arm

Else

If
System::Equals
   P1=%(LVar:CQCActParm_2)
   P2=Stay
   P3=No Case

Devices::FieldWrite
   P1=ElkM1.InvokeCmd
   P2=ArmArea:CraftHome, Stay, 003456
   P3=True

End

End

GlobalVars::SetVariable
   P1=GVar:EchoReply
   P2=The alarm system is setting to %(LVar:CQCActParm_2) mode
Reply
#4
(10-03-2017, 03:37 PM)KenC Wrote:
(10-03-2017, 01:02 PM)Dean Roddey Wrote: Replace this bit:

Code:
Devices::QueryDrvText
   P1=ElkM1
   P2=ElkM1.Area_CraftHome_ArmUpMode
   P3=Not Ready To Arm
   P4=%(GVar:NewVar_1)

With something like this:

Code:
Devices::ReadField(ElkM1.Area_CraftHome_ArmUpMode, LVar:CurUpMode, True)
If System::Equals(%(LVar:CurUpMode), Not Ready To Arm, No Case)
Else
EndIf

So you would use ReadField to get the value of a field. Also, for local temporary variables, use local variables instead of global. The locals go away immediately upon the end of the action so they stay around and pollute the variable space.

If that doesn't work for you, let me know.

Dean,

I tried the suggestion as written below, but the action doesn't react or ignores the "Not Ready To Arm" state, and doesn't send text/voice back to Echo, "The alarm system is not ready".   The action runs commands after "Else", and sends "Stay" command to Elk, even though the field we are reading is "Not Ready To Arm".   Just to check, the command in CQC is FieldRead, and not ReadField as stated above, correct?   Any other ideas?   Ken

Code:
Devices::FieldRead
   P1=ElkM1.Area_CraftHome_ArmUpMode
   P2=LVar:CurUpMode
   P3=True

If
System::Equals
   P1=%(LVar:CurUpMode)
   P2=Not Ready To Arm
   P3=No Case

GlobalVars::SetVariable
   P1=GVar:EchoReply
   P2=The alarm system is not ready to arm

Else

If
System::Equals
   P1=%(LVar:CQCActParm_2)
   P2=Stay
   P3=No Case

Devices::FieldWrite
   P1=ElkM1.InvokeCmd
   P2=ArmArea:CraftHome, Stay, 003456
   P3=True

End

End

GlobalVars::SetVariable
   P1=GVar:EchoReply
   P2=The alarm system is setting to %(LVar:CQCActParm_2) mode

Also, is CurUpMode just a name you made up for the LVar?  Ken
Reply
#5
Yeh, I just made that name up, to make it more obvious what's in it. Throw in a command like:

System::LogMsg("Echo Handler", 0, Arm up mode is: %(LVar:CurUpMode), Status)

just after you read the field. That will log the current value of the field to the CQC logs and you see what value you are getting.
Dean Roddey
Software Geek Extraordinaire
Reply
#6
BTW, since it is a global action, you can debug it as well. Use the Test button in the global action tab. That will run the command and show you all of the expanded out values, so that you can see what is happening. It allows you to pass in parameter values just as if it was invoked in the normal way. Those are done as a quoted comma list, so
you would pass in something like:

"CQCSetToIntent", "Stay", ""

The actual intent name isn't probably important since you aren't using it. Stay would be the value you are reacting to, and you don't appear to be using the parameters one, so pass an empty string.

That should run it as though it was invoked by the Echo handler, and let you see what is happening.
Dean Roddey
Software Geek Extraordinaire
Reply
#7
1. The log captured - "Arm up mode is: Not Ready To Arm"
2. Ran test of Global Action and copied failed results:

Command Step 8 failed...

01/01 00:00:00-DESKTOP-C24LIQ5, CQCAdmin, StdCmdEngineThr3
{
CQCKit, CQCKit_ThisFacility.cpp.633, Failed/Data Format, Error: 6257/0/0
Token expansion failed during command processing
The alarm system is setting to %(LVar:CQCActParm_2) mode
}

Wasn't really sure how to troubleshoot this message, but moved the "GlobalVars/Echo Reply" command line shown below that was after both "End" commands, and moved this as the last command under the Else statements, and it worked! I included the working code below... Thanks, Ken

GlobalVars::SetVariable
P1=GVar:EchoReply
P2=The alarm system is setting to %(LVar:CQCActParm_2) mode

NEW CODE LINES
=======================
Devices::FieldRead
P1=ElkM1.Area_CraftHome_ArmUpMode
P2=LVar:CurUpMode
P3=True

If
System::Equals
P1=%(LVar:CurUpMode)
P2=Not Ready To Arm
P3=No Case

GlobalVars::SetVariable
P1=GVar:EchoReply
P2=The alarm system is not ready to arm

Else

If
System::Equals
P1=%(LVar:CQCActParm_2)
P2=Stay
P3=No Case

Devices::FieldWrite
P1=ElkM1.InvokeCmd
P2=ArmArea:CraftHome, Stay, 003456
P3=True

GlobalVars::SetVariable =====Moved this line here, vs at the end!=====
P1=GVar:EchoReply
P2=The alarm system is setting to %(LVar:CQCActParm_2) mode

End

End

System::LogMsg
P1="Echo Handler"
P2=0
P3=Arm up mode is: %(LVar:CurUpMode)
P4=Status
Reply
#8
The error sounds like you didn't get the parameters passed in correctly, so that it showed up looking like a single parameter and therefore there was no parameter 2 to expand.
Dean Roddey
Software Geek Extraordinaire
Reply


Possibly Related Threads...
Thread Author Replies Views Last Post
  Really simple CML driver questions znelbok 327 39,132 10-11-2017, 09:19 PM
Last Post: znelbok
  Field Check Box Text on 2 Lines Shaky 6 1,245 02-25-2017, 10:05 PM
Last Post: Shaky
  Field Check Box fields George M 2 475 01-25-2017, 04:14 PM
Last Post: George M
  What does it mean that a switch is currently in an error state ghurty 3 513 11-13-2016, 08:14 PM
Last Post: Dean Roddey
  PDL Question re:Stores in the State Machine bluebag 13 902 03-29-2016, 04:07 PM
Last Post: Dean Roddey
  initial State dashboard/graphing potts.mike 7 881 12-22-2015, 05:31 PM
Last Post: Dean Roddey
  Best way to iterate fields and check for a value? dlmorgan999 2 543 07-26-2015, 05:28 PM
Last Post: dlmorgan999
  Current Sonos State potts.mike 7 775 01-22-2015, 05:03 PM
Last Post: Dean Roddey
  Check if ELK is fully Armed ghurty 2 671 01-16-2015, 09:00 AM
Last Post: Dean Roddey
  Macro Editor does not check CQC version level batwater 1 826 12-27-2013, 12:15 PM
Last Post: Dean Roddey

Forum Jump:


Users browsing this thread: 1 Guest(s)