This guide assumes familiarity with:
Command
Node (Sending a Device Command)Attribute
Node (Create a Bixby Response Using a Device Status)In this guide, you'll learn how to:
Equal Comparison
NodeExample: "Set the brightness of the bulb to 25."
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 bulb is off and the user gives the command to Bixby?
In this scenario, an intelligent action from Bixby would be to turn on the bulb and then set the brightness to the user's desired value.
This guide helps you to incorporate this type of intelligent behavior into your device.
Equal Comparison
NodeTo 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 bulb 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
NodeDrag an 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 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 or not they're equal to each other.
In this example, the Equal Comparison
Node compares the bulb's power status with the value "on."
To configure the Equal Comparison
Node:
equalTo
in the operator drop-down 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 is not yet attached to the false trigger port.
Now, you must define the action flow if the bulb is off. In this case, after the first command is sent (and the bulb turns on), the second command is sent to set the brightness. 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:
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 bulb triggers the original Command
Node to set the brightness.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 brightness.
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 brightness.
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.