Author Topic: Broadcaster SetVar  (Read 1433 times)

0 Members and 1 Guest are viewing this topic.

dwvaughn

  • Jr. Member
  • **
  • Posts: 16
  • Karma: 0
    • View Profile
Broadcaster SetVar
« on: January 07, 2014, 02:24:33 AM »
So spinning off from my other topic about changing zones and sending the TTS to each zone specific, I've been trying to figure out how to use Variables in VC and EventGhost.

So EventGhost can receive serial commands (which I will send from my home automation system).  when a certain serial command is received (i.e. KristiIsHome) then I want to trigger EventGhost to set the variable KristiIsHome to True or 1 or whatever in VC. 

So I used the EventGhost broadcaster plugin and under event I typed Results.SetVar:KristiIsHome and under paryload I typed True.  For whatever reason this isn't setting the variable KristiIsHome in VC.  I tested using OSD.ShowText{Var.KristiIsHome}.  Any thoughts?

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Broadcaster SetVar
« Reply #1 on: January 07, 2014, 05:38:30 AM »
Please post the code you are using.

dwvaughn

  • Jr. Member
  • **
  • Posts: 16
  • Karma: 0
    • View Profile
Re: Broadcaster SetVar
« Reply #2 on: January 07, 2014, 01:39:36 PM »
James,

Here is what I was using for testing.

Code: [Select]
-<commandGroup description="" requiredProcess="" priority="0" prefix="" enabled="True" name="TEST TTS" open="True">


-<command description="" enabled="true" name="Get Audio Device List" loopMax="0" loopDelay="0" loop="False" requiredConfidence="0" confirm="False" alwaysOn="False" id="1305">


-<action>

<cmdType>AudioEndpoint.GetList</cmdType>

<cmdString>,</cmdString>

<cmdRepeat>1</cmdRepeat>

</action>


-<action>

<cmdType>File.Write</cmdType>

<cmdString>C:\Users\David\Desktop\Audio Device List.txt&&{LastResult}</cmdString>

<cmdRepeat>1</cmdRepeat>

</action>

</command>


-<command description="" enabled="true" name="Test TTS" loopMax="0" loopDelay="0" loop="False" requiredConfidence="0" confirm="False" alwaysOn="False" id="1302">


-<action>

<cmdType>AudioEndpoint.SetByNum</cmdType>

<cmdString>4</cmdString>

<cmdRepeat>1</cmdRepeat>

</action>


-<action>

<cmdType>TTS.Speak</cmdType>

<cmdString>This channel is working. I want to write a long sentence to see what happens</cmdString>

<cmdRepeat>1</cmdRepeat>

</action>


-<action>

<cmdType>AudioEndpoint.SetByNum</cmdType>

<cmdString>12</cmdString>

<cmdRepeat>1</cmdRepeat>

</action>

</command>


-<command description="" enabled="true" name="SetVar" loopMax="0" loopDelay="0" loop="False" requiredConfidence="0" confirm="False" alwaysOn="False" id="1316">


-<action>

<cmdType>Results.SetVar</cmdType>

<cmdString>KristiIsHome&&Yes</cmdString>

<cmdRepeat>1</cmdRepeat>

</action>

</command>


-<command description="" enabled="true" name="showVar" loopMax="0" loopDelay="0" loop="False" requiredConfidence="0" confirm="False" alwaysOn="False" id="1323">


-<action>

<cmdType>OSD.ShowText</cmdType>

<cmdString>{Var.KristiIsHome}&&10000</cmdString>

<cmdRepeat>1</cmdRepeat>

</action>

</command>

</commandGroup>

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Broadcaster SetVar
« Reply #3 on: January 07, 2014, 03:25:51 PM »
I'm not sure how you generated that code, but it is not valid xml.  You can copy code directly from your command tree.  see here: http://voxcommando.com/mediawiki/index.php?title=XML_on_the_forum

Actually I wanted to know what code you were using in EventGhost.  You can do the same thing.  Right click your macro in EventGhost and choose copy.  Then paste it into a code box on the forum.

I think the problem might be the port that you are sending to.  By default VC listens to udp commands on port 33000 so your EventGhost macro must use this port.

from VC to EventGhost uses UDP port 33333
from EventGhost to VC uses UDP port 33000

You can verify these values on the VC Options page on the advanced tab.

This is different from TCP where a single port can be used in both directions.

So for example, let's say I want to set my variable 'thingy' to a value of 1:
Here is the macro to use in EventGhost (you can copy and paste this to your EventGhost tree):
Code: [Select]
<?xml version="1.0" encoding="UTF-8" ?>
<EventGhost Version="1572">
    <Macro Name="Broadcaster: Broadcast: Results.SetVar" Expanded="True">
        <Action>
            BroadcastListener.Broadcast(u'Results.SetVar', u'thingy&amp;&amp;1', 33000)
        </Action>
    </Macro>
</EventGhost>

and to test this variable in VC we can use this command  (you can copy and paste this to your VoxCommando tree):
Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<command id="246" name="show thingy" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
  <action>
    <cmdType>OSD.ShowText</cmdType>
    <cmdString>{Var.thingy}</cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <phrase>show thingy</phrase>
</command>

It is probably sufficient to just use the variables, but if you want to remember values even after VC is closed and restarted you can either store them in a text file, or use Maps (which I consider the preferred method).

dwvaughn

  • Jr. Member
  • **
  • Posts: 16
  • Karma: 0
    • View Profile
Re: Broadcaster SetVar
« Reply #4 on: January 07, 2014, 05:11:17 PM »
Thanks I got it working.  Sorry about the code paste issue, I copied it straight from I.E. after I double clicked on the voicecommands.xml file that's why it looked all messed up.  Your way is much easier.