News:

HOT TIP! Exploring the commands packaged in VC's standard configurations is a great way to learn how to build your own. You can also clone a command as a starting point: just right-click and select "Clone" (or type Alt-C).

Main Menu

Logic in Commands

Started by Tom_G_2010, December 24, 2020, 04:54:01 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Tom_G_2010

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

#1
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
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

Example voice command using payload XML value-phrase file:

<?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

Thanks!!!

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

nime5ter

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

Thanks for the info!  I now have it working using a payload XML list!

nime5ter

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

Some steps have a way to do it. Try searching for a clip.