In this section you will learn the next steps towards automation.
You will create a rule which triggers changes the led color depending on the settings of the switch feature.
Create a second demo device and group both with a Tag
Provision the deviceSet the rule trigger based on the DeviceOnlineEvent
Use the demo device Vorto model and make sure the name is for the new device unique.
Create the tag
Group the two demo devices with the tag
Assign the devices to the tag. One by one.
Activate the checkbox of the tag to check the correct filtering.
Result should be as shown in the screenshot.
Create a rule which will be applied to all devices grouped with the tag
Starting at the Bosch IoT Suite Console click the Rules entry in the left navigation.
Click the plus icon in the upper right corner of the list to get the "Create rule wizard".
Deviating for the task, you can edit a rule settings, triggers and actions multiple times.
Set the Settings
In this example, want to apply the rule only on devices which implement the led feature.
Enter a Name for the rule.
In section Scope > Tags choose the demo-device tag for filtering the scope to demo devices only.
In section Execution options make sure that Once per device is deselected to allow rule execution multiple times per device.
Continue with Next.
Set the Rule trigger to be based on a FeatureEvent
The next step is to set the appropriate trigger to the rule.
In this example we will use an event type trigger based on an Eclipse Vorto model:
Add a new trigger via the plus icon.
Choose the trigger type. Select Event Based.
Open event type selection dialog by clicking the Select from event browser icon.
Search for event type. For this example search for FeaturesEvents/com.bosch.iot.suite.example:Switch:1.0.0.
Select the event type row - FeaturesEvents/com.bosch.iot.suite.example:Switch:1.0.0/PropertyChanged/Status/on.
Continue with Next.
Set the Action
def isOn = event.value
def color = isOn ?
Save the Rule
Click Finish, to save your new rule.
Click Enable rule, to enable the rule immediately.
In case your device is disconnected, you can connect it now, and see if the rule is triggered.
Hint: If you increase the sensor update rate of your demo device connection, then you can focus more on the triggered rule executions caused by changing the switch.
Play with the switch and depending on the state "on" or "off" the LED color should change respectively.
Once the rule is enabled the play icon within the circle changes into a stop icon, allowing to disable the rule.
The wrench icon holds a menu of further actions to pause or re-run your rule.
Your first rule gives an example how you could automate your device management based on values reported by the device itself.
The digital twin layer (Bosch IoT Things) creates a change event for all changes it receives from the connectivity layer (Bosch IoT Hub) and forwards them to the device management layer (Bosch IoT Manager).
The device management layer makes use of the pre-defined "operation" of a feature (in our case LED provides setColor) and sends a message to the device.
The device tries to execute and reports again all changes to the cloud services.