Mapping Freematics PID Data with Computed Attributes

Kevin Vinck4 years ago

Hi,

I'm trying to map the PID data that my Freematics adapter sends back to values using computed attributes. However the problem I'm running into is that the attributes both in the UI and the JSON start with numbers which JEXL doesn't support so I get a parse error. I've also tried prefixing the PIDs with "io", "i", and "in" since I wasn't sure if those get remapped internally, but haven't had any luck.

These are the attributes reportedly available:

    "attributes": {
        "12": "179",
        "104": "25",
        "111": "3",
        "10D": "0",
        "10C": "862",
        "battery": 15.610000000000001,
        "acceleration": "-0.06;-0.05;-0.03",
        "deviceTemp": 36.4,
        "sat": 9,
        "distance": 0.33,
        "totalDistance": 33.72,
        "motion": true
      }

How do I go about accessing the ones that start with numbers in computed attributes? For example, 10D should be mapped to OBD Speed, and 10C to RPM.

Anton Tananaev4 years ago

If JEXL doesn't support it, you would need to change the server code to prefix attributes with something.

Kevin Vinck4 years ago

Ok, thanks. I modified it to accept the PIDs in the default Freematics code and handle everything else with a prefix.

My modifications are here: https://github.com/KalenXI/traccar/commit/d0ac9e99c279b7cef02cae7ac418e0f6e9390bce

If you're interested I can submit a pull request for it.

Anton Tananaev4 years ago

Feel free to send a PR.