I would like to suggest having two position attributes called device_status and status_duration.
There are three different statuses: Idle, moving, and stopped. The status_duration is in seconds
Idle: accumulates the status_duration when the device's ignition is on and motion is false.
resets if it detects motion or ignition off.
Moving: status_duration accumulates when it detects motion and resets if motion is false.
Stopped: status_duration will accumulate until the ignition is on or motion is true.
Consider if the device went offline while moving when it's back online.
I would like to suggest having two position attributes called device_status and status_duration. There are three different statuses: Idle, moving, and stopped. The status_duration is in seconds
Consider if the device went offline while moving when it's back online.