Author Topic: Return Multiple Values from single phrase in Payload?  (Read 6656 times)

0 Members and 1 Guest are viewing this topic.

JasonFox

  • $upporter
  • Jr. Member
  • *****
  • Posts: 27
  • Karma: 4
    • View Profile
Return Multiple Values from single phrase in Payload?
« on: October 13, 2013, 05:53:42 PM »
Currently I'm using individual commands to send IR codes to my iTach to change TV (more specifically Tivo) channels. I'd like to change this to a single command that uses a payload.xml with the channel names and the #s and/or IR codes map codes as the values. The problem I have is that I need each # to be sent separately with a short pause between. Is there a way to have a payload with channel name as the phrase and the mapped channel commands as the values loaded into {1),{2}.{3},{4}? For example I'll paste my existing command for CNN below. Can a payload.xml take an input of C N N and output values in {1},{2},{3}, and {4} that are would go in the <cmdString>fields? (I hope that made sense  :P

Thanks in advance for any advice.

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<command id="705" name="Tivo - CNN/1022" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
  <action>
    <cmdType>TCP.Single.Write</cmdType>
    <cmdString>{M:GcTivo.TIVO - 1}</cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>VC.Pause</cmdType>
    <cmdString>200</cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>TCP.Single.Write</cmdType>
    <cmdString>{M:GcTivo.TIVO - 0}</cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>VC.Pause</cmdType>
    <cmdString>200</cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>TCP.Single.Write</cmdType>
    <cmdString>{M:GcTivo.TIVO - 2}</cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>VC.Pause</cmdType>
    <cmdString>200</cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>TCP.Single.Write</cmdType>
    <cmdString>{M:GcTivo.TIVO - 2}</cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>VC.Pause</cmdType>
    <cmdString>200</cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>TCP.Single.Write</cmdType>
    <cmdString>{M:GcTivo.TIVO - ENTER/LAST}</cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <phrase>Tivo Change Channel to C N N</phrase>
</command>


Kalle

  • $upporter
  • Hero Member
  • *****
  • Posts: 2320
  • Karma: 47
    • View Profile
Re: Return Multiple Values from single phrase in Payload?
« Reply #1 on: October 14, 2013, 06:46:15 AM »
I'm absolutely not firm with the iTach/TCP things, but what you will do (if I understand it correctly), is calling a value from a payload that has stored payloads as value - that made no sense.  ::hmm
***********  get excited and make things  **********

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 1999
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: Return Multiple Values from single phrase in Payload?
« Reply #2 on: October 14, 2013, 11:02:21 AM »
I had fun figuring this one out! (Thanks to jitterjames for pointing out to me that Tcp.Client.Write actions have a built-in optional 'pause' parameter.)

I thought with the iTach you are supposed to use WriteLn rather than just Write because the iTach expects a new line at the end of the command, which is why I am using Tcp.Client.WriteLn in this command. It's possible that with WriteLn you might not need to add a pause (unless it's the Tivo that needs the pause, rather than iTach?). You could test the following code with and without the pause.

In this command, a single channel number payload {1} is used. The regex action then evaluates each digit within a channel number as a separate match.

The first Tcp.Client.WriteLn action iterates through the matches #M times.

Of course, you'll need to change the iTach IP etc. to the correct IP for your iTach. And you'll need to create your TivoChannels payloadXML file.

I don't have a Tivo so this was a hypothetical exercise for me, tested using a dummy map. I hope it works, or requires only basic tweaks!

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<command id="724" name="Tivo channel {1}" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="1">
  <action>
    <cmdType>TTS.Speak</cmdType>
    <cmdString>Switching to channel: {PF.1}</cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>Tcp.Client.Connect</cmdType>
    <cmdString>iTach&amp;&amp;192.168.0.100&amp;&amp;4998</cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>Results.RegEx</cmdType>
    <cmdString>(\d)&amp;&amp;&amp;&amp;{1}</cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>Tcp.Client.WriteLn</cmdType>
    <cmdString>iTach&amp;&amp;{M:GcTivo.TIVO - {Match.{i}}}&amp;&amp;200</cmdString>
    <cmdRepeat>{#M}</cmdRepeat>
  </action>
  <action>
    <cmdType>Tcp.Client.WriteLn</cmdType>
    <cmdString>iTach&amp;&amp;{M:GcTivo.TIVO - ENTER/LAST}</cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>TCP.Client.Disconnect</cmdType>
    <cmdString>iTach</cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <phrase>Tivo Change Channel to</phrase>
  <payloadFromXML phraseOnly="False" use2partPhrase="False" phraseConnector="by" Phrase2wildcard="anyone" optional="False">TivoChannels</payloadFromXML>
</command>
« Last Edit: October 14, 2013, 12:29:47 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)

JasonFox

  • $upporter
  • Jr. Member
  • *****
  • Posts: 27
  • Karma: 4
    • View Profile
Re: Return Multiple Values from single phrase in Payload?
« Reply #3 on: October 14, 2013, 06:25:50 PM »
Thank you very much nime5ter! This works perfectly for changing channels on my Tivo. I have no RegEx experience so would never have been able to do this myself. This was very educational for me.

Strangely the first action (The TTS.Speak command) doesn't execute when I speak the command. If I use the 'save and execute' button from within the command editor and add a channel name in the payload field it does the TTS but does not sent the iTach commands. Screenshots from the history below. So long as it keeps actually changing the channels I'm happy but from a learning perspective I'm curious as to what the problem could be.




Anyway thank you again. VC and this forum continue to amaze me!


Kalle

  • $upporter
  • Hero Member
  • *****
  • Posts: 2320
  • Karma: 47
    • View Profile
Re: Return Multiple Values from single phrase in Payload?
« Reply #4 on: October 14, 2013, 06:40:31 PM »
You can try TTS.SpeakSync instead as TTS.Speak, maybe it can help.


@nime: You are the "RegExinator"  ::bow :clap
« Last Edit: October 14, 2013, 06:46:20 PM by Kalle »
***********  get excited and make things  **********

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 1999
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: Return Multiple Values from single phrase in Payload?
« Reply #5 on: October 14, 2013, 07:23:46 PM »
I'm glad you're able to change channels, that's great.

Apart from Kalle's suggestion, which may do the trick, it's hard for me to tell what's working and what isn't based on your screenshots, because the screenshots actually show 2 different commands, from what I can see.

The top image shows what looks like my code, but the bottom one is using TCP.SingleWrite and I see no sign of the Regex action, so I have no idea how it's creating such magic for you!

With regard to testing by manually entering "C N N" in the payload field and using the save and execute: to test your command this way you would need to use the payloadXML value, not the payloadXML phrase. The way payloadXML works is that the value column corresponds to {1} and the phrase column corresponds to {PF.1} (aka 'friendly payload' -- a description of a payload that humans can understand).

So, to test the command using the payload field you need to enter channel numbers not channel names. If you look again at the top screenshot, you can see that the regex action is trying to evaluate "C N N", when what it needs is the channel number.

It could be that this is the reason the code didn't work for you except for the TTS.Speak line. However, since the first line indicating an error is the TCP client connect line, maybe it's not that. You might also want to  double-check the IP and port parameters there.
« Last Edit: October 14, 2013, 07:26:23 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: 1999
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: Return Multiple Values from single phrase in Payload?
« Reply #6 on: October 14, 2013, 07:29:45 PM »
@nime: You are the "RegExinator"  ::bow :clap

Yes, I totally am now.  ;D

After jitterjames posted that initial Internet Radio xml for Radio Paradise I became obsessed with mastering it and its applications.

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)

JasonFox

  • $upporter
  • Jr. Member
  • *****
  • Posts: 27
  • Karma: 4
    • View Profile
Re: Return Multiple Values from single phrase in Payload?
« Reply #7 on: October 14, 2013, 07:33:17 PM »
The good news I've figured out why the channel changes and I get no speech. The bad news is that the reason is I was an idiot and didn't disable the old individual commands when I was testing.  :bonk   So when I said "Tivo change channel to C N N" VC was executing the actions in my old command. The new command you wrote wasn't being executed.
 
Once I disabled all the individual channel commands I had written previously I get the TTS w/ a failed iTach command everytime.  :(

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 1999
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: Return Multiple Values from single phrase in Payload?
« Reply #8 on: October 14, 2013, 07:40:09 PM »
Ha, yes, sorry to laugh. But it just now popped into my head what was happening with the second command and I was just sitting down to post that here.

Is it at all possible that either the port number or the IP you've entered for the iTACH are incorrect?
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: 1999
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: Return Multiple Values from single phrase in Payload?
« Reply #9 on: October 14, 2013, 07:56:07 PM »
Once I disabled all the individual channel commands I had written previously I get the TTS w/ a failed iTach command everytime.  :(

Brainstorm: Have you tried issuing my command more than once at a time?

If not, can you try that to see if it fails the first time but then works after that?

(Reason being, if you are already connected to the itach for some other reason, then trying to connect within this command will fail. But it should work the second time if this is the issue because at the end of my command there's a tcp.client.disconnect action.)
« Last Edit: October 14, 2013, 07:58:52 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)

JasonFox

  • $upporter
  • Jr. Member
  • *****
  • Posts: 27
  • Karma: 4
    • View Profile
Re: Return Multiple Values from single phrase in Payload?
« Reply #10 on: October 14, 2013, 07:58:34 PM »
That was my next thought as well but I modified the old command to use Client.WriteLn and it worked perfectly so that's not the problem.

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<command id="758" name="Tivo - CNN/1022" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="" description="">
  <action>
    <cmdType>Tcp.Client.Connect</cmdType>
    <cmdString>iTach&amp;&amp;192.168.1.102&amp;&amp;4998</cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>Tcp.Client.WriteLn</cmdType>
    <cmdString>iTach&amp;&amp;{M:GcTivo.TIVO - 1}</cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>VC.Pause</cmdType>
    <cmdString>200</cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>Tcp.Client.WriteLn</cmdType>
    <cmdString>iTach&amp;&amp;{M:GcTivo.TIVO - 0}</cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>VC.Pause</cmdType>
    <cmdString>200</cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>Tcp.Client.WriteLn</cmdType>
    <cmdString>iTach&amp;&amp;{M:GcTivo.TIVO - 2}</cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>VC.Pause</cmdType>
    <cmdString>200</cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>Tcp.Client.WriteLn</cmdType>
    <cmdString>iTach&amp;&amp;{M:GcTivo.TIVO - 2}</cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>VC.Pause</cmdType>
    <cmdString>200</cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>Tcp.Client.WriteLn</cmdType>
    <cmdString>iTach&amp;&amp;{M:GcTivo.TIVO - ENTER/LAST}</cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>VC.Pause</cmdType>
    <cmdString>200</cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>TCP.Client.Disconnect</cmdType>
    <cmdString>iTach</cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <phrase>Tivo Change Channel to C N N</phrase>
</command>

Just saw your next post. I'll try that now.

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Return Multiple Values from single phrase in Payload?
« Reply #11 on: October 14, 2013, 08:00:11 PM »
Hi Jason.

This command works.  So I recommend that you

- check that you don't already have a tcp.client.connect command that is interfering, and check your port and Ip in the tcp.client.connect parameters.

If it doesn't work then:

- Post your command xml (copy paste from the tree to the forum in a code box)
- Post your payload XML file with your channel names and numbers
- Attach a voxLog.txt


JasonFox

  • $upporter
  • Jr. Member
  • *****
  • Posts: 27
  • Karma: 4
    • View Profile
Re: Return Multiple Values from single phrase in Payload?
« Reply #12 on: October 14, 2013, 08:18:04 PM »
Thanks James. I'm guessing the problem is something I have done wrong with the payload as the only error I get now is "no matches found" in the reg.ex command.  The TTS fires as the final 'enter' iTach command, but the #'s don't. Copies of command and xml to follow.

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<command id="733" name="Tivo channel {1}" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="1">
  <action>
    <cmdType>TTS.Speak</cmdType>
    <cmdString>Switching to channel: {PF.1}</cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>Tcp.Client.Connect</cmdType>
    <cmdString>iTach&amp;&amp;192.168.1.102&amp;&amp;4998</cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>Results.RegEx</cmdType>
    <cmdString>(\d)&amp;&amp;&amp;&amp;{1}</cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>Tcp.Client.WriteLn</cmdType>
    <cmdString>iTach&amp;&amp;{M:GcTivo.TIVO - {Match.{i}}}&amp;&amp;200</cmdString>
    <cmdRepeat>{#M}</cmdRepeat>
  </action>
  <action>
    <cmdType>Tcp.Client.WriteLn</cmdType>
    <cmdString>iTach&amp;&amp;{M:GcTivo.TIVO - ENTER/LAST}</cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>TCP.Client.Disconnect</cmdType>
    <cmdString>iTach</cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <phrase>Tivo Change Channel to</phrase>
  <payloadFromXML phraseOnly="False" use2partPhrase="False" phraseConnector="by" Phrase2wildcard="anyone" optional="False">payloads\CableChannels.xml</payloadFromXML>
</command>


« Last Edit: December 07, 2014, 08:12:25 AM by jitterjames »

Kalle

  • $upporter
  • Hero Member
  • *****
  • Posts: 2320
  • Karma: 47
    • View Profile
Re: Return Multiple Values from single phrase in Payload?
« Reply #13 on: October 14, 2013, 08:26:02 PM »
Jason, please check your iTach IP again - in the commands above you use different IP's 192.168.0.102 and also 192.168.1.102
***********  get excited and make things  **********

JasonFox

  • $upporter
  • Jr. Member
  • *****
  • Posts: 27
  • Karma: 4
    • View Profile
Re: Return Multiple Values from single phrase in Payload?
« Reply #14 on: October 14, 2013, 08:33:16 PM »
Yes. I found that after I retried the commands as Client.WriteLn in the other command.  I believe the problem must be something I did wrong in the payload? Executing the command now doesn't give the unable to connect error that happened before it only gives the "no matches found" error.

I just realized I didn't include the voxlog.txt in my last post. I'm including it below.