Author Topic: Logic in Commands  (Read 3551 times)

0 Members and 1 Guest are viewing this topic.

Tom_G_2010

  • Jr. Member
  • **
  • Posts: 12
  • Karma: 2
    • View Profile
Logic in Commands
« on: December 24, 2020, 04:54:01 PM »
So, I've had success creating some basic commands to turn lights on and off and to set their dimmer levels.

What I haven't been successful at is searching the wiki docs and youtube tutorials...  I'm on the hunt for some examples of using logic.

Here's what I want to accomplish:

If {1} = red then set {2} to 100

elseIf {1} = green then set {2} to 50

elseIf {1} = blue then set {2} to 25

else set {2} to 10

and I'll use {2} to issue a hue change for an RGBW light

Is this possible and if so how or where might I find some documentation or a video tutorial?

Thanks!
Tom G>

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 1999
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: Logic in Commands
« Reply #1 on: December 25, 2020, 09:07:54 AM »
Rather than an else-if, you could do consecutive logic blocks with the stop.macro action:
https://voxcommando.com/forum/index.php?topic=2910.msg24634#msg24634

That said, it's possible that using a value-phrase payloadXML table may be a better approach but I'm not quite clear on how the command is being executed.

For example, if you're issuing a voice command to say "Turn the lights {red,green,blue,white,purple}", then in the payload XML file you'd have payload phrase {colour} --> payload value {x}.

In this case there would be no need for a logic block at all, but each colour would need to be defined, along the lines of:
red --> 100
green --> 50
blue --> 25
white --> 10
purple --> 10
« Last Edit: December 25, 2020, 09:10:26 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: 1999
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: Logic in Commands
« Reply #2 on: December 25, 2020, 09:22:27 AM »
Example voice command using payload XML value-phrase file:

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.3.0.4-->
<command id="281" name="Turn the lights {1}" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="Replace actions with the ones you need.">
  <action>
    <cmdType>OSD.ShowText</cmdType>
    <params>
      <param>Turn the lights {PF.1}:</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>OSD.AddText</cmdType>
    <params>
      <param>Sending value {1}</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <phrase>Turn the lights</phrase>
  <payloadFromXML phraseOnly="False" use2partPhrase="False" phraseConnector="by" Phrase2wildcard="anyone" optional="False">payloads\rgb_lights.xml</payloadFromXML>
</command>

The payloadXML file is attached separately to this post (see paperclip icon below). You'll note in the command tree that the payloadxml rgb_lights.xml is stored in VC's payloads folder.
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)

Tom_G_2010

  • Jr. Member
  • **
  • Posts: 12
  • Karma: 2
    • View Profile
Re: Logic in Commands
« Reply #3 on: December 25, 2020, 01:38:32 PM »
Thanks!!!

I'll dig into this after the festivities wind down.  Any sooner and the WAF will plummet into negative numbers .

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 1999
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: Logic in Commands
« Reply #4 on: December 25, 2020, 02:06:51 PM »
As a wife myself, I approve of your priorities.

In case it hasn't come up for you yet, to use command xml from the forum, just select the command text in the post, copy, and paste it into the command tree editor window.
https://voxcommando.com/mediawiki/index.php?title=XML_on_the_forum



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)

Tom_G_2010

  • Jr. Member
  • **
  • Posts: 12
  • Karma: 2
    • View Profile
Re: Logic in Commands
« Reply #5 on: December 26, 2020, 03:20:02 PM »
Thanks for the info!  I now have it working using a payload XML list!

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 1999
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: Logic in Commands
« Reply #6 on: December 26, 2020, 04:01:40 PM »
Glad that worked out for you. Enjoy!
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)

wdb2021

  • Guest
Re: Logic in Commands
« Reply #7 on: May 07, 2021, 01:23:23 AM »
Some steps have a way to do it. Try searching for a clip.