Cloud trigger: Tags for
dashboarding
Use Case
A dashboard is needed that displays all vehicles and is able to display:
- All vehicles
- Vehicles low on fuel (1/2 fuel tank level and lower)
- Vehicles at a good fuel level (3/4 fuel tank level and higher).
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's states.
Thing Definition
The thing's thing definition has an alarm for the fuel tank level: fuellevel
The fulelevel alarm states are:
- 0 = Low
- 1 = 1/4 full
- 2 = 1/2 full
- 3 = 3/4 full
- 4 = Full
Event Variables
- $(event.thing.key) - The key of the thing that
initiated the cloud trigger.
Action Variables
- $(action.X.value) - The result value for action
block X.
Property.change cloud trigger event
A cloud trigger is executed when an alarm state change
occurs for the fuellevel alarm for all things that
have this thing definition and have the fuel-good,
low-fuel, proxy, telit or
vehicle thing tags.
Alarm.current action
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)
Math.if action
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.
Note: The $(action.X.value) action variable references
the action block numbered X. In this case we are using 0,
as it is the action number from the previous alarm.current
action.
True routing path
The true routing path (circled in green in the image)
will add the low-fuel tag to the thing the event occurred
on, using the $(event.thing.key), and delete the fuel-good
tag from the thing the event occurred on, using the
$(event.thing.key.
False routing path
The false routing path (circled in red in the image)
will add the fuel-good tag to the thing the event occurred
on, using the $(event.thing.key), and delete the low-fuel
tag from the thing the event occurred on, using the
$(event.thing.key).
Dashboard one
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
Thing List Widget – Filter by tags
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 Vehicle Telematics – All Vehicles dashboard’s
Thing List widget is configured to only show Things
with the vehicle tag but does not filter by
the fuel level tags.
Navigation Button Widget
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.
This same method above is used to link the remaining
dashboards together using the Navigation buttons.