Let’s assume your device is reporting absolute “counter” that correspond to water consumption. However, you would like to visualize not the “absolute” but “delta” values, e.g. how many water was consumer within last day, week, month.
In this tutorial we will calculate “delta” of the counter readings based on current and previous reading.
Assuming that previous reported value of counter was 90, we will transform incoming telemetry:
{
"counter": 100
}
to
{
"counter": 100,
"delta": 10
}
We assume you have completed the following guides and reviewed the articles listed below:
We will modify default rule chain and will an enrichment rule node to fetch previous telemetry value from the database and put it to the message metadata.
We will use the following node configuration:
Please note that if the “counter” value is missing, the rule node will return failure. We will protect from this failure by setting the default previous counter on the next step.
This transformation node will set the default counter to the metadata from the incoming message. This will be used to set default “delta” value to 0 on the next step.
This transformation node will calculate delta based on previous counter value from the metadata and current value from the message.
We have added simple card widget to show the latest values generated by the rule chain
Download and import attached json file with a rule chain from this tutorial. Don’t forget to mark new rule chain as “root”.
Download and import attached json file with a dashboard from this tutorial.
Getting started guides - These guides provide quick overview of main ThingsBoard features. Designed to be completed in 15-30 minutes.
Installation guides - Learn how to setup ThingsBoard on various available operating systems.
Connect your device - Learn how to connect devices based on your connectivity technology or solution.
Data visualization - These guides contain instructions how to configure complex ThingsBoard dashboards.
IoT Data analytics - Learn how to use rule engine to perform basic analytics tasks.
Hardware samples - Learn how to connect various hardware platforms to ThingsBoard.
Advanced features - Learn about advanced ThingsBoard features.
Contribution and Development - Learn about contribution and development in ThingsBoard.