I have what I hope is a fairly easy question to answer. What is a trip? Is there a specific trigger to start/stop a trip? Will turning off the vehicle stop a trip and start a new one?
If you wanted to do so, can you manually add events that will start and stop trips? And how would you do that?
For my vehicle (Mazda 3 2019), there is usually no vehicle/engine/stopped event. So out-of-the-box, my Trip will never stop until I start the engine again, which will cause the trip data to be unusable anyway.
To workaround this issue, I wrote Custom Code to detect RPM=0 and fire Custom Event to stop my trip.
There’s also a Reopen Limit parameter (number of seconds).
This means if you stop the car, turn off engine & later turn it on within a short period (within 600s = 5 minutes in my case) the trip will be re-opened to continue. This is useful for scenarios like pumping petrol or buying something quick, or parked & re-parked within a couple of minutes.
Interesting and helpful information. Let me take that to the next level. I would like to manually generate event data that could be used to start/stop a trip. Think of a USB keyboard attached to the device. Lets forget the connectivity for a moment. How could I manually add an event from within the shell for something that is not sourced via OBD?
I’m actually generating custom event via shell command.
Initially I wrote Custom Code module inside AutoPi platform, but it’s pretty limited.
So I installed full Node-RED on to my dongle and do many more complex customizations with it.
For your application, you can use a simple shell script as a system service that listens to specific keyboard codes & fire custom events to start/stop trip.
Custom events can be generate via a few different way:
from Python code (Custom Code): __salt__["event.fire"]({"any_name":"some_value", "another_one":1234}, "vehicle/some_event_name")
from web terminal: event.fire "{\"any_name\":\"some_value\", \"another_one\":1234}" "vehicle/some_event_name”'