Just trying to get my head around Flespi Calculators with its selectors and counters for our FMB003 devices.

I started from the "Trip detector" template and would like some advice on how to adopt the following:

Whenever a trip is detected, based on things like
movement.status
engine.ignition.status
can.vehicle.speed and/or position.speed>0
segment.vehicle.mileage

it should store the following to identify the vehicle:
ident
vehicle.vin

values from the beginning and end of the trip"
timestamp
position.latitude
position.longtitude
position.altitude

calculated values, trip end value minus values at the start of the trip:
can.vehicle.mileage (in km)
can.fuel.level (percentage)
can.fuel.volume (liters)

The step after would be to consolidate this on a weekly, monthly and yearly basis.

    JamesJapp this should be quite easy to achieve with calculators.

    First you configure selectors, you may use expressions for that, for example: "$movement.status || $engine.ignition.status || max($can.vehicle.speed, $position.speed) > 0 || $segment.vehicle.mileage"

    Then you configure counters to add required information to the interval.

    And finally you create additional calculators for combined weekly, monthly and yearly stats.

      shal thanks! I managed to get most of it to work. I would like some more info on the different types of counters. At the moment I just used "Expression" to get e.g. the fuel volume at the beginning end end of the trip.

      Something I haven't figured out yet is how to detect a re-fueling event. In my example the vehicle started with a low fuel level, during the trip the vehicel was refueled and the trip just continued. I was unable to figure out how much fuel was added, what the position lon/lat was and the odometer reading when re-fueling.

        A simple re-fuel calculator example based on the can.fuel.volume parameter:

        {
          "intervals_ttl": 31536000,
          "update_delay": 1,
          "update_period": 86400,
          "messages_source": {
            "source": "device"
          },
          "validate_message": "can.fuel.volume",
          "validate_interval": "fuel.delta>3",
          "name": "Refuel",
          "selectors": [
            {
              "expression": "#can.fuel.volume<can.fuel.volume",
              "max_inactive": 90,
              "max_messages_time_diff": 1800,
              "merge_message_before": true,
              "method": "boolean",
              "min_duration": 30,
              "name": "fuel increased",
              "type": "expression"
            }
          ],
          "intervals_rotate": 0,
          "counters": [
            {
              "method": "first",
              "name": "fuel.before",
              "parameter": "can.fuel.volume",
              "type": "parameter"
            },
            {
              "method": "last",
              "name": "fuel.after",
              "parameter": "can.fuel.volume",
              "type": "parameter"
            },
            {
              "expression": "fuel.after-fuel.before",
              "name": "fuel.delta",
              "type": "interval"
            },
            {
              "method": "first",
              "name": "position.latitude",
              "type": "parameter"
            },
            {
              "method": "first",
              "name": "position.longitude",
              "type": "parameter"
            },
            {
              "method": "first",
              "name": "can.vehicle.mileage",
              "type": "parameter"
            }
          ],
          "timezone": "UTC"
        }

        5 days later
        • Edited



        Looks good , but must play around with calc param to remove false fllings.

        6 days later

        ysv That look pretty good. What did you use to visualize the refueling events like that?

        Is there an easy way to push these journey refuel data to an app database e.g. Firebase?

        Apologies if I am asking silly question, I am at the beginning of an exciting learning curve 😀

          Write a Reply...