This guide assumes familiarity with the following information:
Command
node (Sending a Device Command)Attribute
node (Creating a Bixby Response Using a Device Status)In this guide, you'll learn how to do the following:
Equal Comparison
nodeExample: "Set the volume of the television to 25."
The device used in this guide is a SmartThings-enabled TV.
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 an 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 then 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.
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 Constant
node.
The value output ports of the Attribute
and Constant
nodes connect to the leftValue
and rightValue
input ports of the Equal Comparison
node, respectively. The Equal Comparison
node then compares the values of the Attribute
and Constant
nodes to determine whether they're equal to each other. In this example, the Equal Comparison
node compares the television's power status with the value "on."
Configure the Equal Comparison
node:
equalTo
in the operator list.
The Equal Comparison
node fetches and compares the values from the Attribute
and Constant
nodes. If both values are the same (in this example, the device is set to on
), the Command
node gets triggered. Otherwise, the Equal Comparison
node doesn't trigger a node because one isn't attached yet to the false trigger port.
Now, you must define the action flow if the TV is off. In this case, after the first command is sent (and the TV 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 action flows. To achieve this concatenated flow, do the following:
Command
node.Equal Comparison
node's false trigger port with an execution path.Command
node's trigger port. This ensures that a successful command to turn on the device triggers the original Command
node 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, meaning it is 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.
The Node Recommendation feature enables you to get recommendations for next possible nodes, and can make it easier to create a graph.
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.