Trigger Example: Tags for Dashboard Display
A dashboard is needed that displays all vehicles and is able to display all vehicles, vehicles low on fuel (half a tank or less), and vehicles with enough fuel (three quarters of a tank or more).
To solve this requirement, a dashboard is defined with navigation buttons to show other dashboards based on alarm states. A tag is added to a thing or deleted from a thing, based on an alarm states.
The thing's thing definition has an alarm for the fuel tank level: fuellevel
The fuellevel alarm states are:
-
0 = Low
-
1 = one quarter full
-
2 = half full
-
3 = three quarters full
-
4 = Full
-
$(event.thing.key) - The key of the thing that initiated the cloud trigger.
-
$(action.X.value) - The result value for action block X.
The current timestamp, state, message, duration, latitude, and longitude for the fuellevel alarm for the thing that caused the event are action variables to be used in later actions in the cloud trigger:
-
$(action.0.ts)
-
$(action.0.state)
-
$(action.0.msg)
-
$(action.0.duration)
-
$(action.0.lat)
-
$(action.0.lng)
A math.if action compares the previous alarm state, stored in $(action.0.state) with a value of 2 to see if the alarm state is lesser then or equal (0 = Low, 1 = 1/4, 2 = 1/2). If the alarm state is less than or equal to 2 then the true routing path is followed. If the alarm state is Not less than or equal to 2 then it will follow the false routing path.
The first dashboard is created (Vehicle Telematics – All Vehicles) with an unfiltered Thing List widget.
This dashboard is then cloned into two child dashboards and navigation buttons are added to link the dashboards together:
-
Vehicle Telematics – Good on Fuel: with a thing List filtered by tag fuel-good
-
Vehicle Telematics – Low Fuel: with a thing List filtered by tag low-fuel
In the Vehicle Telematics – Good on Fuel dashboard in the image, the Thing List widget is configured to only show things with the vehicle tag and the fuel-good tag.
Following this pattern the Vehicle Telematics – Low Fuel dashboard’s Thing List widget is configure to only show Things with the vehicle tag and the low-fuel tag.
The Navigation buttons in the dashboards link the dashboards together as shown in the image in the Vehicle Telematics – All Vehicles dashboard. This dashboard has:
-
A green navigation button configured to link to the Vehicle Telematics – Good on Fuel dashboard
-
A red navigation button configured to link to the Vehicle Telematics – Low Fuel dashboard.