Automatically translate this page?

How to calculate total mileage and other aggregate metrics with calculators?

Aggregating counter values by period.

Say, you have a calculator that detects trips and has a counter that calculates mileage for each trip. The next thing you often want to do is calculate daily_mileage to know how much time you were driving since the beginning of each day, total_mileage for larger periods, etc.

We have an “accumulator” type counter for that purpose. This counter can accumulate value between intervals and store accumulated resulting value in each interval.

We created two “accumulator” counters in our “route” calculator:

  • total_mileage: configured as name=total_mileage, counter=mileage.

  • daily_mileage: configured as name=daily_mileage, counter=mileage, reset_interval=day.

add accumulator type counters to calculator

And in the device Toolbox tab we get pretty intervals where each trip contains information about total mileage and daily mileage as a parameter:

check aggregate measures in toolbox


See also
Resources you should monitor to stay in sync with all changes introduced to the flespi platform infrastructure.
Resolving the MQTT connectivity issues faster by analyzing raw MQTT traffic.