Author Topic: Regex Results  (Read 10772 times)

0 Members and 1 Guest are viewing this topic.

ddl

  • Sr. Member
  • ****
  • Posts: 118
  • Karma: 0
    • View Profile
Regex Results
« on: April 27, 2015, 11:20:04 PM »
Having trouble writing the Regex code to produce results from my ISY994i home automation device.  Can someone help?

Here is what I would like to do.  I would like to pull status information from devices in my ISY.  Here is what I have so far

formatted="Off" uom="%/on/off" /></node><node id="32 80 D2 1"><property id="ST" value="0"

I would like to pull the "Off" state for the node id "32 80 D2 1"
__________________________

formatted="78.00" uom="degrees" /><property id="CLIMD" value="1" formatted="Heat" uom="n/a" />

I would like to pull the degree status "78", the thermostat mode "Heat"

Any help would be appreciated


Kalle

  • $upporter
  • Hero Member
  • *****
  • Posts: 2319
  • Karma: 47
    • View Profile
Re: Regex Results
« Reply #1 on: April 28, 2015, 12:08:21 AM »
You can use the VC regexTool which will you help a lot.


for - Off
formatted="(.*?)"


and for 78
formatted=\W(\d+)


if you need 78.0
formatted=\W(\d+\W\d) and this will give you the same result: (\d+\W\d)


so you can see, there are many options - the following picture will show you how it looks in the VC- RegExTool



« Last Edit: April 28, 2015, 01:41:41 AM by Kalle »
***********  get excited and make things  **********

PegLegTV

  • $upporter
  • Hero Member
  • *****
  • Posts: 500
  • Karma: 43
    • View Profile
Re: Regex Results
« Reply #2 on: April 28, 2015, 12:21:48 AM »
I'm guessing that you are looking for the "off" listed after formatted= if so the first command in the group below should do it, the second command should work for retrieving the "78"

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.1.3.8-->
<commandGroup open="True" name="regex examples " enabled="True" prefix="" priority="0" requiredProcess="" description="">
  <command id="625" name="regex for off status" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <action>
      <cmdType>Results.RegEx</cmdType>
      <params>
        <param>formatted="(.*?)"\Wuom="%/on/off"\W/&gt;&lt;/node&gt;&lt;node\Wid="32\W80\WD2\W1"&gt;&lt;property\Wid="ST"\Wvalue="0"</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
  </command>
  <command id="626" name="regex for 78  " enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <action>
      <cmdType>Results.RegEx</cmdType>
      <params>
        <param>formatted="(.*?)"\Wuom="degrees"\W/&gt;&lt;property\Wid="CLIMD"\Wvalue="1"\Wformatted="Heat"\Wuom="n/a"\W/&gt;</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
  </command>
</commandGroup>

if you look at the two commands you will see that where the info you where trying to grab ( "off" and "78") there is
Code: [Select]
(.*?) this will capture everything in the defined area,

you will also see there are several
Code: [Select]
\W this is used to define "any nonword character" which in this case was "spaces"

and you can do like kalle shows above, he posted while I was typing mine out




jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7715
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Regex Results
« Reply #3 on: April 28, 2015, 08:49:03 AM »
It will only be possible to give you reliable regex patterns if you show us the complete string you are trying to analyse. If possible, give us several complete examples from different devices or events.

Otherwise there is too much guesswork and you will end up with actions that only work some of the time, or simply return incorrect values.

ddl

  • Sr. Member
  • ****
  • Posts: 118
  • Karma: 0
    • View Profile
Re: Regex Results
« Reply #4 on: April 28, 2015, 09:11:22 AM »
All, thanks much.  This helps a lot.  Also, from the same result above, I'd like to pull the thermostat mode status(heat or cool) and the node id (14 2E B1 1).  Using the regex tool in VC I get all tangled up when trying to pull multiple things. 

@Jitterjames... will do.  Following is the complete results that i pulled from my isy.

Thermostat Results

<node id="11 B3 8F 1"><property id="ST" value="156" formatted="78.00" uom="degrees"/><property id="CLIMD" value="1" formatted="Heat" uom="n/a"/><property id="CLISPC" value=" " formatted=" " uom="degrees"/><property id="CLISPH" value="140" formatted="70.00" uom="degrees"/><property id="CLIHUM" value="73" formatted="73.00" uom="%"/></node>

Light switch result
<node id="14 2E B1 3"><property id="ST" value="0" formatted="Off" uom="on/off"/>

Door Lock result
<node id="ZW003_1"><property id="ST" value="100" formatted="Locked" uom="11"/></node>




jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7715
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Regex Results
« Reply #5 on: April 28, 2015, 09:18:35 AM »
Do these messages all arrive together or separately?

ddl

  • Sr. Member
  • ****
  • Posts: 118
  • Karma: 0
    • View Profile
Re: Regex Results
« Reply #6 on: April 28, 2015, 11:03:56 AM »
It depends on how I query the isy.  In this particular case I have formatted the query to pull the status of all devices in the isy.  I broke them out (thermostat, Light Switch and Door Lock) below to give examples of what I am trying to pull from the results. 

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7715
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Regex Results
« Reply #7 on: April 28, 2015, 11:11:10 AM »
It will only be possible to give you reliable regex patterns if you show us the complete string you are trying to analyse.

Whatever string you get back and are trying to apply the RegEx to, show us the complete string that is returned from your query, unedited, unspliced, no lines added, not broken up, etc.

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7715
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Regex Results
« Reply #8 on: April 28, 2015, 11:20:15 AM »
Assuming you can ask for information on one specific node at a time, then you will know which node these values are for and you can break up all the properties and values returned for that node as follows.

I am using the pattern \s for spaces since it is the most precise and clear method, I think.

Code: [Select]
<property\sid="(.*?)"\svalue="(.*?)"\sformatted="(.*?)"\suom="(.*?)"
Try it with the RegEx tool to see what you get.
« Last Edit: April 29, 2015, 08:48:09 AM by nime5ter »

ddl

  • Sr. Member
  • ****
  • Posts: 118
  • Karma: 0
    • View Profile
Re: Regex Results
« Reply #9 on: April 28, 2015, 11:23:21 AM »
ok, will do going forward.  At the moment I am away from my ISY.  I will resubmit this evening.


ddl

  • Sr. Member
  • ****
  • Posts: 118
  • Karma: 0
    • View Profile
Re: Regex Results
« Reply #10 on: April 28, 2015, 11:29:13 AM »
Yes, However, if I wanted to find all of the nodes with a specific status and have VC report the total number of devices that are"ON"  how does that look in the Regex tool.  I will play more with it tonight.

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 2012
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: Regex Results
« Reply #11 on: April 28, 2015, 11:57:16 AM »
Yes, However, if I wanted to find all of the nodes with a specific status and have VC report the total number of devices that are"ON"  how does that look in the Regex tool.  I will play more with it tonight.

If all you want to know is the total number of devices that are "on" at a given moment -- without knowing which specific devices are on -- then you can query the status of all devices at once looking for the regex pattern:

Code: [Select]
formatted="(On)"
Each time the pattern in the brackets is captured it counts as 1 match (first match = {Match.1}, second match = {Match.2} etc.).

Therefore {#M} tells you how many devices are on.

Of course, this will only work for devices that report their on/off state in this format.

The regex tool will show you a list of all the matches. It also provides the total number of matches in the label on the left.
It will not tell you the standard VC syntax for different variables, though. You'll need to know that {#M} refers to the total number of matches, or look in your parameter helper window in VC, or review the wiki page that lists all the standard VC variables.



« Last Edit: April 28, 2015, 12:20:41 PM by nime5ter »
TIPS: POST VC VERSION #. Explain what you want VC to do. Say what you've tried & what happened, or post a video demo. Attach VC log. Link to instructions followed.  Post your command (xml)

ddl

  • Sr. Member
  • ****
  • Posts: 118
  • Karma: 0
    • View Profile
Re: Regex Results
« Reply #12 on: April 28, 2015, 12:51:56 PM »
Got it, thanks.

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7715
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Regex Results
« Reply #13 on: April 28, 2015, 09:22:39 PM »
Why all the \ in front of property?

ddl

  • Sr. Member
  • ****
  • Posts: 118
  • Karma: 0
    • View Profile
Re: Regex Results
« Reply #14 on: April 29, 2015, 12:58:35 AM »
ok, i think I figured it out.  However, the results from the query above has spaces in it.  When i place the regex code in the regex tester it crashes at the point where it is a space.  How do I get pass that?  The "\s" does not work.

Code: [Select]
<?xml version="1.0" encoding="UTF-8"?><nodes><node id="11 B3 8F 1"><property id="ST" value="156" formatted="78.00" uom="degrees" /><property id="CLIMD" value="1" formatted="Heat" uom="n/a" /><property id="CLISPC" value=" " formatted=" " uom="degrees"/><property id="CLISPH" value="150" formatted="75.00" uom="degrees" /><property id="CLIHUM" value="73" formatted="73.00" uom="%" /></node><node id="14 2E B1 1"><property id="ST" value=" " formatted=" " uom="on/off"/></node><node id="14 2E B1 2"><property id="ST" value=" " formatted=" " uom="on/off"/></node><node id="14 2E B1 3"><property id="ST" value="0" formatted="Off" uom="on/off" /></node><node id="17 53 DB 1"><property id="ST" value="0" formatted="Off" uom="on/off" /></node><node id="17 54 96 1"><property id="ST" value="0" formatted="Off" uom="on/off" /></node><node id="1B 6E 54 1"><property id="ST" value="0" formatted="Off" uom="on/off" /></node><node id="1B 71 A0 1"><property id="ST" value="0" formatted="Off" uom="on/off" /></node><node id="1B 80 D2 1"><property id="ST" value="255" formatted="On" uom="on/off" /></node><node id="22 B2 82 1"><property id="ST" value="0" formatted="Off" uom="on/off" /></node><node id="24 99 A0 1"><property id="ST" value="0" formatted="Off" uom="%/on/off" /></node><node id="29 B9 D 1"><property id="ST" value="0" formatted="Off" uom="%/on/off" /></node><node id="2A 29 97 1"><property id="ST" value="0" formatted="Off" uom="%/on/off" /></node><node id="32 80 D2 1"><property id="ST" value="0" formatted="Off" uom="on/off" /></node><node id="C 7B 80 1"><property id="ST" value="0" formatted="Off" [b]uom="%/on/off" />[/b]</node><node id="ZW003_1"><property id="ST" value="100" formatted="Locked" uom="11" /></node><node id="ZW014_1"><property id="ST" value="0" formatted="Off" uom="78" /></node><node id="ZW015_1"><property id="ST" value="0" formatted="Off" uom="78" /></node><node id="ZW016_1"><property id="ST" value="0" formatted="Off" uom="78" /></node></nodes>
Code: [Select]
<node\sid="(.*?)"><property\sid="(.*?)"\svalue="(.*?)"\sformatted="(.*?)"\suom="(.*?)"\ /><property\sid="(.*?)"\svalue="(.*?)"\sformatted="(.*?)"\suom="(.*?)"/ ><property\sid="(.*?)"\svalue="(.*?)"\sformatted="(.*?)"\suom="(.*?)"><property\sid="(.*?)"\svalue="(.*?)"\sformatted="(.*?)"\suom="(.*?)"/></node><node\sid="(.*?)"><property\sid="(.*?)"\svalue="(.*?)"\sformatted="(.*?)"\suom="(.*?)"/></node><node\sid="(.*?)"><property\sid="(.*?)"\svalue="(.*?)"\sformatted="(.*?)"\suom="(.*?)"/></node><node\sid="(.*?)"><property\sid="(.*?)"\svalue="(.*?)"\sformatted="(.*?)"\suom="(.*?)"/></node><node\sid="(.*?)"><property\sid="(.*?)"\svalue="(.*?)"\sformatted="(.*?)"\suom="(.*?)"/></node><node\sid="(.*?)"><property\sid="(.*?)"\svalue="(.*?)"\sformatted="(.*?)"\suom="(.*?)"/></node><node\sid="(.*?)"><property\sid="(.*?)"\svalue="(.*?)"

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 2012
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: Regex Results
« Reply #15 on: April 29, 2015, 08:34:42 AM »
Generally, a regex pattern is as short as possible. It will return multiple matches of the same pattern; you don't need to repeat the pattern over and over again in your regular expression.

James gave you the proper pattern earlier in this thread for the regular expression that will capture the following info about each node:

1. node id
2. property id
3. property value
4. property formatted
5. uom (unit of measurement)

It is here: http://voxcommando.com/forum/index.php?topic=2135.msg18535#msg18535

If the first node matched {Match.1} is, for example:
Code: [Select]
node id="11 B3 8F 1"><property id="ST" value="156" formatted="78.00" uom="degrees"
Then {Match.1.1} is 11 B3 8F 1, {Match.1.2} is ST, {Match.1.3} is 156, {Match.1.4} is 78.00, {Match.1.5} is degrees.

The next node will be {Match.2}, and its component parts will be {Match.2.1}, {Match.2.2} etc.

The question is, what does grabbing all of this info at once do for you? What is it that you are trying to accomplish? Do you need all of those values?
« Last Edit: April 29, 2015, 08:40:23 AM by nime5ter »
TIPS: POST VC VERSION #. Explain what you want VC to do. Say what you've tried & what happened, or post a video demo. Attach VC log. Link to instructions followed.  Post your command (xml)

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 2012
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: Regex Results
« Reply #16 on: April 29, 2015, 04:53:25 PM »
Quote from: ddl
What I am trying to accomplish is:
1. Have VC tell me the total number of devices on my network
2. the total number of active/inactive devices on the network (this is identified by the "formatted" status) and
3. the status of a particular node if requested

After reading through your comment, I'm guessing there is a better way to write this command to achieve the results that I am looking for. I'm just not sure of it yet.

It sounds as though you want a group of commands, rather than a single command. The issue is not just mastering regular expressions, but thinking in terms of how VC works, and what types of ISY queries you can use that make it easier to isolate the values you're interested in, in each case.

There are different ways to parse your objectives, but I would probably break it down into as many as 5 commands -- something like:

Command 1: Scan my devices / (How many devices do I have)

Solution:
Scrape http://YOUR_ISY_URL/rest/status
Simple Results.regex --> node id="(.*?)" [just looking for node ids]
OSD.ShowText Total devices: {#M}
Store this value as a variable to be used in command 2, using Results.SetVar.


Command 2: Triggered automatically by command 1, using an event trigger. (Technically all this could be done in command 1 instead -- this is just my preference.)

Solution:
Scrape http://YOUR_ISY_URL/rest/status
Simple Results.regex --> formatted="\s" [looking ONLY for cases when formatted is blank (which I'm assuming means a device is inactive/disabled?)]

Then I can calculate active devices by subtracting inactive devices from my total. This requires that the Python plugin be enabled. We use it to do the math. Simply, PY.ExecString --> result = {var.devices} - {#M}

Now I can report the number of active ({LastResult}) and inactive ({#M}) devices.

Command 3: Get status info only for my lights.

To make this convenient, I would create a payload XML file associating the node IDs for each light switch device with that device's friendly name.

This way you can ask more naturally, "Is the hall light/living room light/bedroom light on?"

You take advantage of the fact that you can query the status for a specific node ID. You pass in the payload value for that specific device node id.

Solution:
Scrape http://YOUR_ISY_URL/rest/nodes/{1}/ST
Simple Results.regex --> formatted="(.*?)"

Now you can customize the feedback you receive based on whether the regex returns a value of on, off, or a number indicating the dim level of a dimmable light. You can use a logic block for this.
If {Match.1} is either on or off, VC tells you that. [If AcontainsB > On Off > {Match.1}, then "{PF.1} is {Match.1}"]
Otherwise, it tells you the dim level. (Slightly different wording to make this natural-sounding.)

Command 4: Give the thermostat its own special command, because it has various properties apart from its current status (What mode is the thermostat in? What's the humidity reading, etc.).

In this case I'd create a payload XML file that associates each of the 4 property IDs with a convenient phrase for that property ID. Along the lines of:
ST -> temperature
CLIMD -> mode
CLIHUM -> humidity reading
CLISPH -> heat set point

Now you can take advantage of your ability to query specific property types for specific nodes. You can hard code the node ID for the thermostat, and use a payload{1} to pass in the property that you're interested in:

Solution:
Scrape http://YOUR_ISY_URL/rest/nodes/11 B3 8F 1/{1}
Simple Results.regex --> formatted="(.*?)"
You can again customize the response with a logic block, or keep it simple and just report {Match.1} for whatever you asked for.

Command 5: Give your door lock its own command as well. (Basically, I prefer to monitor different types of devices using distinct commands, in part so that I can customize the feedback.

So, same scrape and regex as above but using the lock's node ID, and then you can customize the wording of both the voice command and the feedback so that it makes sense for a door lock.
« Last Edit: April 30, 2015, 12:32:53 PM by nime5ter »
TIPS: POST VC VERSION #. Explain what you want VC to do. Say what you've tried & what happened, or post a video demo. Attach VC log. Link to instructions followed.  Post your command (xml)

ddl

  • Sr. Member
  • ****
  • Posts: 118
  • Karma: 0
    • View Profile
Re: Regex Results
« Reply #17 on: April 30, 2015, 10:48:26 AM »
Thank you so much for this information.  I will spend some time this weekend with VC and the information that you all have provided.  I'll report back with my results next week.

Thanks again for the support.

ddl

  • Sr. Member
  • ****
  • Posts: 118
  • Karma: 0
    • View Profile
Re: Regex Results
« Reply #18 on: May 03, 2015, 01:37:05 PM »
Having trouble with creating command #2  What am I missing?

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.1.4.2-->
<command id="422" name="Scan my devices" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
  <action>
    <cmdType>Scrape</cmdType>
    <params>
      <param>http://192.168.1.5/rest/status</param>
      <param>don</param>
      <param>dond</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>RegExTool.Open</cmdType>
    <params>
      <param>True</param>
    </params>
    <cmdRepeat>0</cmdRepeat>
  </action>
  <action>
    <cmdType>Results.RegEx</cmdType>
    <params>
      <param>&lt;node\sid="(.*?)"</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>OSD.ShowText</cmdType>
    <params>
      <param>{#M}</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>Results.SetVar</cmdType>
    <params>
      <param>devices</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <phrase>How many devices do I have</phrase>
</command>

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.1.4.2-->
<command id="527" name="Scan devices 2" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
  <action>
    <cmdType>scrape</cmdType>
    <params>
      <param>http://192.168.1.5/rest/status</param>
      <param>don</param>
      <param>dond</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>RegExTool.Open</cmdType>
    <params>
      <param>True</param>
    </params>
    <cmdRepeat>0</cmdRepeat>
  </action>
  <action>
    <cmdType>Results.RegEx</cmdType>
    <params>
      <param>formatted="\s"</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>PY.ExecString</cmdType>
    <params>
      <param>result={var.devices} - {#M}</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
</command>

« Last Edit: May 03, 2015, 01:40:09 PM by nime5ter »

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 2012
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: Regex Results
« Reply #19 on: May 03, 2015, 01:46:10 PM »
Looks like there are a few small things. I'm a bit strapped for time so rather than explaining in detail, pls compare with the following. Hopefully these will work for you. If you have any questions let me/us know.

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.1.4.6-->
<command id="686" name="Scan my devices" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
  <action>
    <cmdType>Scrape</cmdType>
    <params>
      <param>http://192.168.1.5/rest/status</param>
      <param>don</param>
      <param>dond</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>Results.RegEx</cmdType>
    <params>
      <param>node\sid="(.*?)"</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>OSD.ShowText</cmdType>
    <params>
      <param>Total number of devices: {#M}</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>Results.SetVar</cmdType>
    <params>
      <param>devices</param>
      <param>{#M}</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>VC.TriggerEvent</cmdType>
    <params>
      <param>check.inactive</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <phrase>Scan my devices, How many devices do I have</phrase>
</command>

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.1.4.6-->
<command id="668" name="count active/inactive devices" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="You will need to have VC's Python plugin enabled to do the math calculation here.">
  <action>
    <cmdType>Scrape</cmdType>
    <params>
      <param>http://192.168.1.5/rest/status</param>
      <param>don</param>
      <param>dond</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>Results.RegEx</cmdType>
    <params>
      <param>formatted="\s"</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>OSD.AddText</cmdType>
    <params>
      <param>Inactive devices: {#M}</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>PY.ExecString</cmdType>
    <params>
      <param>result={var.devices}-{#M}</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>OSD.AddText</cmdType>
    <params>
      <param>Active devices: {LastResult}</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>TTS.Speak</cmdType>
    <params>
      <param>There are currently {LastResult} active devices and {#M} inactive devices on your network.</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <event>check.inactive</event>
</command>
« Last Edit: May 03, 2015, 03:22:11 PM by nime5ter »
TIPS: POST VC VERSION #. Explain what you want VC to do. Say what you've tried & what happened, or post a video demo. Attach VC log. Link to instructions followed.  Post your command (xml)

ddl

  • Sr. Member
  • ****
  • Posts: 118
  • Karma: 0
    • View Profile
Re: Regex Results
« Reply #20 on: May 03, 2015, 08:31:23 PM »
Thanks... I have compared the two and I understand what was done.  That said, I'm stuck on command #3 as well.  I can't seem to figure out how I associate the payload file that I have created for the node id's.  Here is what I have done so far.

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.1.4.2-->
<command id="492" name="Get Status Info For My Lights" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
  <action>
    <cmdType>Scrape</cmdType>
    <params>
      <param>http://192.168.1.5/rest/nodes/</param>
      <param>don</param>
      <param>dond</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>RegExTool.Open</cmdType>
    <params>
      <param>True</param>
    </params>
    <cmdRepeat>0</cmdRepeat>
  </action>
  <action>
    <cmdType>Results.RegEx</cmdType>
    <params>
      <param>formatted="(.*?)</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType />
    <params />
    <cmdRepeat>1</cmdRepeat>
  </action>
  <payloadFromXML phraseOnly="False" use2partPhrase="False" phraseConnector="by" Phrase2wildcard="anyone" optional="False">payloads\ISYNodeNames.xml</payloadFromXML>
</command>
« Last Edit: May 03, 2015, 09:02:09 PM by nime5ter »

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 2012
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: Regex Results
« Reply #21 on: May 03, 2015, 09:11:52 PM »
In the future, please put always put your command xml in a code box when you post it to the forum. There are two reasons we ask for this: 1) The code boxes have a fixed height, so long code takes up much less space on the page; 2) It makes it much easier for others to select/copy the xml.

Try the URL that I originally suggested you use for Command 3.

If you take another look, you'll see that I include the syntax for a payload value within the URL. If the documentation that I read was correct, that should be the proper url to get status properties for a particular node.

You might also want to take a bit of time to review the wiki documentation on payloads and perhaps watch the second Fireside Chat video. Various users have said they find that video really helpful for understanding how to use payloads. Getting a better grasp of that will save you a lot of time in the long run.

TIPS: POST VC VERSION #. Explain what you want VC to do. Say what you've tried & what happened, or post a video demo. Attach VC log. Link to instructions followed.  Post your command (xml)

ddl

  • Sr. Member
  • ****
  • Posts: 118
  • Karma: 0
    • View Profile
Re: Regex Results
« Reply #22 on: May 03, 2015, 09:34:59 PM »
Will do, thanks.

ddl

  • Sr. Member
  • ****
  • Posts: 118
  • Karma: 0
    • View Profile
Re: Regex Results
« Reply #23 on: May 03, 2015, 10:17:56 PM »
Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.1.4.2-->
<command id="492" name="Get Status Info For My Lights" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
  <action>
    <cmdType>Scrape</cmdType>
    <params>
      <param>http://192.168.1.5/rest/node/{1}/ST</param>
      <param>don</param>
      <param>dond</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>RegExTool.Open</cmdType>
    <params>
      <param>True</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>Results.RegEx</cmdType>
    <params>
      <param>formatted="(.*?)"</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <payloadFromXML phraseOnly="False" use2partPhrase="False" phraseConnector="by" Phrase2wildcard="anyone" optional="False">payloads\ISYNodeNames.xml</payloadFromXML>
</command>

Not working for me.  I get the following error:

"system.net web exception... 404 not found

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 2012
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: Regex Results
« Reply #24 on: May 03, 2015, 10:22:21 PM »
Edit: On first glance, looked like you wrote "node" instead of "nodes" in the URL.
« Last Edit: May 03, 2015, 10:31:10 PM by nime5ter »
TIPS: POST VC VERSION #. Explain what you want VC to do. Say what you've tried & what happened, or post a video demo. Attach VC log. Link to instructions followed.  Post your command (xml)

ddl

  • Sr. Member
  • ****
  • Posts: 118
  • Karma: 0
    • View Profile
Re: Regex Results
« Reply #25 on: May 03, 2015, 10:34:29 PM »
Made the correction but still got the error.  The log file is attached.


nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 2012
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: Regex Results
« Reply #26 on: May 03, 2015, 10:36:06 PM »
A few things:

The URL should be "nodes" plural: http://192.168.1.5/rest/nodes/{1}/ST

But also: To test this command, you need to properly issue the voice command, not use Save & Execute. Otherwise the command will not know the payload value.

http://voxcommando.com/mediawiki/index.php?title=Payloads#More_on_Payload_XML

And in case it's not clear, your payload xml should have phrases like "kitchen light" associated with a node ID that is in the value column.

The other way to test the command if you can't issue a voice command, is to enter a node ID value in the {1} Test payloads field of the LCB, and then you can use the Save & Execute button.

« Last Edit: May 03, 2015, 10:39:49 PM by nime5ter »
TIPS: POST VC VERSION #. Explain what you want VC to do. Say what you've tried & what happened, or post a video demo. Attach VC log. Link to instructions followed.  Post your command (xml)

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 2012
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: Regex Results
« Reply #27 on: May 03, 2015, 10:46:37 PM »
I'm about to go to bed, but basically:

The idea behind the 3rd command is that you would be asking for the status of a particular light. I had in mind something like this:

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.1.4.6-->
<command id="653" name="Status of light {1}" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="Where {1} is the node ID. &#xD;&#xA;The variable {PF.1} is the phrase in your payload xml file associated with the node id.">
  <action>
    <cmdType>Scrape</cmdType>
    <params>
      <param>http://YOUR_ISY_URL/rest/nodes/{1}/ST</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>Results.RegEx</cmdType>
    <params>
      <param>formatted="(.*?)"</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <if ifBlockDisabled="False" ifNot="False">
    <ifType>(A)Contains(B)</ifType>
    <ifParams>Off On&amp;&amp;{Match.1}</ifParams>
    <then>
      <action>
        <cmdType>OSD.ShowText</cmdType>
        <params>
          <param>{PF.1} is currently {Match.1}.</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
      <action>
        <cmdType>TTS.Speak</cmdType>
        <params>
          <param>{PF.1} is currently {Match.1}</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
    </then>
    <else>
      <action>
        <cmdType>OSD.ShowText</cmdType>
        <params>
          <param>{PF.1} is on, with a brightness level of {Match.1}%.</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
      <action>
        <cmdType>TTS.Speak</cmdType>
        <params>
          <param>{PF.1} is on, with a brightness level of {Match.1}%</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
    </else>
  </if>
  <phrase>Is the</phrase>
  <payloadFromXML phraseOnly="False" use2partPhrase="False" phraseConnector="by" Phrase2wildcard="anyone" optional="False">payloads\ISYNodeNames.xml</payloadFromXML>
  <phrase>on, off</phrase>
</command>

I don't have your hardware so I can't say for sure that the URL is correct, but probably it is.
TIPS: POST VC VERSION #. Explain what you want VC to do. Say what you've tried & what happened, or post a video demo. Attach VC log. Link to instructions followed.  Post your command (xml)

ddl

  • Sr. Member
  • ****
  • Posts: 118
  • Karma: 0
    • View Profile
Re: Regex Results
« Reply #28 on: May 03, 2015, 10:54:10 PM »
Sorry,  Im just not getting it.  I'll review the links when I have more time.


ddl

  • Sr. Member
  • ****
  • Posts: 118
  • Karma: 0
    • View Profile
Re: Regex Results
« Reply #29 on: May 03, 2015, 10:56:03 PM »
ok, I'll look at this in the morning with fresh eyes.  Thanks for your help.

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 2012
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: Regex Results
« Reply #30 on: May 04, 2015, 01:34:53 PM »
Apart from the fact that the command 3 I had in mind was specifically for retrieving light device info, your payload XML looks perfectly fine. (And you could certainly just make one command to get the status of any type of device; I just think dividing it up would provide more control over how you handle the returned values.)

Sorry,  Im just not getting it.  I'll review the links when I have more time.

Another video tutorial that might help you is the Vera plugin tutorial, even though you don't have a Vera. It describes the process of building commands for home automation using payload XML, which might help clarify the basic thinking behind how such commands are structured.

I suspect that if you can find some time to just concentrate on exploring the available resources that explain the fundamentals: how payloads work, how variables work, how command testing works, you will ultimately save a TON of time -- and frustration.
TIPS: POST VC VERSION #. Explain what you want VC to do. Say what you've tried & what happened, or post a video demo. Attach VC log. Link to instructions followed.  Post your command (xml)

ddl

  • Sr. Member
  • ****
  • Posts: 118
  • Karma: 0
    • View Profile
Re: Regex Results
« Reply #31 on: May 10, 2015, 10:52:56 AM »
This weekend I took some time to review this thread, the wiki and the links/videos suggested.  After my review I do have a better understanding of how Regex and payloads work in VC.  That said, I still need a little help with drafting the number 3 command.  First, let me say that after spending hours trying to formulate the correct syntax for the scrape command for getting the requested information from the ISY.  I have learned that the URL http://192.168.1.5/rest/nodes/{1}/ST is not recognized by the ISY as written.  The ISY does not recognize the payload indicator {1} and "ST".  Instead i have used http://192.168.1.5/rest/status.  This url gives me the status of all devices in the ISY.  See the full results below.

Code: [Select]
<?xml version="1.0" encoding="UTF-8"?><nodes><node id="11 B3 8F 1"><property id="ST" value="154" formatted="77.00" uom="degrees" /><property id="CLIMD" value="2" formatted="Cool" uom="n/a" /><property id="CLISPC" value="154" formatted="77.00" uom="degrees" /><property id="CLISPH" value=" " formatted=" " uom="degrees"/><property id="CLIHUM" value="75" formatted="75.00" uom="%" /></node><node id="14 2E B1 1"><property id="ST" value=" " formatted=" " uom="on/off"/></node><node id="14 2E B1 2"><property id="ST" value=" " formatted=" " uom="on/off"/></node><node id="14 2E B1 3"><property id="ST" value="0" formatted="Off" uom="on/off" /></node><node id="17 53 DB 1"><property id="ST" value="0" formatted="Off" uom="on/off" /></node><node id="17 54 96 1"><property id="ST" value="0" formatted="Off" uom="on/off" /></node><node id="1B 6E 54 1"><property id="ST" value="0" formatted="Off" uom="on/off" /></node><node id="1B 71 A0 1"><property id="ST" value="0" formatted="Off" uom="on/off" /></node><node id="1B 80 D2 1"><property id="ST" value="0" formatted="Off" uom="on/off" /></node><node id="22 B2 82 1"><property id="ST" value="0" formatted="Off" uom="on/off" /></node><node id="24 99 A0 1"><property id="ST" value="0" formatted="Off" uom="%/on/off" /></node><node id="29 B9 D 1"><property id="ST" value="0" formatted="Off" uom="%/on/off" /></node><node id="2A 29 97 1"><property id="ST" value="0" formatted="Off" uom="%/on/off" /></node><node id="32 80 D2 1"><property id="ST" value="0" formatted="Off" uom="on/off" /></node><node id="C 7B 80 1"><property id="ST" value="0" formatted="Off" uom="%/on/off" /></node><node id="ZW003_1"><property id="ST" value="100" formatted="Locked" uom="11" /></node><node id="ZW014_1"><property id="ST" value="0" formatted="Off" uom="78" /></node><node id="ZW015_1"><property id="ST" value="0" formatted="Off" uom="78" /></node><node id="ZW016_1"><property id="ST" value="0" formatted="Off" uom="78" /></node></nodes>
To grab the information that I need for VC to report on I used the following Regex code:

Code: [Select]
node\sid="(.*?)"><property\sid="(.*?)"\svalue="(.*?)"\sformatted="(.*?)"
At this point everything appears to work ok until I get to my logic block.  The results from the logic block that I have written only reports half of the information correctly.  Here is what i have written so far:

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.1.4.2-->
<command id="512" name="Device Status {1}" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
  <action>
    <cmdType>Scrape</cmdType>
    <params>
      <param>http://192.168.1.5/rest/status</param>
      <param>don</param>
      <param>dond</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>RegExTool.Open</cmdType>
    <params>
      <param>True</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>Results.RegEx</cmdType>
    <params>
      <param>node\sid="(.*?)"&gt;&lt;property\sid="(.*?)"\svalue="(.*?)"\sformatted="(.*?)"</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <if ifBlockDisabled="False" ifNot="False">
    <ifType>(A)Contains(B)</ifType>
    <ifParams>{Match.1.4}&amp;&amp;{Match.1.4}</ifParams>
    <then>
      <action>
        <cmdType>OSD.ShowText</cmdType>
        <params>
          <param>{PF.1} is currently {Match.1.4}</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
      <action>
        <cmdType>TTS.SpeakSync</cmdType>
        <params>
          <param>{PF.1} is currently {Match.1.4}</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
    </then>
    <else />
  </if>
  <action>
    <cmdType />
    <params />
    <cmdRepeat>1</cmdRepeat>
  </action>
  <phrase>Is the, What is the</phrase>
  <payloadFromXML phraseOnly="False" use2partPhrase="True" phraseConnector="by" Phrase2wildcard="anyone" optional="False">payloads\ISYNodeNames.xml</payloadFromXML>
  <phrase>On Off , Status</phrase>
</command>

At the end of the day, VC reports the status of the device incorrectly when using the "what is the" kitchen main light (as written in the payload file) command.  It will report back the first device status as indicated by the "{Match.1.4}"

How do I write the logic block so that it reports back the correct status for any device that I request that information for?

Also, while I know that i can write a command for each device individually I was just looking to save time by using a payload as suggestd.

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 2012
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: Regex Results
« Reply #32 on: May 10, 2015, 11:24:24 AM »
I'll take a look and get back to you.

In the meantime, could you please do the following for me?

Enable VC logging (if it's not already enabled), then run the following command exactly as is, then post your log for me? Thanks.

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.1.4.6-->
<command id="766" name="Test status command" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
  <action>
    <cmdType>Scrape</cmdType>
    <params>
      <param>http://192.168.1.5/rest/nodes/11 B3 8F 1/ST</param>
      <param>don</param>
      <param>dond</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>System.SetClipboardText</cmdType>
    <params>
      <param>Test 1: {LastResult}</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>Scrape</cmdType>
    <params>
      <param>http://192.168.1.5/rest/nodes/11%20B3%208F%201/ST</param>
      <param>don</param>
      <param>dond</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>System.SetClipboardText</cmdType>
    <params>
      <param>Test 2: {LastResult}</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <phrase>Test status command</phrase>
</command>
TIPS: POST VC VERSION #. Explain what you want VC to do. Say what you've tried & what happened, or post a video demo. Attach VC log. Link to instructions followed.  Post your command (xml)

ddl

  • Sr. Member
  • ****
  • Posts: 118
  • Karma: 0
    • View Profile
Re: Regex Results
« Reply #33 on: May 10, 2015, 11:30:17 AM »
Thank you...

Here is the log as requested.


nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 2012
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: Regex Results
« Reply #34 on: May 10, 2015, 11:41:49 AM »
Thank you, that's helpful.

The command that we just tested used the URL that I initially suggested: http://192.168.1.5/rest/nodes/<node id>/ST, and works correctly according the log.

If you look at the Scrape action in that command, you'll see that we used the id for a specific node: 11 B3 8F 1, which is your thermostat.

It returned the following response when you executed the command:

Code: [Select]
<?xml version="1.0" encoding="UTF-8"?><properties><property id="ST" value="154" formatted="77.00" uom="degrees" /></properties>
This result, and now looking at the command you posted above where you're grabbing the status of all devices, indicates to me that you're still not understanding how payloads work. This will be the challenge to overcome, not the regular expression aspect.

You may have already watched this, but can you please watch the following section of the Vera tutorial video again?

&feature=youtu.be&t=5m56s

It gives a step-by-step example of using 2 types of payloads to control dimmable lights. I'm hoping that will give us a better starting point for moving forward.

In the meantime I will work on a follow-up post to discuss your command above.
TIPS: POST VC VERSION #. Explain what you want VC to do. Say what you've tried & what happened, or post a video demo. Attach VC log. Link to instructions followed.  Post your command (xml)

ddl

  • Sr. Member
  • ****
  • Posts: 118
  • Karma: 0
    • View Profile
Re: Regex Results
« Reply #35 on: May 10, 2015, 11:47:13 AM »
ok, I will watch the video again. 


ddl

  • Sr. Member
  • ****
  • Posts: 118
  • Karma: 0
    • View Profile
Re: Regex Results
« Reply #36 on: May 10, 2015, 12:02:38 PM »
I think I am confused by the Scrape "http://192.168.1.5/rest/nodes/{1}/ST".  My interpretation of this is that VC is scraping the isy and referencing the payload file (not individual node) for the devices state.  The URL" http://192.168.1.5/rest/nodes/{1}/ST" as written is not accepted by the ISY and returns and error.  This is why I used the URL "http://192.168.1.5/rest/status"

In my mind, if after I asking for the status of the kitchen light VC scans the payload list for the device to report its status.  Correct?  If not, that is where my problem is and I can't do what I thought I could do without creating a separate command for each node.

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 2012
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: Regex Results
« Reply #37 on: May 10, 2015, 12:38:27 PM »
That's not what's happening.

VC cannot scrape ISY if it is not using a valid URL.

http://192.168.1.5/rest/nodes/{1}/ST is certainly not a valid URL.

It becomes a valid URL when you issue the command correctly, so that the node ID *replaces* {1} in your macro, and then VC will scrape that URL.

Your command is not working when you issue it because you are not issuing the command correctly, somehow.

Either there's something wrong with your payloadXML file, or with how you are saying the command.

Or, if you are not saying the command but trying to execute it by clicking "save and execute" then you have not entered a node ID in the Test payload field as demonstrated in the video.

I'm sorry for the following super-long post. I hope it's manageable. I discuss both the command you posted today, as well as the original suggestion.

----

It *is* possible to get the status of a specific device using the method you were trying, but it will be a bit more complicated than the way I originally suggested.

I can't decide if it will be helpful or just confusing to explain why. But here goes.

Your command phrase that you posted is: What is the {ISY Node Name} status?

the {ISY Node Name} refers to the payload XML file you created, in which you have friendly names associated with node IDs.

The only way VoxCommando can then use that node ID that you specify in your voice command is for you to have the equivalent payload value {1} in your command macro.

Using a payload in your command phrase is not enough. You need to pass that to the macro.

Let's look at the original command format that I suggested for a second.

In the *original* command that I suggested, the node ID should have been passed into the URL:

Code: [Select]
http://192.168.1.5/rest/nodes/{1}/ST
So, if you had verbally issued (i.e., said) the command "What is my {thermostat} status", then VC would know to use the node ID associated with that friendly name: 11 B3 8F 1, and it would pass that into the URL in the Scrape action.

Code: [Select]
http://192.168.1.5/rest/nodes/11 B3 8F 1/ST
But if you don't actually say the command but instead just try to "save and execute" without giving the command a payload value, VC would have had no idea what {1} stands for, and it would not have scraped the proper URL. In other words, there is no such URL as: http://192.168.1.5/rest/nodes/{1}/ST. We have to issue the command correctly, passing a proper node ID value to the command.

Now back to the command you're trying to use, which you posted today:

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.1.4.2-->
<command id="512" name="Device Status {1}" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
  <action>
    <cmdType>Scrape</cmdType>
    <params>
      <param>http://192.168.1.5/rest/status</param>
      <param>don</param>
      <param>dond</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>RegExTool.Open</cmdType>
    <params>
      <param>True</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>Results.RegEx</cmdType>
    <params>
      <param>node\sid="(.*?)"&gt;&lt;property\sid="(.*?)"\svalue="(.*?)"\sformatted="(.*?)"</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <if ifBlockDisabled="False" ifNot="False">
    <ifType>(A)Contains(B)</ifType>
    <ifParams>{Match.1.4}&amp;&amp;{Match.1.4}</ifParams>
    <then>
      <action>
        <cmdType>OSD.ShowText</cmdType>
        <params>
          <param>{PF.1} is currently {Match.1.4}</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
      <action>
        <cmdType>TTS.SpeakSync</cmdType>
        <params>
          <param>{PF.1} is currently {Match.1.4}</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
    </then>
    <else />
  </if>
  <action>
    <cmdType />
    <params />
    <cmdRepeat>1</cmdRepeat>
  </action>
  <phrase>Is the, What is the</phrase>
  <payloadFromXML phraseOnly="False" use2partPhrase="True" phraseConnector="by" Phrase2wildcard="anyone" optional="False">payloads\ISYNodeNames.xml</payloadFromXML>
  <phrase>On Off , Status</phrase>
</command>

If you choose to scrape all devices, then in order to get the status of one specific device, you should tell the command which device you are interested in. That means passing it the node ID as a payload value, so it knows which node to isolate out of all the possible nodes.

But nowhere in that command have you specified the node ID. That is, {1} is missing from your macro. So VC will have no idea which device it should be looking for in the feedback that it receives from ISY.

Your current regular expression is:

Code: [Select]
node\sid="(.*?)"&gt;&lt;property\sid="(.*?)"\svalue="(.*?)"\sformatted="(.*?)"
{Match.1.4} will return the formatted value of the very first device listed. In your case, that is always the thermostat.

So how can you find the node you're actually interested in? Instead of using a general pattern that will match for every device you have, you should instead use a pattern that only works for the node you are interested in.

In other words, tell it what node ID to find.

Code: [Select]
node\sid="{1}"&gt;&lt;property\sid="(.*?)"\svalue="(.*?)"\sformatted="(.*?)"
So, if you ask for the "motion detector low battery" status, its node ID (14 2E B1 3) is passed into the regular expression.

Code: [Select]
node\sid="14 2E B1 3"&gt;&lt;property\sid="(.*?)"\svalue="(.*?)"\sformatted="(.*?)"
Note that now you only have 3 sets of brackets in your regular expression, so the "formatted" value will be {Match.1.3} now (you're not capturing the node id).

Unfortunately, now we get into a complication caused by how regular expressions work. So while the above is correct as a concept, we have more tap-dancing to do because your node IDs have spaces in them, and regular expressions don't like spaces. (This is why you use "\s" in your regex above.)

Here is one way to overcome the problem. What we do is:

1. Pass the payload {1} value into the command and set it to be the {LastResult}
2. Then we replace the spaces with a . character (you could also use \s)
3. We save the node id, now in the format like 14.2E.B1.3 as a variable I call "device".
4. Now you can use the {var.device} variable in the regular expression.

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.1.4.6-->
<command id="512" name="Device Status {1}" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
  <action>
    <cmdType>Results.SetLastResult</cmdType>
    <params>
      <param>{1}</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>Results.Replace</cmdType>
    <params>
      <param><![CDATA[ ]]></param>
      <param>.</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>Results.SetVar</cmdType>
    <params>
      <param>device</param>
      <param>{LastResult}</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>Scrape</cmdType>
    <params>
      <param>http://192.168.1.5/rest/status</param>
      <param>don</param>
      <param>dond</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>Results.RegEx</cmdType>
    <params>
      <param>node\sid="{var.device}"&gt;&lt;property\sid="(.*?)"\svalue="(.*?)"\sformatted="(.*?)"</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>OSD.ShowText</cmdType>
    <params>
      <param>{PF.1} is currently {Match.1.3}</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>TTS.Speak</cmdType>
    <params>
      <param>{PF.1} is currently {Match.1.3}</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <phrase>Is the, What is the</phrase>
  <payloadFromXML phraseOnly="False" use2partPhrase="True" phraseConnector="by" Phrase2wildcard="anyone" optional="False">payloads\ISYNodeNames.xml</payloadFromXML>
  <phrase>On, Off , Status</phrase>
</command>

Personally, I think my original suggestion to use the status URL that specific to each node is a cleaner solution, but this way also works.


« Last Edit: May 10, 2015, 01:04:32 PM by nime5ter »
TIPS: POST VC VERSION #. Explain what you want VC to do. Say what you've tried & what happened, or post a video demo. Attach VC log. Link to instructions followed.  Post your command (xml)

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 2012
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: Regex Results
« Reply #38 on: May 10, 2015, 12:53:48 PM »
There is another possibility for why "http://192.168.1.5/rest/nodes/{1}/ST" hasn't worked.

It may be that this URL doesn't work for all the various types of devices you have. The documentation implies that it should, but who knows.

I know that it works for your thermostat, because we tested that this morning. I'm quite sure it will work for your light switches as well. If you always issued the command asking for the status of a particular device type -- and by chance that device type doesn't support that type of request -- then the command would have failed.

The easiest way to know would probably be to enter different node IDs into the command I had you test earlier, and see what kind of results you get back.
TIPS: POST VC VERSION #. Explain what you want VC to do. Say what you've tried & what happened, or post a video demo. Attach VC log. Link to instructions followed.  Post your command (xml)

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 2012
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: Regex Results
« Reply #39 on: May 10, 2015, 01:23:25 PM »
Here is the original command 3 that I suggested (basically). I've kept your phrasing. Give it a try.

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.1.4.6-->
<command id="512" name="Device Status {1}" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
  <action>
    <cmdType>Scrape</cmdType>
    <params>
      <param>http://192.168.1.5//rest/nodes/{1}/ST</param>
      <param>don</param>
      <param>dond</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>Results.RegEx</cmdType>
    <params>
      <param>formatted="(.*?)"</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>OSD.ShowText</cmdType>
    <params>
      <param>The status of {PF.1} is {Match.1}.</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>TTS.Speak</cmdType>
    <params>
      <param>The status of {PF.1} is {Match.1}</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <phrase>Is the, What is the</phrase>
  <payloadFromXML phraseOnly="False" use2partPhrase="True" phraseConnector="by" Phrase2wildcard="anyone" optional="False">payloads\ISYNodeNames.xml</payloadFromXML>
  <phrase>On, Off , Status</phrase>
</command>
TIPS: POST VC VERSION #. Explain what you want VC to do. Say what you've tried & what happened, or post a video demo. Attach VC log. Link to instructions followed.  Post your command (xml)

ddl

  • Sr. Member
  • ****
  • Posts: 118
  • Karma: 0
    • View Profile
Re: Regex Results
« Reply #40 on: May 10, 2015, 01:55:29 PM »
Wow!  I'am getting it. :) This was so helpful!  Thanks so much for the detailed response.  It is without a doubt that I will study and learn from all of it. Thanks again for your patience and prompt attention.  I really appreciate it. 

I will put this to test and report back shortly.