This guide assumes familiarity with the following information:
CommandNode (Sending a Device Command)
AttributeNode (Create a Bixby Response Using a Device Status)
In this guide, you'll learn how to do the following:
Example: "Set the volume of the television to 25."
The device used in this guide is a SmartThings-enabled television.
This is the simplest action flow for this voice intent:
However, this action flow only works if the device is already on, such as in the Sending a Device Command With an Argument guide. What happens if the television is off and the user gives the command to Bixby? An intelligent action would be to turn on the television and then set the volume to the user's desired value. This guide helps you to incorporate this type of smart behavior into your device.
To start, you'll need to fetch the device's power status. To do this, add the
Attribute Node and configure it to get the power status of the device.
Next, you need to create logic to check the power status and turn the television on if it is off. You need a node that triggers a specific execution path out of multiple options based on a condition.
To create this logic, use an
Equal Comparison Node.
Equal Comparison Node from the action flow sidebar to the editor area.
This node takes the value of the
Attribute Node and uses the selected operator (in this example,
equalTo) to compare the
Attribute Node value with the value of a
The value output ports of the
Constant Nodes connect to the
rightValue input ports of the
Equal Comparison Node, respectively. The
Equal Comparison Node then compares the values of the
Constant Nodes to determine whether or not they're equal to each other.
In this example, the
Equal Comparison Node compares the television's power status with the value "on."
Equal Comparison Node:
equalToin the operator list.
Equal Comparison Node fetches and compares the values from the
Constant Nodes. If both values are the same (in this example, the device is set to
Command Node gets triggered. Otherwise, the
Equal Comparison Node doesn't trigger a node because one is not yet attached to the false trigger port.
Now, you must define the action flow if the television is off. In this case, after the first command is sent (and the television turns on), the second command is sent to set the volume. If the first command fails, the second command does not execute. These concatenated actions demonstrate the flexibility of the action flows.
To achieve this concatenated flow, do the following:
Equal ComparisonNode's false trigger port with an execution path.
CommandNode's trigger port. This ensures that a successful command to turn on the television triggers the original
CommandNode to set the volume.
To test the action flow, click the Try It button at the top right of the editor window. The flow editor should look like this:
If the device is already on:
As the device is already in the
on state, the execution path (denoted by the dashed green line) only sends the command to set the volume.
If the device is off:
The action flow first executes a command to turn on the device. Then, it executes a command to set the volume.
You can also make more complex graphs by using subgraphs.
For an additional example, see the "Set a Cooling Setpoint With or Without Temperature Unit" Sample Graph.