Segments (Trips)

Segments and Trips API

Segments help us get summarized data about a collection of events over a span of time grouped in a convenient and natural way, each segment can be thought of a partition of data in a timeline.

One of the way Pegasus summarizes data is using trips, trips are segments of data that have start and end times based on conditions such as time, ignition, distance, etc. Trip data includes totals, max, and averages of information captured during that particular time range, for example the total distance driven, max speed, etc. An entity can have at most 1 trip definition.

Another way Pegasus can group data is using segments, segments are yet another way to use conditions based on the status of the ignition or input to start and end segments, unlike trips you can define multiple definitions of segments to partition the data.

Segments are configured using the /remote/segment_setup API

POST /api/vehicle/:vid/remote/segment_setup

{
    "segment_type": "trips|hos", //trips or hos
    ...
}

A device can have exactly one segment of each segment_type.


Trips Configure

In order to configure the trips segments we can specify

Body attributesValueDescription
segment_typetripssegment types to configure
methodtracker or gps or ignition or labelsthe method for splitting up trips
mode0, 1, or 2these methods are valid for syrus 3 and taurus devices, not syrus 4
partition0 - 9999duration in seconds to finish a trip. available for syrus 3 and taurus devices
distance1 - 999distance in meters to start a new trip
labelsts;te;ddlabels or events that must be met to start, end, or toggle trips

Method "tracker" (device)

Trips are calculated by the device and messages are sent in a separate streams to the gps events.
The tracker method is only supported for Syrus 3 and Taurus devices

Tracker method requires mode, partition, and distance

mode can be:

  • 0: use the motion sensor
  • 1: ignition and motion
  • 2: ignition only

partition: how long (seconds) the mode condition must be met before finishing a trip, default is 210 seconds.
distance: how far of a distance (meters) to consider before starting a trip, default is 50 meters.

POST /api/vehicle/:vid/remote/segment_setup

{
    "segment_type": "trips",
    "method": "tracker",
    "mode": 0|1|2,
    "partition": 0-9999,
    "distance": 1-999
}
DeviceModeStartEnd
Taurus1Trips start when motion is detected by the phone's movement sensor and there's a distance traveled of more than 50 meters.Trips end when there's no motion detected and the phone is in the same location for more than 4.5 minutes or manually when the user clicks Stop trip on the app
Syrus30When motion is detected and the distance traveled is more than XXX metersTrip ends when there's no movement detected for more than YYY seconds
Syrus31Trips start when the ignition is ON, and movement is detected, and the distance traveled is more than XXX metersTrip ends when the ignition is OFF and no movement is detected for more than YYY seconds or if the ignition remains ON and the vehicle does not detect movement for more than YYY seconds
Syrus32Trips start when the ignition ON is detected and the distance traveled is more than XXX metersTrip ends when the ignition OFF is detected for more than YYY seconds

Method "gps"

Applies to Syrus and non-Syrus devices.

Internal logic used by Pegasus based on gps to establish whether the vehicle is moving or stopped.

POST /api/vehicles/:vid/remote/segment_setup

{
  "segment_type": "trips",
  "method": "gps"
}
DeviceMethodStartEnd
Applies to Syrus3, Syrus4 and non-Syrus devicesGPSTrips start when the average speed is greater than 3mphTrips end when the average speed is less than 3mph for more than 4 minutes

For more information on the logic used checkout the following forum.


Method "ignition"

Trips are started and ended based on the ignition state.
Falls back to GPS if the ignition state is not available.

POST /api/vehicles/:vid/remote/segment_setup

{
  "segment_type": "trips",
  "method": "ignition"
}
DeviceMethodStartEnd
Applies to Syrus3, Syrus4 and non-Syrus devicesignitionTrips start when the ignition ON is detectedTrips end when an ignition OFF is detected

Method "labels"

Trips are started and ended based specified labels, requires labels in the configuration payload
the format is composed of switches, switch=label, you can combine as many of these as you want with ;

allowed switches

  • dd: default switch
  • ts,te: trip start, trip end
  • ss,se: stop start, stop end

examples:

  • ts=ignon;te=ignoff will start and end a trip based on the ignition labels
  • ts=in1on;ts=in2on;ts=panic;te=ignoff will start a trip or a stop
  • dd=trpswtch end current trip and start new one
  • ts=ignon;te=idl;te=ignoff will start a trip with ignition on, and end with idle or ignition off label
  • ts=ignon;dd=in1on will start a trip with ignition on and switch with in1on label

if you do not provide a dd switch, you need to make sure that the start and end conditions are met.
i.e ts|ss require a te|se

POST /api/vehicles/:vid/remote/segment_setup

{
  "segment_type": "trips",
  "method": "labels",
  "labels": "switch1=label1[;switch2=label2[;switch3=...]]"
}
DeviceMethodStartEnd
Applies to Syrus and non-Syrus deviceslabelsTrips start when the ts label occurs, or there's a stop and the dd label occursTrips end when the te label occurs, or there's a trip and the dd label occurs, or the device is coming from a trip and the ss label occurs

Segments Configure

Hours of Service

Hours of Service segments are special segments that are built from a boolean signal that the vehicle reports.
The segments use the signal as a condition to start a segment of type working or resting.

In order to configure this type of segment, in the body we can specify:

Body attributesExampleDescription
segment_type"hos"hours of service will be the type of segment
signal"moving"Boolean signal that the vehicle reports. The signal moving will be in true once motion is detected. In this case, the vehicle will be in a working segment.
max_work_hours12 hMaximum hours that the entity must work. The entity is overworked if works more than max_work_hours.
min_rest_hours6 hMinimum hours that the entity must rest.
max_continuous_work_hours2hMaximum hours that the entity must work continuously. The system will trigger an alert if the entity works continually for more than this maximum.
min_break_hours0.25 hMinimum time required to start a break.
POST /api/vehicles/:vid/remote/segment_setup

{
  "segment_type": "hos",
  "signal": "moving",
  "max_work_hours": 8,
  "min_rest_hours": 4,
  "max_continuous_work_hours": 2,
  "min_break_hours": 0.25
}

signal can refer to any of the following values on the event

  • io_inX - Inputs
  • io_outX - Outputs
  • io_ign - Ignition state
  • io_pwr - Power state
  • ecu_speed - ECU speed only
  • moving - Moving state
    • Moving is true when the gps speed is > 3mph and there's valid_gps
    • Moving is false when the gps speed is < 3mph and there's valid_gps
    • If there's no valid_gps it falls back to the movement sensor
  • or any other field outside of the $basic.

🚧

Ignition reported as false

Note that if at some point the ignition state was reported as True, but then the device reports it as off/False, even while it's moving, in other words there's a physical issue with the ignition, then the segments will not be created correctly. It would be recommended to switch to another signal like ecu_speed or io_pwr, or fix the installation of the device.

πŸ“˜

HoS Segments

The signal moving will be in true once motion is detected and will transition into a working segment. If the vehicle stops moving, the signal transitions to false, at which point starts a resting_start that records the date on which the vehicle stops moving. While moving is false, the resting_start will be kept recording the date, so we can know how much time the vehicle is without motion. Once the rest time reaches min_rest_hours, a segment in resting will be created and the working segment is ended.

The behavior is similar if we use another type of signal, the working segment will be created when the signal goes true, and when the signal goes false and the entity remains in that state for at least min_rest_hours then a resting segment is created.

View Segment/Trips Configuration

In order to get the configuration of the trip and segments configured you can use the device package from the device API.

To access this data you can use the vehicles API, that show the current segment.
/vehicles/459?select=device:segments trip_setup

{
    "device": {
        "segments": {
            "setup": {
                "hos": {
                    "max_work_hours": 8,
                    "signal": "moving",
                    "min_rest_hours": 4,
                    "max_continuous_work_hours": 2,
                    "min_break_hours": 0.1
                }
            },
            "_epoch": 1698324803.59646,
            "entries": {
                "hos": {
                    "entity_id": 459,
                    "signal": "moving",
                    "end_event": null,
                    "start_time": 1698318344.0,
                    "max_continuous_work_hours": 2,
                    "min_break_hours": 0.1,
                    "max_work_hours": 8,
                    "resting_start": null,
                    "state": "working",
                    "end_time": null,
                    "device": 866771027161925,
                    "start_event": {
                        "lon": -74.03707,
                        "mph": 15.5,
                        "label": "aaa",
                        "count_dev_idle": 142665.0,
                        "lat": 4.81702,
                        "moving": true,
                        "count_dev_dist": 18725628.0,
                        "event_time__epoch": 1698318344.0,
                        "valid_gps": true,
                        "io_ign": true,
                        "count_dev_ign": 184544190.0
                    },
                    "min_rest_hours": 4,
                    "breaks": [
                        {
                            "start_event": {
                                "lon": -74.03706,
                                "mph": 0.0,
                                "label": "aaa",
                                "count_dev_idle": 142665.0,
                                "event_time__epoch": 1698318638.0,
                                "moving": false,
                                "count_dev_dist": 18725717.0,
                                "lat": 4.81712,
                                "valid_gps": true,
                                "io_ign": true,
                                "count_dev_ign": 184544481.0
                            },
                            "end_event": {
                                "lon": -74.03706,
                                "mph": 3.1,
                                "label": "aaa",
                                "count_dev_idle": 142784.0,
                                "event_time__epoch": 1698319845.0,
                                "moving": true,
                                "count_dev_dist": 18725832.0,
                                "lat": 4.81702,
                                "valid_gps": true,
                                "io_ign": true,
                                "count_dev_ign": 184545683.0
                            }
                        },
                        {
                            "start_event": {
                                "lon": -74.03706,
                                "mph": 0.0,
                                "label": "aaa",
                                "count_dev_idle": 142784.0,
                                "lat": 4.81699,
                                "moving": false,
                                "count_dev_dist": 18725852.0,
                                "event_time__epoch": 1698319896.0,
                                "valid_gps": true,
                                "io_ign": true,
                                "count_dev_ign": 184545735.0
                            },
                            "end_event": {
                                "lon": -74.03701,
                                "mph": 3.1,
                                "label": "aaa",
                                "count_dev_idle": 142784.0,
                                "event_time__epoch": 1698322559.0,
                                "moving": true,
                                "count_dev_dist": 18725882.0,
                                "lat": 4.8171,
                                "valid_gps": true,
                                "io_ign": true,
                                "count_dev_ign": 184548397.0
                            }
                        },
                        {
                            "start_event": {
                                "lon": -74.03731,
                                "mph": 0.6,
                                "label": "aaa",
                                "count_dev_idle": 142859.0,
                                "event_time__epoch": 1698323221.0,
                                "moving": false,
                                "count_dev_dist": 18726054.0,
                                "lat": 4.81722,
                                "valid_gps": true,
                                "io_ign": true,
                                "count_dev_ign": 184549059.0
                            },
                            "end_event": {
                                "lon": -74.03716,
                                "mph": 4.3,
                                "label": "aaa",
                                "count_dev_idle": 142902.0,
                                "lat": 4.817,
                                "moving": true,
                                "count_dev_dist": 18726545.0,
                                "event_time__epoch": 1698323750.0,
                                "valid_gps": true,
                                "io_ign": true,
                                "count_dev_ign": 184549589.0
                            }
                        },
                        {
                            "start_event": {
                                "lon": -74.03764,
                                "mph": 1.2,
                                "label": "aaa",
                                "count_dev_idle": 142902.0,
                                "lat": 4.81678,
                                "moving": false,
                                "count_dev_dist": 18726805.0,
                                "event_time__epoch": 1698323953.0,
                                "valid_gps": true,
                                "io_ign": true,
                                "count_dev_ign": 184549792.0
                            },
                            "end_event": {
                                "lon": -74.03772,
                                "mph": 3.1,
                                "label": "aaa",
                                "count_dev_idle": 142902.0,
                                "event_time__epoch": 1698324747.0,
                                "moving": true,
                                "count_dev_dist": 18727150.0,
                                "lat": 4.8168,
                                "valid_gps": true,
                                "io_ign": true,
                                "count_dev_ign": 184550586.0
                            }
                        }
                    ],
                    "resting_start_event": null
                }
            }
        },
        "imei": 866771027161925
    },
    "id": 459
}

or you can also use the devices API
/devices/866771027161925?select=segments,trip_setup

GET /api/devices/:imei?select=segments,trip_setup

{
    "count": 1,
    "set": 1,
    "total": 1,
    "data": [
        {
            "segments": {
                "setup": {
                    "hos": {
                        "max_work_hours": 8,
                        "signal": "moving",
                        "min_rest_hours": 4,
                        "max_continuous_work_hours": 2,
                        "min_break_hours": 0.1
                    }
                },
                "_epoch": 1698324910.690634,
                "entries": {
                    "hos": {
                        "entity_id": 459,
                        "signal": "moving",
                        "end_event": null,
                        "start_time": 1698318344.0,
                        "max_continuous_work_hours": 2,
                        "min_break_hours": 0.1,
                        "max_work_hours": 8,
                        "resting_start": null,
                        "state": "working",
                        "end_time": null,
                        "device": 866771027161925,
                        "start_event": {
                            "lon": -74.03707,
                            "mph": 15.5,
                            "label": "aaa",
                            "count_dev_idle": 142665.0,
                            "lat": 4.81702,
                            "moving": true,
                            "count_dev_dist": 18725628.0,
                            "event_time__epoch": 1698318344.0,
                            "valid_gps": true,
                            "io_ign": true,
                            "count_dev_ign": 184544190.0
                        },
                        "min_rest_hours": 4,
                        "breaks": [
                            {
                                "start_event": {
                                    "lon": -74.03706,
                                    "mph": 0.0,
                                    "label": "aaa",
                                    "count_dev_idle": 142665.0,
                                    "event_time__epoch": 1698318638.0,
                                    "moving": false,
                                    "count_dev_dist": 18725717.0,
                                    "lat": 4.81712,
                                    "valid_gps": true,
                                    "io_ign": true,
                                    "count_dev_ign": 184544481.0
                                },
                                "end_event": {
                                    "lon": -74.03706,
                                    "mph": 3.1,
                                    "label": "aaa",
                                    "count_dev_idle": 142784.0,
                                    "event_time__epoch": 1698319845.0,
                                    "moving": true,
                                    "count_dev_dist": 18725832.0,
                                    "lat": 4.81702,
                                    "valid_gps": true,
                                    "io_ign": true,
                                    "count_dev_ign": 184545683.0
                                }
                            },
                            {
                                "start_event": {
                                    "lon": -74.03706,
                                    "mph": 0.0,
                                    "label": "aaa",
                                    "count_dev_idle": 142784.0,
                                    "lat": 4.81699,
                                    "moving": false,
                                    "count_dev_dist": 18725852.0,
                                    "event_time__epoch": 1698319896.0,
                                    "valid_gps": true,
                                    "io_ign": true,
                                    "count_dev_ign": 184545735.0
                                },
                                "end_event": {
                                    "lon": -74.03701,
                                    "mph": 3.1,
                                    "label": "aaa",
                                    "count_dev_idle": 142784.0,
                                    "event_time__epoch": 1698322559.0,
                                    "moving": true,
                                    "count_dev_dist": 18725882.0,
                                    "lat": 4.8171,
                                    "valid_gps": true,
                                    "io_ign": true,
                                    "count_dev_ign": 184548397.0
                                }
                            },
                            {
                                "start_event": {
                                    "lon": -74.03731,
                                    "mph": 0.6,
                                    "label": "aaa",
                                    "count_dev_idle": 142859.0,
                                    "event_time__epoch": 1698323221.0,
                                    "moving": false,
                                    "count_dev_dist": 18726054.0,
                                    "lat": 4.81722,
                                    "valid_gps": true,
                                    "io_ign": true,
                                    "count_dev_ign": 184549059.0
                                },
                                "end_event": {
                                    "lon": -74.03716,
                                    "mph": 4.3,
                                    "label": "aaa",
                                    "count_dev_idle": 142902.0,
                                    "lat": 4.817,
                                    "moving": true,
                                    "count_dev_dist": 18726545.0,
                                    "event_time__epoch": 1698323750.0,
                                    "valid_gps": true,
                                    "io_ign": true,
                                    "count_dev_ign": 184549589.0
                                }
                            },
                            {
                                "start_event": {
                                    "lon": -74.03764,
                                    "mph": 1.2,
                                    "label": "aaa",
                                    "count_dev_idle": 142902.0,
                                    "lat": 4.81678,
                                    "moving": false,
                                    "count_dev_dist": 18726805.0,
                                    "event_time__epoch": 1698323953.0,
                                    "valid_gps": true,
                                    "io_ign": true,
                                    "count_dev_ign": 184549792.0
                                },
                                "end_event": {
                                    "lon": -74.03772,
                                    "mph": 3.1,
                                    "label": "aaa",
                                    "count_dev_idle": 142902.0,
                                    "event_time__epoch": 1698324747.0,
                                    "moving": true,
                                    "count_dev_dist": 18727150.0,
                                    "lat": 4.8168,
                                    "valid_gps": true,
                                    "io_ign": true,
                                    "count_dev_ign": 184550586.0
                                }
                            }
                        ],
                        "resting_start_event": null
                    }
                }
            },
            "imei": 866771027161925
        }
    ],
    "pages": 1,
    "page": 1
}

You can also get the data from live websockets via the device package.

Browse segments

Trips

These are the currently supported query params to get trips data:

ParamTypeDescription
idsNumberTrips of interest
fromStringTime from YYYY-MM-DD[Thh:mm:ss]
toStringTime to YYYY-MM-DD[Thh:mm:ss]
durationStringISO_8601 Duration format (PnYnMnDTnHnMnS, PnW, PT) (ex: P1D = Past 1 Day)
vehiclesNumberVehicles to get data from
fieldsStringWhich data fields do you want to include
containedBooleanWhether to return only fully contained trips within 'from' and 'to'
movingBooleanSet to true to view only trips that were moving
distanceStringunit to return distance values in (default: meters)
volumeStringunit to return volume values in (default: liters)
timeStringunit to return time values in (default: second)
speedStringunit to return speed values in (default: distance_unit/time_unit)
exportStringformat to export the trips data (csv or tsv)

🚧

Combining parameters

All requested conditions defined by the parameters are logically ANDed, so invalid conditions will return no trips (eg: requesting ids=12 and vehicles=34 but trip with id=12 belongs to vehicle with id=56).

Request the trips for a vehicle

/trips?vehicles=45&from=2023-12-25T10:05:00&to=2023-12-25T11:00:00&fields=distance,mean_speed,duration,moving,start_time&distance=km&time=minute&speed=kph

[
    {
        "distance": 13.405,
        "mean_speed": 43.28,
        "start_time": "2015-12-25 10:04:05",
        "moving": true,
        "duration": 18.58
    },
    {
        "distance": 0,
        "mean_speed": 0,
        "start_time": "2015-12-25 10:22:40",
        "moving": false,
        "duration": 5.87
    },
    {
        "distance": 25.33,
        "mean_speed": 36.49,
        "start_time": "2015-12-25 10:28:32",
        "moving": true,
        "duration": 41.65
    }
]

πŸ‘

Fields Description

You can view a description of the trips fields here /trips/keys

Note that you can also use data to retrieve only certain results from the trips keys

For example only retrieve units and type from the trips keys:

https://api.pegasusgateway.com/trips/keys?data=units,type

The available options for the data parameter are:

  • all (default)
  • none
  • type
  • short_desc
  • long_desc
  • units

When data=none then no data for the fields is requested and only an array of available fields names is returned.

View the distance, duration, ignition time, idle time, and the average speed per trip

https://api.pegasusgateway.com/trips?from=2016-10-17&to=2016-10-18&vehicles=598,599&fields=distance,duration,ignition,idle,mean_speed

{
  "mean_speed": 13.17,
  "duration": 3483,
  "idle": 0,
  "distance": 45876,
  "ignition": 3483
}

When getting trips, if the fields parameter is undefined, then all available trips' fields data will be returned by default.

Hours of Service Segments API

To browse HoS segments you can use the segments partition API

GET /api/segments?partition=<partition>&entities=<vid>&from=<date>&to=<date>

These are the currently supported query params to get segments data:

ParamDescription
partitionHow the segments are partitioned, for now only: entity_hos & kamaleon are supported
fromTime from YYYY-MM-DD[Thh:mm:ss]
toTime to YYYY-MM-DD[Thh:mm:ss]
durationISO_8601 Duration format (PnYnMnDTnHnMnS, PnW, PT) (ex: P1D = Past 1 Day)
entitiesVehicle IDs to get data from
offsetResult offset to view next segments. Number of results to skip until you reach the total.
data.stateworking or resting
data.start_event.labellabel corresponding with the end_event and start_event

segments?partition=entity_hos&from=2023-11-20T00:00:00&entities=459

The response shows segments sorted by creation date, most recent to oldest. The end_event of the working segment records the same info as the start_event of the resting segment, which means that the working segment ended because a resting segment started.

{
    "count": 20,
    "query": {
        "groups": null,
        "offset": 0,
        "data": null,
        "from": "2023-11-20T00:00:00+00:00",
        "entities": [
            459
        ],
        "section": 1,
        "partition": "entity_hos",
        "ids": null,
        "to": "2023-11-30T16:29:52.906129+00:00",
        "limit": 100
    },
    "total": 20,
    "data": [
        {
            "uuid": "064fcf3d-ea5d-41bc-a702-16356a52b5c4",
            "start_time": "2023-11-30T05:02:37+00:00",
            "partition": "entity_hos",
            "end_time": "2023-11-30T11:51:38+00:00",
            "identifier": "459",
            "data": {
                "entity_id": 459,
                "end_event": {
                    "lon": -74.03707,
                    "mph": 3.7,
                    "label": "aaa",
                    "count_dev_idle": 157690.0,
                    "event_time__epoch": 1701345098.0,
                    "moving": true,
                    "count_dev_dist": 20670626.0,
                    "lat": 4.81688,
                    "valid_gps": true,
                    "io_ign": true,
                    "count_dev_ign": 187564198.0
                },
                "signal": "moving",
                "max_continuous_work_hours": 2,
                "min_rest_hours": 4,
                "max_work_hours": 8,
                "state": "resting",
                "end_time": 1701345098.0,
                "device": 866771027161925,
                "start_event": {
                    "lon": -74.03684,
                    "mph": 0.0,
                    "label": "aaa",
                    "count_dev_idle": 157610.0,
                    "event_time__epoch": 1701320557.0,
                    "moving": false,
                    "count_dev_dist": 20670572.0,
                    "lat": 4.81671,
                    "valid_gps": true,
                    "io_ign": false,
                    "count_dev_ign": 187539717.0
                },
                "min_break_hours": 360.0,
                "start_time": 1701320557.0
            }
        },
        {
            "uuid": "e290f1f3-ddca-496c-9ac4-9201e319f51a",
            "start_time": "2023-11-29T11:49:03+00:00",
            "partition": "entity_hos",
            "end_time": "2023-11-30T05:02:37+00:00",
            "identifier": "459",
            "data": {
                "entity_id": 459,
                "start_time": 1701258543.0,
                "end_event": {
                    "lon": -74.03684,
                    "mph": 0.0,
                    "label": "aaa",
                    "count_dev_idle": 157610.0,
                    "event_time__epoch": 1701320557.0,
                    "moving": false,
                    "count_dev_dist": 20670572.0,
                    "lat": 4.81671,
                    "valid_gps": true,
                    "io_ign": false,
                    "count_dev_ign": 187539717.0
                },
                "breaks": [
                    {
                        "start_event": {
                            "lon": -74.04913,
                            "mph": 0.0,
                            "label": "aaa",
                            "count_dev_idle": 157568.0,
                            "event_time__epoch": 1701271087.0,
                            "moving": false,
                            "count_dev_dist": 20580201.0,
                            "lat": 4.85419,
                            "valid_gps": true,
                            "io_ign": true,
                            "count_dev_ign": 187490330.0
                        },
                        "end_event": {
                            "lon": -74.0485,
                            "mph": 19.3,
                            "label": "aaa",
                            "count_dev_idle": 157568.0,
                            "event_time__epoch": 1701271629.0,
                            "moving": true,
                            "count_dev_dist": 20580394.0,
                            "lat": 4.8557,
                            "valid_gps": true,
                            "io_ign": true,
                            "count_dev_ign": 187490871.0
                        }
                    },
                    {
                        "start_event": {
                            "lon": -74.03767,
                            "mph": 0.0,
                            "label": "aaa",
                            "count_dev_idle": 157601.0,
                            "event_time__epoch": 1701277499.0,
                            "moving": false,
                            "count_dev_dist": 20588908.0,
                            "lat": 4.81704,
                            "valid_gps": true,
                            "io_ign": true,
                            "count_dev_ign": 187496742.0
                        },
                        "end_event": {
                            "lon": -74.03759,
                            "mph": 3.1,
                            "label": "aaa",
                            "count_dev_idle": 157601.0,
                            "event_time__epoch": 1701278466.0,
                            "moving": true,
                            "count_dev_dist": 20589114.0,
                            "lat": 4.81696,
                            "valid_gps": true,
                            "io_ign": true,
                            "count_dev_ign": 187497709.0
                        }
                    },
                    {
                        "start_event": {
                            "lon": -74.0374,
                            "mph": 1.2,
                            "label": "aaa",
                            "count_dev_idle": 157601.0,
                            "event_time__epoch": 1701278482.0,
                            "moving": false,
                            "count_dev_dist": 20589142.0,
                            "lat": 4.8168,
                            "valid_gps": true,
                            "io_ign": true,
                            "count_dev_ign": 187497726.0
                        },
                        "end_event": {
                            "lon": -74.03701,
                            "mph": 3.7,
                            "label": "aaa",
                            "count_dev_idle": 157601.0,
                            "event_time__epoch": 1701279038.0,
                            "moving": true,
                            "count_dev_dist": 20589224.0,
                            "lat": 4.8167,
                            "valid_gps": true,
                            "io_ign": true,
                            "count_dev_ign": 187498281.0
                        }
                    },
                    {
                        "start_event": {
                            "lon": -74.04465,
                            "mph": 1.2,
                            "label": "aaa",
                            "count_dev_idle": 157601.0,
                            "event_time__epoch": 1701280905.0,
                            "moving": false,
                            "count_dev_dist": 20593970.0,
                            "lat": 4.77525,
                            "valid_gps": true,
                            "io_ign": true,
                            "count_dev_ign": 187500149.0
                        },
                        "end_event": {
                            "lon": -74.04403,
                            "mph": 3.7,
                            "label": "aaa",
                            "count_dev_idle": 157601.0,
                            "event_time__epoch": 1701283253.0,
                            "moving": true,
                            "count_dev_dist": 20594244.0,
                            "lat": 4.77523,
                            "valid_gps": true,
                            "io_ign": true,
                            "count_dev_ign": 187502492.0
                        }
                    },
                    {
                        "start_event": {
                            "lon": -74.04376,
                            "mph": 1.9,
                            "label": "aaa",
                            "count_dev_idle": 157601.0,
                            "event_time__epoch": 1701283279.0,
                            "moving": false,
                            "count_dev_dist": 20594272.0,
                            "lat": 4.77523,
                            "valid_gps": true,
                            "io_ign": true,
                            "count_dev_ign": 187502517.0
                        },
                        "end_event": {
                            "lon": -74.04376,
                            "mph": 3.1,
                            "label": "aaa",
                            "count_dev_idle": 157601.0,
                            "event_time__epoch": 1701284177.0,
                            "moving": true,
                            "count_dev_dist": 20594424.0,
                            "lat": 4.77539,
                            "valid_gps": true,
                            "io_ign": true,
                            "count_dev_ign": 187503410.0
                        }
                    },
                    {
                        "start_event": {
                            "lon": -74.03711,
                            "mph": 0.6,
                            "label": "aaa",
                            "count_dev_idle": 157601.0,
                            "event_time__epoch": 1701286773.0,
                            "moving": false,
                            "count_dev_dist": 20607876.0,
                            "lat": 4.81696,
                            "valid_gps": true,
                            "io_ign": true,
                            "count_dev_ign": 187505999.0
                        },
                        "end_event": {
                            "lon": -74.03735,
                            "mph": 4.3,
                            "label": "aaa",
                            "count_dev_idle": 157601.0,
                            "event_time__epoch": 1701291043.0,
                            "moving": true,
                            "count_dev_dist": 20608038.0,
                            "lat": 4.81734,
                            "valid_gps": true,
                            "io_ign": true,
                            "count_dev_ign": 187510270.0
                        }
                    },
                    {
                        "start_event": {
                            "lon": -74.03774,
                            "mph": 1.9,
                            "label": "aaa",
                            "count_dev_idle": 157601.0,
                            "event_time__epoch": 1701291091.0,
                            "moving": false,
                            "count_dev_dist": 20608101.0,
                            "lat": 4.81709,
                            "valid_gps": true,
                            "io_ign": true,
                            "count_dev_ign": 187510318.0
                        },
                        "end_event": {
                            "lon": -74.03773,
                            "mph": 3.1,
                            "label": "aaa",
                            "count_dev_idle": 157601.0,
                            "event_time__epoch": 1701291517.0,
                            "moving": true,
                            "count_dev_dist": 20608163.0,
                            "lat": 4.81701,
                            "valid_gps": true,
                            "io_ign": true,
                            "count_dev_ign": 187510743.0
                        }
                    },
                    {
                        "start_event": {
                            "lon": -73.9878,
                            "mph": 0.0,
                            "label": "aaa",
                            "count_dev_idle": 157601.0,
                            "event_time__epoch": 1701295734.0,
                            "moving": false,
                            "count_dev_dist": 20640371.0,
                            "lat": 5.03404,
                            "valid_gps": true,
                            "io_ign": true,
                            "count_dev_ign": 187514962.0
                        },
                        "end_event": {
                            "lon": -73.98803,
                            "mph": 3.7,
                            "label": "aaa",
                            "count_dev_idle": 157601.0,
                            "event_time__epoch": 1701296561.0,
                            "moving": true,
                            "count_dev_dist": 20640657.0,
                            "lat": 5.0338,
                            "valid_gps": true,
                            "io_ign": true,
                            "count_dev_ign": 187515787.0
                        }
                    },
                    {
                        "start_event": {
                            "lon": -73.98792,
                            "mph": 0.0,
                            "label": "aaa",
                            "count_dev_idle": 157601.0,
                            "event_time__epoch": 1701296569.0,
                            "moving": false,
                            "count_dev_dist": 20640674.0,
                            "lat": 5.03386,
                            "valid_gps": true,
                            "io_ign": true,
                            "count_dev_ign": 187515795.0
                        },
                        "end_event": {
                            "lon": -73.98763,
                            "mph": 3.1,
                            "label": "aaa",
                            "count_dev_idle": 157601.0,
                            "event_time__epoch": 1701298166.0,
                            "moving": true,
                            "count_dev_dist": 20641200.0,
                            "lat": 5.03408,
                            "valid_gps": true,
                            "io_ign": true,
                            "count_dev_ign": 187517376.0
                        }
                    },
                    {
                        "start_event": {
                            "lon": -74.03756,
                            "mph": 1.9,
                            "label": "aaa",
                            "count_dev_idle": 157610.0,
                            "event_time__epoch": 1701302000.0,
                            "moving": false,
                            "count_dev_dist": 20670335.0,
                            "lat": 4.81669,
                            "valid_gps": true,
                            "io_ign": true,
                            "count_dev_ign": 187521204.0
                        },
                        "end_event": {
                            "lon": -74.03742,
                            "mph": 3.1,
                            "label": "aaa",
                            "count_dev_idle": 157610.0,
                            "event_time__epoch": 1701302375.0,
                            "moving": true,
                            "count_dev_dist": 20670364.0,
                            "lat": 4.8168,
                            "valid_gps": true,
                            "io_ign": true,
                            "count_dev_ign": 187521578.0
                        }
                    }
                ],
                "resting_start": 1701302607.0,
                "min_rest_hours": 4,
                "max_work_hours": 8,
                "state": "working",
                "end_time": 1701320557.0,
                "max_continuous_work_hours": 2,
                "device": 866771027161925,
                "start_event": {
                    "lon": -74.03697,
                    "mph": 9.9,
                    "label": "aaa",
                    "count_dev_idle": 157328.0,
                    "event_time__epoch": 1701258543.0,
                    "moving": true,
                    "count_dev_dist": 20559591.0,
                    "lat": 4.81712,
                    "valid_gps": true,
                    "io_ign": true,
                    "count_dev_ign": 187477794.0
                },
                "min_break_hours": 360.0,
                "signal": "moving",
                "resting_start_event": {
                    "lon": -74.03693,
                    "mph": 0.0,
                    "label": "ignoff",
                    "count_dev_idle": 157610.0,
                    "event_time__epoch": 1701302607.0,
                    "moving": false,
                    "count_dev_dist": 20670572.0,
                    "lat": 4.81679,
                    "valid_gps": true,
                    "io_ign": false,
                    "count_dev_ign": 187521810.0
                }
            }
        }

πŸ“˜

Segments Pagination

Note that the response of the segments API is paginated and returns the first 100 results.
The way to navigate the rest of the segments requested when there's more than 100 results is to use offset. The offset pops the most recent X amount of segments from the results until you reach the total segments. The total is reached when you have count from the response + offset from the param equaling the total from the response.

In other words if the total is 147 segments, the normal API response would return the first 100:

  "count": 100,
   ...
  "total": 147,
  "data": []

To get the next 47 you can pop the first 100 using the offset=100

 "count": 47,
  ...
 "total": 147,
 "data": []

🚧

Units in Segments API

Note that the units responded in the Segments API are the default ones reported by the API.

Distance = meters
Time = seconds
Volume = liters
Speed = km/h

Hours of Service States

For the sake of Hours of Service the following states are derived from segments

StateStatusDescription
WorkingValidWorking less than or equal to the max_work_hours and working continuously less than or equal to the max_continuous_work_hours.
WorkingInvalidWorking more than the max_work_hours or working continuously more than max_continuous_work_hours.
WorkingUnfinishedThe time that the vehicle has been turned off is less than minimum rest hours.
RestingValidThe time that the vehicle has been turned off is equal to or more than min_rest_hours.

HoS API

The general idea of this API is to know:

  • The maximum hours that the entity works.
  • The maximum time that an entity works continually.
  • The break times during the working segment.
  • The minimum rest time of an entity.

As we mentioned above, HoS are segments that can have two states: working or resting. In the configuration of HoS segments, we specified the max_work_hours, min_break_hours,max_continuous_work_hours and min_rest_ hours.

The working segment starts when the signal is true (for example if the signal is ignition, then when the ignition is on). When the signal goes to false, the vehicle enters at resting, and a resting_start property with the date when the vehicle starts resting is recorded. If the vehicle remains in this resting state for at least the min_rest_hours, the system creates a restingsegment, which will end when the vehicle is turned on again. Both segments: working + resting create a cycle.

The HoS API shows the complete working and resting segments for entities. It shows information related to the working cycle of a vehicle/driver, ex: the time when the cycle started and ended, the amount of hours continuously worked, the total worked hours, the brakes-times, and the total resting hours, etc. It also shows if the cycle is valid or not. If the vehicle/driver works more than max_work_hours the cycle is invalid (valid: false).

Let's take an example:

The driver needs to travel from Miami to New York. In this example, the signal is ignition.

We have this segment configuration:

{  
    "segment_type": "hos",  
    "signal": "ignition",  
    "max_work_hours": 8,  
    "min_rest_hours": 4,  
    "max_continuous_work_hours": 2,  
    "min_break_hours": 0.25  
}
StepActionSystem response
1The driver turns on the vehicle. Ignition OnCreate a working segment with start_time: current date, state: working, io_ign: true, etc.
3The driver turns off the vehicle (for lunch). Ignition OffThe working segment switch io_ign: false, the state continue in working and in the resting_start the system records the date when the driver turned off the vehicle. The vehicle remains in this resting state for at least min_break_hours and the system will record this break time.
3The driver finishes his/her lunch and turns on the vehicle to continue with the travel. Ignition OnThe segment switch io_ign: true and state continue in working because the rest time was not equal to or greater than min_rest_hours.
5The driver turns off the vehicle (for dinner and sleep). Ignition OffThe segment switch io_ign: false, the state continue in working and in the resting_start property the system records the date when the driver turned off the vehicle. The vehicle remains in this resting state for a time equal to min_rest_hours, so at this time, when the vehicle reports the next event, it automatically ends the work segment, and a rest segment is created with(start_time: current date, state: resting, io_ign: false, etc). Note that the segment switches on the next received event.
6The next morning the driver turns on the vehicle to continue with the travel. Ignition OnThe resting segment is ended, and is created another working segment(start_time: current date, state: working,io_ign: true, etc). At this moment, the entity has one finished cycle (the working segment + resting segment) corresponding with the day before and also has one current cycle that is not finished yet.

While the trip lasts, the cycles will be recorded depending on the working and resting segments that are ending. If a segment does not end, it means that the entity has not generated another event (for example: Turn on the vehicle).

This API is found in a separate server, d2.

d2.pegasusgateway.com/segments/hos

The parameters are

ParamDescription
authToken (Pegasus)
fromstart date (YYYY-MM-DD[Thh:mm:ss])
toend date (YYYY-MM-DD[Thh:mm:ss]), defaults to current time
entitiesIds related to vehicles or assets
groupsIds related to groups
pointerThe element pointer of the segment API.
limitAmount of cycles. By default is 250. Maximum is 250.
sectionThe API sections the entities when the quantity is greater than 100, the API returns how many sections it was divided into.

segments/hos?auth={{AUTH_TOKEN}}&from=2023-11-29T11:49:03&to=2023-11-30T11:51:38&entities=459

{
    "query": {
        "from": "2023-11-29T11:49:03",
        "to": "2023-11-30T11:51:38",
        "pointer": 0,
        "entities": [
            459
        ],
        "section": 1,
        "limit": 250
    },
    "count": 1,
    "limit": 250,
    "next_pointer": -1,
    "sections": 1,
    "data": [
        {
            "cycle_start": "2023-11-29T11:49:03Z",
            "cycle_end": "2023-11-30T11:51:38Z",
            "start_working": "2023-11-29T11:49:03Z",
            "end_working": "2023-11-30T00:03:27Z",
            "cycle_working_time": 44064,
            "cycle_rest_time": 42491,
            "total_rest_time": 60068,
            "total_breaks_time": 12806,
            "break_times": 17577,
            "last_working_location": {
                "lat": 4.40137,
                "lon": -75.29409
            },
            "valid": false,
            "cycle_id": "e290f1f3-ddca-496c-9ac4-9201e319f51a",
            "entity_id": 459,
            "state": "resting",
            "source": "vehicle",
            "breaks": [
                {
                    "start_event": {
                        "lon": -74.04913,
                        "mph": 0,
                        "label": "aaa",
                        "count_dev_idle": 157568,
                        "event_time__epoch": 1701271087,
                        "moving": false,
                        "count_dev_dist": 20580201,
                        "lat": 4.85419,
                        "valid_gps": true,
                        "io_ign": true,
                        "count_dev_ign": 187490330
                    },
                    "end_event": {
                        "lon": -74.0485,
                        "mph": 19.3,
                        "label": "aaa",
                        "count_dev_idle": 157568,
                        "event_time__epoch": 1701271629,
                        "moving": true,
                        "count_dev_dist": 20580394,
                        "lat": 4.8557,
                        "valid_gps": true,
                        "io_ign": true,
                        "count_dev_ign": 187490871
                    }
                },
                {
                    "start_event": {
                        "lon": -74.03767,
                        "mph": 0,
                        "label": "aaa",
                        "count_dev_idle": 157601,
                        "event_time__epoch": 1701277499,
                        "moving": false,
                        "count_dev_dist": 20588908,
                        "lat": 4.81704,
                        "valid_gps": true,
                        "io_ign": true,
                        "count_dev_ign": 187496742
                    },
                    "end_event": {
                        "lon": -74.03759,
                        "mph": 3.1,
                        "label": "aaa",
                        "count_dev_idle": 157601,
                        "event_time__epoch": 1701278466,
                        "moving": true,
                        "count_dev_dist": 20589114,
                        "lat": 4.81696,
                        "valid_gps": true,
                        "io_ign": true,
                        "count_dev_ign": 187497709
                    }
                },
                {
                    "start_event": {
                        "lon": -74.0374,
                        "mph": 1.2,
                        "label": "aaa",
                        "count_dev_idle": 157601,
                        "event_time__epoch": 1701278482,
                        "moving": false,
                        "count_dev_dist": 20589142,
                        "lat": 4.8168,
                        "valid_gps": true,
                        "io_ign": true,
                        "count_dev_ign": 187497726
                    },
                    "end_event": {
                        "lon": -74.03701,
                        "mph": 3.7,
                        "label": "aaa",
                        "count_dev_idle": 157601,
                        "event_time__epoch": 1701279038,
                        "moving": true,
                        "count_dev_dist": 20589224,
                        "lat": 4.8167,
                        "valid_gps": true,
                        "io_ign": true,
                        "count_dev_ign": 187498281
                    }
                },
                {
                    "start_event": {
                        "lon": -74.04465,
                        "mph": 1.2,
                        "label": "aaa",
                        "count_dev_idle": 157601,
                        "event_time__epoch": 1701280905,
                        "moving": false,
                        "count_dev_dist": 20593970,
                        "lat": 4.77525,
                        "valid_gps": true,
                        "io_ign": true,
                        "count_dev_ign": 187500149
                    },
                    "end_event": {
                        "lon": -74.04403,
                        "mph": 3.7,
                        "label": "aaa",
                        "count_dev_idle": 157601,
                        "event_time__epoch": 1701283253,
                        "moving": true,
                        "count_dev_dist": 20594244,
                        "lat": 4.77523,
                        "valid_gps": true,
                        "io_ign": true,
                        "count_dev_ign": 187502492
                    }
                },
                {
                    "start_event": {
                        "lon": -74.04376,
                        "mph": 1.9,
                        "label": "aaa",
                        "count_dev_idle": 157601,
                        "event_time__epoch": 1701283279,
                        "moving": false,
                        "count_dev_dist": 20594272,
                        "lat": 4.77523,
                        "valid_gps": true,
                        "io_ign": true,
                        "count_dev_ign": 187502517
                    },
                    "end_event": {
                        "lon": -74.04376,
                        "mph": 3.1,
                        "label": "aaa",
                        "count_dev_idle": 157601,
                        "event_time__epoch": 1701284177,
                        "moving": true,
                        "count_dev_dist": 20594424,
                        "lat": 4.77539,
                        "valid_gps": true,
                        "io_ign": true,
                        "count_dev_ign": 187503410
                    }
                },
                {
                    "start_event": {
                        "lon": -74.03711,
                        "mph": 0.6,
                        "label": "aaa",
                        "count_dev_idle": 157601,
                        "event_time__epoch": 1701286773,
                        "moving": false,
                        "count_dev_dist": 20607876,
                        "lat": 4.81696,
                        "valid_gps": true,
                        "io_ign": true,
                        "count_dev_ign": 187505999
                    },
                    "end_event": {
                        "lon": -74.03735,
                        "mph": 4.3,
                        "label": "aaa",
                        "count_dev_idle": 157601,
                        "event_time__epoch": 1701291043,
                        "moving": true,
                        "count_dev_dist": 20608038,
                        "lat": 4.81734,
                        "valid_gps": true,
                        "io_ign": true,
                        "count_dev_ign": 187510270
                    }
                },
                {
                    "start_event": {
                        "lon": -74.03774,
                        "mph": 1.9,
                        "label": "aaa",
                        "count_dev_idle": 157601,
                        "event_time__epoch": 1701291091,
                        "moving": false,
                        "count_dev_dist": 20608101,
                        "lat": 4.81709,
                        "valid_gps": true,
                        "io_ign": true,
                        "count_dev_ign": 187510318
                    },
                    "end_event": {
                        "lon": -74.03773,
                        "mph": 3.1,
                        "label": "aaa",
                        "count_dev_idle": 157601,
                        "event_time__epoch": 1701291517,
                        "moving": true,
                        "count_dev_dist": 20608163,
                        "lat": 4.81701,
                        "valid_gps": true,
                        "io_ign": true,
                        "count_dev_ign": 187510743
                    }
                },
                {
                    "start_event": {
                        "lon": -73.9878,
                        "mph": 0,
                        "label": "aaa",
                        "count_dev_idle": 157601,
                        "event_time__epoch": 1701295734,
                        "moving": false,
                        "count_dev_dist": 20640371,
                        "lat": 5.03404,
                        "valid_gps": true,
                        "io_ign": true,
                        "count_dev_ign": 187514962
                    },
                    "end_event": {
                        "lon": -73.98803,
                        "mph": 3.7,
                        "label": "aaa",
                        "count_dev_idle": 157601,
                        "event_time__epoch": 1701296561,
                        "moving": true,
                        "count_dev_dist": 20640657,
                        "lat": 5.0338,
                        "valid_gps": true,
                        "io_ign": true,
                        "count_dev_ign": 187515787
                    }
                },
                {
                    "start_event": {
                        "lon": -73.98792,
                        "mph": 0,
                        "label": "aaa",
                        "count_dev_idle": 157601,
                        "event_time__epoch": 1701296569,
                        "moving": false,
                        "count_dev_dist": 20640674,
                        "lat": 5.03386,
                        "valid_gps": true,
                        "io_ign": true,
                        "count_dev_ign": 187515795
                    },
                    "end_event": {
                        "lon": -73.98763,
                        "mph": 3.1,
                        "label": "aaa",
                        "count_dev_idle": 157601,
                        "event_time__epoch": 1701298166,
                        "moving": true,
                        "count_dev_dist": 20641200,
                        "lat": 5.03408,
                        "valid_gps": true,
                        "io_ign": true,
                        "count_dev_ign": 187517376
                    }
                },
                {
                    "start_event": {
                        "lon": -74.03756,
                        "mph": 1.9,
                        "label": "aaa",
                        "count_dev_idle": 157610,
                        "event_time__epoch": 1701302000,
                        "moving": false,
                        "count_dev_dist": 20670335,
                        "lat": 4.81669,
                        "valid_gps": true,
                        "io_ign": true,
                        "count_dev_ign": 187521204
                    },
                    "end_event": {
                        "lon": -74.03742,
                        "mph": 3.1,
                        "label": "aaa",
                        "count_dev_idle": 157610,
                        "event_time__epoch": 1701302375,
                        "moving": true,
                        "count_dev_dist": 20670364,
                        "lat": 4.8168,
                        "valid_gps": true,
                        "io_ign": true,
                        "count_dev_ign": 187521578
                    }
                }
            ],
            "driver": null,
            "driver_id": null,
            "vehicle_id": 459,
            "shipment_code": []
        }
    ]
}

How do we get the data to build the cycle?

For example, to create the cycle depicted we need the data from the [Segments API](### Hours of Service Segments API)

segments?partition=entity_hos&from=2023-11-20T00:00:00&entities=459

{
    "count": 20,
    "query": {
        "groups": null,
        "offset": 0,
        "data": null,
        "from": "2023-11-20T00:00:00+00:00",
        "entities": [
            459
        ],
        "section": 1,
        "partition": "entity_hos",
        "ids": null,
        "to": "2023-11-30T16:29:52.906129+00:00",
        "limit": 100
    },
    "total": 20,
    "data": [
        {  
            "uuid": "064fcf3d-ea5d-41bc-a702-16356a52b5c4",
            "start_time": "2023-11-30T05:02:37+00:00",
            "partition": "entity_hos",
            "end_time": "2023-11-30T11:51:38+00:00",
            "identifier": "459",
            "data": {
                "entity_id": 459,
                "end_event": {
                    "lon": -74.03707,
                    "mph": 3.7,
                    "label": "aaa",
                    "count_dev_idle": 157690.0,
                    "event_time__epoch": 1701345098.0,
                    "moving": true,
                    "count_dev_dist": 20670626.0,
                    "lat": 4.81688,
                    "valid_gps": true,
                    "io_ign": true,
                    "count_dev_ign": 187564198.0
                },
                "signal": "moving",
                "max_continuous_work_hours": 2,
                "min_rest_hours": 4,
                "max_work_hours": 8,
                "state": "resting",
                "end_time": 1701345098.0,
                "device": 866771027161925,
                "start_event": {
                    "lon": -74.03684,
                    "mph": 0.0,
                    "label": "aaa",
                    "count_dev_idle": 157610.0,
                    "event_time__epoch": 1701320557.0,
                    "moving": false,
                    "count_dev_dist": 20670572.0,
                    "lat": 4.81671,
                    "valid_gps": true,
                    "io_ign": false,
                    "count_dev_ign": 187539717.0
                },
                "min_break_hours": 0.1,
                "start_time": 1701320557.0
            }
        },
        {
            "uuid": "e290f1f3-ddca-496c-9ac4-9201e319f51a",
            "start_time": "2023-11-29T11:49:03+00:00",
            "partition": "entity_hos",
            "end_time": "2023-11-30T05:02:37+00:00",
            "identifier": "459",
            "data": {
                "entity_id": 459,
                "start_time": 1701258543.0,
                "end_event": {
                    "lon": -74.03684,
                    "mph": 0.0,
                    "label": "aaa",
                    "count_dev_idle": 157610.0,
                    "event_time__epoch": 1701320557.0,
                    "moving": false,
                    "count_dev_dist": 20670572.0,
                    "lat": 4.81671,
                    "valid_gps": true,
                    "io_ign": false,
                    "count_dev_ign": 187539717.0
                },
                "breaks": [
                    {
                        "start_event": {
                            "lon": -74.04913,
                            "mph": 0.0,
                            "label": "aaa",
                            "count_dev_idle": 157568.0,
                            "event_time__epoch": 1701271087.0,
                            "moving": false,
                            "count_dev_dist": 20580201.0,
                            "lat": 4.85419,
                            "valid_gps": true,
                            "io_ign": true,
                            "count_dev_ign": 187490330.0
                        },
                        "end_event": {
                            "lon": -74.0485,
                            "mph": 19.3,
                            "label": "aaa",
                            "count_dev_idle": 157568.0,
                            "event_time__epoch": 1701271629.0,
                            "moving": true,
                            "count_dev_dist": 20580394.0,
                            "lat": 4.8557,
                            "valid_gps": true,
                            "io_ign": true,
                            "count_dev_ign": 187490871.0
                        }
                    },
                    {
                        "start_event": {
                            "lon": -74.03767,
                            "mph": 0.0,
                            "label": "aaa",
                            "count_dev_idle": 157601.0,
                            "event_time__epoch": 1701277499.0,
                            "moving": false,
                            "count_dev_dist": 20588908.0,
                            "lat": 4.81704,
                            "valid_gps": true,
                            "io_ign": true,
                            "count_dev_ign": 187496742.0
                        },
                        "end_event": {
                            "lon": -74.03759,
                            "mph": 3.1,
                            "label": "aaa",
                            "count_dev_idle": 157601.0,
                            "event_time__epoch": 1701278466.0,
                            "moving": true,
                            "count_dev_dist": 20589114.0,
                            "lat": 4.81696,
                            "valid_gps": true,
                            "io_ign": true,
                            "count_dev_ign": 187497709.0
                        }
                    },
                    {
                        "start_event": {
                            "lon": -74.0374,
                            "mph": 1.2,
                            "label": "aaa",
                            "count_dev_idle": 157601.0,
                            "event_time__epoch": 1701278482.0,
                            "moving": false,
                            "count_dev_dist": 20589142.0,
                            "lat": 4.8168,
                            "valid_gps": true,
                            "io_ign": true,
                            "count_dev_ign": 187497726.0
                        },
                        "end_event": {
                            "lon": -74.03701,
                            "mph": 3.7,
                            "label": "aaa",
                            "count_dev_idle": 157601.0,
                            "event_time__epoch": 1701279038.0,
                            "moving": true,
                            "count_dev_dist": 20589224.0,
                            "lat": 4.8167,
                            "valid_gps": true,
                            "io_ign": true,
                            "count_dev_ign": 187498281.0
                        }
                    },
                    {
                        "start_event": {
                            "lon": -74.04465,
                            "mph": 1.2,
                            "label": "aaa",
                            "count_dev_idle": 157601.0,
                            "event_time__epoch": 1701280905.0,
                            "moving": false,
                            "count_dev_dist": 20593970.0,
                            "lat": 4.77525,
                            "valid_gps": true,
                            "io_ign": true,
                            "count_dev_ign": 187500149.0
                        },
                        "end_event": {
                            "lon": -74.04403,
                            "mph": 3.7,
                            "label": "aaa",
                            "count_dev_idle": 157601.0,
                            "event_time__epoch": 1701283253.0,
                            "moving": true,
                            "count_dev_dist": 20594244.0,
                            "lat": 4.77523,
                            "valid_gps": true,
                            "io_ign": true,
                            "count_dev_ign": 187502492.0
                        }
                    },
                    {
                        "start_event": {
                            "lon": -74.04376,
                            "mph": 1.9,
                            "label": "aaa",
                            "count_dev_idle": 157601.0,
                            "event_time__epoch": 1701283279.0,
                            "moving": false,
                            "count_dev_dist": 20594272.0,
                            "lat": 4.77523,
                            "valid_gps": true,
                            "io_ign": true,
                            "count_dev_ign": 187502517.0
                        },
                        "end_event": {
                            "lon": -74.04376,
                            "mph": 3.1,
                            "label": "aaa",
                            "count_dev_idle": 157601.0,
                            "event_time__epoch": 1701284177.0,
                            "moving": true,
                            "count_dev_dist": 20594424.0,
                            "lat": 4.77539,
                            "valid_gps": true,
                            "io_ign": true,
                            "count_dev_ign": 187503410.0
                        }
                    },
                    {
                        "start_event": {
                            "lon": -74.03711,
                            "mph": 0.6,
                            "label": "aaa",
                            "count_dev_idle": 157601.0,
                            "event_time__epoch": 1701286773.0,
                            "moving": false,
                            "count_dev_dist": 20607876.0,
                            "lat": 4.81696,
                            "valid_gps": true,
                            "io_ign": true,
                            "count_dev_ign": 187505999.0
                        },
                        "end_event": {
                            "lon": -74.03735,
                            "mph": 4.3,
                            "label": "aaa",
                            "count_dev_idle": 157601.0,
                            "event_time__epoch": 1701291043.0,
                            "moving": true,
                            "count_dev_dist": 20608038.0,
                            "lat": 4.81734,
                            "valid_gps": true,
                            "io_ign": true,
                            "count_dev_ign": 187510270.0
                        }
                    },
                    {
                        "start_event": {
                            "lon": -74.03774,
                            "mph": 1.9,
                            "label": "aaa",
                            "count_dev_idle": 157601.0,
                            "event_time__epoch": 1701291091.0,
                            "moving": false,
                            "count_dev_dist": 20608101.0,
                            "lat": 4.81709,
                            "valid_gps": true,
                            "io_ign": true,
                            "count_dev_ign": 187510318.0
                        },
                        "end_event": {
                            "lon": -74.03773,
                            "mph": 3.1,
                            "label": "aaa",
                            "count_dev_idle": 157601.0,
                            "event_time__epoch": 1701291517.0,
                            "moving": true,
                            "count_dev_dist": 20608163.0,
                            "lat": 4.81701,
                            "valid_gps": true,
                            "io_ign": true,
                            "count_dev_ign": 187510743.0
                        }
                    },
                    {
                        "start_event": {
                            "lon": -73.9878,
                            "mph": 0.0,
                            "label": "aaa",
                            "count_dev_idle": 157601.0,
                            "event_time__epoch": 1701295734.0,
                            "moving": false,
                            "count_dev_dist": 20640371.0,
                            "lat": 5.03404,
                            "valid_gps": true,
                            "io_ign": true,
                            "count_dev_ign": 187514962.0
                        },
                        "end_event": {
                            "lon": -73.98803,
                            "mph": 3.7,
                            "label": "aaa",
                            "count_dev_idle": 157601.0,
                            "event_time__epoch": 1701296561.0,
                            "moving": true,
                            "count_dev_dist": 20640657.0,
                            "lat": 5.0338,
                            "valid_gps": true,
                            "io_ign": true,
                            "count_dev_ign": 187515787.0
                        }
                    },
                    {
                        "start_event": {
                            "lon": -73.98792,
                            "mph": 0.0,
                            "label": "aaa",
                            "count_dev_idle": 157601.0,
                            "event_time__epoch": 1701296569.0,
                            "moving": false,
                            "count_dev_dist": 20640674.0,
                            "lat": 5.03386,
                            "valid_gps": true,
                            "io_ign": true,
                            "count_dev_ign": 187515795.0
                        },
                        "end_event": {
                            "lon": -73.98763,
                            "mph": 3.1,
                            "label": "aaa",
                            "count_dev_idle": 157601.0,
                            "event_time__epoch": 1701298166.0,// 2023-11-29 10:49:26 PM
                            "moving": true,
                            "count_dev_dist": 20641200.0,
                            "lat": 5.03408,
                            "valid_gps": true,
                            "io_ign": true,
                            "count_dev_ign": 187517376.0
                        }
                    },
                    {
                        "start_event": {
                            "lon": -74.03756,
                            "mph": 1.9,
                            "label": "aaa",
                            "count_dev_idle": 157610.0,
                            "event_time__epoch": 1701302000.0,// 2023-11-29 11:53:20 PM
                            "moving": false,
                            "count_dev_dist": 20670335.0,
                            "lat": 4.81669,
                            "valid_gps": true,
                            "io_ign": true,
                            "count_dev_ign": 187521204.0
                        },
                        "end_event": {
                            "lon": -74.03742,
                            "mph": 3.1,
                            "label": "aaa",
                            "count_dev_idle": 157610.0,
                            "event_time__epoch": 1701302375.0,//2023-11-29 11:59:35 PM
                            "moving": true,
                            "count_dev_dist": 20670364.0,
                            "lat": 4.8168,
                            "valid_gps": true,
                            "io_ign": true,
                            "count_dev_ign": 187521578.0
                        }
                    }
                ],
                "resting_start": 1701302607.0, 
                "min_rest_hours": 4,
                "max_work_hours": 8,
                "state": "working",
                "end_time": 1701320557.0,
                "max_continuous_work_hours": 2,
                "device": 866771027161925,
                "start_event": {
                    "lon": -74.03697,
                    "mph": 9.9,
                    "label": "aaa",
                    "count_dev_idle": 157328.0,
                    "event_time__epoch": 1701258543.0,
                    "moving": true,
                    "count_dev_dist": 20559591.0,
                    "lat": 4.81712,
                    "valid_gps": true,
                    "io_ign": true,
                    "count_dev_ign": 187477794.0
                },
                "min_break_hours": 0.1,
                "signal": "moving",
                "resting_start_event": {
                    "lon": -74.03693,
                    "mph": 0.0,
                    "label": "ignoff",
                    "count_dev_idle": 157610.0,
                    "event_time__epoch": 1701302607.0,
                    "moving": false,
                    "count_dev_dist": 20670572.0,
                    "lat": 4.81679,
                    "valid_gps": true,
                    "io_ign": false,
                    "count_dev_ign": 187521810.0
                }
            }
        },
      ....
   }
               
FieldDescriptionExample
cycle_startworking segment start time working.data.start_timeworking segment start_time: 2023-11-29T11:49:03
cycle_endresting segment end time resting.data.end_time
if the working segment is manually closed: working.data.end_time
resting segment end_time: 2023-11-30T11:51:38
start_working time the entity met the signal condition to start working (time in UTC) working.data.start_timeworking segment start_time: 2023-11-29T11:49:03
end_workingentity.working.resting_start
if entity.working.resting_start is null/empty then entity.working.data.end_time
working segment "resting_start": 1701302607.0,= 2023-11-30T12:03:27 AM
cycle_working_time(resting.data.start_time - working.data.start_time) - min_rest_hours
or
(working.data.end_time - working.data.start_time) - min_rest_hours
or
working.data.resting_start -working.data.start_time
2023-11-30T12:03:27-2023-11-29T11:49:03 = 44,064 s = 12.14h
cycle_rest_timeresting.data.end_time - working.data.resting_start
or
(resting.data.end_time - working.data.end_time) + min_rest_hours
2023-11-30T11:51:38 - 2023-11-30T12:03:27 = 42,491 s = 11.8h
break_time(working segment)
total_ign_off_time = total_time - total_ign_on_time
total_ign_off_time + total_idle_time - min_rest_time
The idle time starts counting after 3 min
total_break_timeThe sum of all breaks in break[]
total_rest_timecycle_rest_time+break_time
validtrue or false.
Is true when the vehicle was turned off equal to or more than min_rest_hours, and the cycle_working_time is equal to or less than max_work_hours.
Is false when the vehicle was turned off less than min_rest_hours or cycle_working_timeis more than max_work_hours.
cycle_idid related to the cycle
last_working_locationlatitude and longitude at the time the work segment was closed
if the cycle is open then the latitude and longitude of the last reported location
entity_idvehicle.id or asset.id
stateworking or resting
sourceex: vehicle
driverasset.name or vehicle.driver
driver_idasset.id
vehicle_idvehicle.id
vehiclevehicle.name
telephoneasset.info.phone
shipment_codesThe codes are related to the Cemex shipments that the entity made during the cycle. Shipments are transactions that we receive from Cemex and are stored in a separate database (MongoDB)

Manually close an overworked working segment

The working segment that is overworked can be manually closed, which means that the working segment will be closed/completed, and a new segment will be created automatically when the next event is received.

Example

In this case, we have a vehicle online (the device is connected), and we manually close the working segment using the segment_close API vehicles/:id/remote/segment_close or devices/:imei/remote/segment_close

{
    "segment_type": "hos"
}

We can see the closed segment in the segments API segments?partition=entity_hos&from=2023-10-27T10:00:00&to=2023-10-27T19:00:00&entities=459

Note that the closed segment has a property called $forced:true inside the resting_start_event object, which indicates that the segment started a forced rest, and the resting_start records the date when the cycle was closed.

{
    "count": 2,
    "query": {
        "groups": null,
        "offset": 0,
        "data": null,
        "from": "2023-10-27T10:00:00+00:00",
        "entities": [
            459
        ],
        "section": 1,
        "partition": "entity_hos",
        "ids": null,
        "to": "2023-10-27T19:00:00+00:00",
        "limit": 100
    },
    "total": 2,
    "data": [
        {
            "uuid": "04865143-176f-4176-9f38-61df28069279",
            "start_time": "2023-10-27T10:55:46+00:00",
            "partition": "entity_hos",
            "end_time": "2023-10-27T19:39:02.366268+00:00",
            "identifier": "459",
            "data": {
                "resting_start": 1698435542.366268,
                "entity_id": 459,
                "start_time": 1698404146.0,
                "end_event": {
                    "$forced": true,
                    "lon": 4.82651,
                    "mph": null,
                    "label": "aaa",
                    "count_dev_idle": 143158.0,
                    "event_time__epoch": 1698435542.366268,
                    "moving": null,
                    "count_dev_dist": 17318739,
                    "lat": 4.82651,
                    "valid_gps": true,
                    "io_ign": true,
                    "count_dev_ign": 29037750
                },
                "breaks": [
                    {
                        "start_event": {
                            "lon": -74.03691,
                            "mph": 0.0,
                            "label": "aaa",
                            "count_dev_idle": 143088.0,
                            "event_time__epoch": 1698410430.0,
                            "moving": false,
                            "count_dev_dist": 18803383.0,
                            "lat": 4.81659,
                            "valid_gps": true,
                            "io_ign": true,
                            "count_dev_ign": 184636129.0
                        },
                        "end_event": {
                            "lon": -74.03698,
                            "mph": 7.5,
                            "label": "aaa",
                            "count_dev_idle": 143103.0,
                            "event_time__epoch": 1698411014.0,
                            "moving": true,
                            "count_dev_dist": 18803387.0,
                            "lat": 4.81658,
                            "valid_gps": true,
                            "io_ign": true,
                            "count_dev_ign": 184636713.0
                        }
                    },
                    {
                        "start_event": {
                            "lon": -74.05419,
                            "mph": 0.0,
                            "label": "aaa",
                            "count_dev_idle": 143128.0,
                            "event_time__epoch": 1698415197.0,
                            "moving": false,
                            "count_dev_dist": 18818195.0,
                            "lat": 4.69393,
                            "valid_gps": true,
                            "io_ign": true,
                            "count_dev_ign": 184640897.0
                        },
                        "end_event": {
                            "lon": -74.05428,
                            "mph": 3.1,
                            "label": "aaa",
                            "count_dev_idle": 143128.0,
                            "event_time__epoch": 1698416811.0,
                            "moving": true,
                            "count_dev_dist": 18818547.0,
                            "lat": 4.69399,
                            "valid_gps": true,
                            "io_ign": true,
                            "count_dev_ign": 184642509.0
                        }
                    },
                    {
                        "start_event": {
                            "lon": -74.03743,
                            "mph": 0.6,
                            "label": "aaa",
                            "count_dev_idle": 143128.0,
                            "event_time__epoch": 1698420759.0,
                            "moving": false,
                            "count_dev_dist": 18835848.0,
                            "lat": 4.81682,
                            "valid_gps": true,
                            "io_ign": true,
                            "count_dev_ign": 184646456.0
                        },
                        "end_event": {
                            "lon": -74.03722,
                            "mph": 3.1,
                            "label": "aaa",
                            "count_dev_idle": 143128.0,
                            "event_time__epoch": 1698421251.0,
                            "moving": true,
                            "count_dev_dist": 18835942.0,
                            "lat": 4.81675,
                            "valid_gps": true,
                            "io_ign": true,
                            "count_dev_ign": 184646947.0
                        }
                    },
                    {
                        "start_event": {
                            "lon": -74.03725,
                            "mph": 1.2,
                            "label": "aaa",
                            "count_dev_idle": 143128.0,
                            "event_time__epoch": 1698421330.0,
                            "moving": false,
                            "count_dev_dist": 18836051.0,
                            "lat": 4.81696,
                            "valid_gps": true,
                            "io_ign": true,
                            "count_dev_ign": 184647027.0
                        },
                        "end_event": {
                            "lon": -74.03718,
                            "mph": 3.7,
                            "label": "aaa",
                            "count_dev_idle": 143128.0,
                            "event_time__epoch": 1698423836.0,
                            "moving": true,
                            "count_dev_dist": 18836063.0,
                            "lat": 4.81697,
                            "valid_gps": true,
                            "io_ign": false,
                            "count_dev_ign": 184649533.0
                        }
                    },
                    {
                        "start_event": {
                            "lon": -74.03717,
                            "mph": 0.0,
                            "label": "ignon",
                            "event_time__epoch": 1698423828.0,
                            "moving": false,
                            "lat": 4.81695,
                            "valid_gps": true,
                            "io_ign": true
                        },
                        "end_event": {
                            "lon": -74.03722,
                            "mph": 3.1,
                            "label": "aaa",
                            "count_dev_idle": 143128.0,
                            "event_time__epoch": 1698424641.0,
                            "moving": true,
                            "count_dev_dist": 18836206.0,
                            "lat": 4.81725,
                            "valid_gps": true,
                            "io_ign": true,
                            "count_dev_ign": 184650338.0
                        }
                    },
                    {
                        "start_event": {
                            "lon": -74.03762,
                            "mph": 2.5,
                            "label": "aaa",
                            "count_dev_idle": 143128.0,
                            "event_time__epoch": 1698424693.0,
                            "moving": false,
                            "count_dev_dist": 18836359.0,
                            "lat": 4.81685,
                            "valid_gps": true,
                            "io_ign": true,
                            "count_dev_ign": 184650390.0
                        },
                        "end_event": {
                            "lon": -74.03756,
                            "mph": 3.7,
                            "label": "aaa",
                            "count_dev_idle": 143128.0,
                            "event_time__epoch": 1698425313.0,
                            "moving": true,
                            "count_dev_dist": 18836566.0,
                            "lat": 4.8168,
                            "valid_gps": true,
                            "io_ign": true,
                            "count_dev_ign": 184651010.0
                        }
                    },
                    {
                        "start_event": {
                            "lon": -74.03625,
                            "mph": 1.2,
                            "label": "aaa",
                            "event_time__epoch": 1698425399.0,
                            "moving": false,
                            "lat": 4.81568,
                            "valid_gps": true,
                            "io_ign": true
                        },
                        "end_event": {
                            "lon": -74.03726,
                            "mph": 7.5,
                            "label": "aaa",
                            "event_time__epoch": 1698425784.0,
                            "moving": true,
                            "lat": 4.80684,
                            "valid_gps": true,
                            "io_ign": true
                        }
                    },
                    {
                        "start_event": {
                            "lon": -74.04442,
                            "mph": 0.0,
                            "label": "aaa",
                            "count_dev_idle": 143128.0,
                            "event_time__epoch": 1698429619.0,
                            "moving": false,
                            "count_dev_dist": 18848731.0,
                            "lat": 4.85131,
                            "valid_gps": true,
                            "io_ign": true,
                            "count_dev_ign": 184655301.0
                        },
                        "end_event": {
                            "lon": -74.044,
                            "mph": 3.1,
                            "label": "aaa",
                            "count_dev_idle": 143158.0,
                            "event_time__epoch": 1698431725.0,
                            "moving": true,
                            "count_dev_dist": 18849104.0,
                            "lat": 4.85113,
                            "valid_gps": true,
                            "io_ign": true,
                            "count_dev_ign": 184657387.0
                        }
                    },
                    {
                        "start_event": {
                            "lon": -74.04317,
                            "mph": 0.0,
                            "label": "aaa",
                            "count_dev_idle": 143158.0,
                            "event_time__epoch": 1698432209.0,
                            "moving": false,
                            "count_dev_dist": 18849578.0,
                            "lat": 4.8529,
                            "valid_gps": true,
                            "io_ign": true,
                            "count_dev_ign": 184657867.0
                        },
                        "end_event": {
                            "lon": -74.0431,
                            "mph": 3.1,
                            "label": "aaa",
                            "count_dev_idle": 143158.0,
                            "event_time__epoch": 1698432846.0,
                            "moving": true,
                            "count_dev_dist": 18849591.0,
                            "lat": 4.85293,
                            "valid_gps": true,
                            "io_ign": true,
                            "count_dev_ign": 184658503.0
                        }
                    },
                    {
                        "start_event": {
                            "lon": -74.04422,
                            "mph": 1.9,
                            "label": "aaa",
                            "count_dev_idle": 143158.0,
                            "event_time__epoch": 1698433479.0,
                            "moving": false,
                            "count_dev_dist": 18849741.0,
                            "lat": 4.85365,
                            "valid_gps": true,
                            "io_ign": true,
                            "count_dev_ign": 184659137.0
                        },
                        "end_event": {
                            "lon": -74.04448,
                            "mph": 5.0,
                            "label": "aaa",
                            "count_dev_idle": 143158.0,
                            "event_time__epoch": 1698434214.0,
                            "moving": true,
                            "count_dev_dist": 18849783.0,
                            "lat": 4.85367,
                            "valid_gps": true,
                            "io_ign": true,
                            "count_dev_ign": 184659871.0
                        }
                    }
                ],
                "secondary_id": 2142,
                "min_rest_hours": 4,
                "max_work_hours": 8,
                "state": "working",
                "end_time": 1698435542.366268,
                "max_continuous_work_hours": 2,
                "device": 866771027161925,
                "start_event": {
                    "lon": -74.03712,
                    "mph": 3.1,
                    "label": "aaa",
                    "count_dev_idle": 142952.0,
                    "event_time__epoch": 1698404146.0,
                    "moving": true,
                    "count_dev_dist": 18802100.0,
                    "lat": 4.81719,
                    "valid_gps": true,
                    "io_ign": true,
                    "count_dev_ign": 184629856.0
                },
                "min_break_hours": 0.1,
                "signal": "moving",
                "resting_start_event": {
                    "$forced": true,
                    "lon": 4.82651,
                    "mph": null,
                    "label": "aaa",
                    "count_dev_idle": 143158.0,
                    "event_time__epoch": 1698435542.366268,
                    "moving": null,
                    "count_dev_dist": 17318739,
                    "lat": 4.82651,
                    "valid_gps": true,
                    "io_ign": true,
                    "count_dev_ign": 29037750
                }
            }
        }
    ],
    "sections": 1
}

In this example, the next event generated by the vehicle was a motion event, which indicates that the vehicle is still working, so a new working segment that belongs to another cycle is created. When this new segment is automatically completed, we have something like this

segments?partition=entity_hos&from=2023-10-27T10:00:00&to=2023-10-28T00:00:00&entities=459

{
    "count": 3,
    "query": {
        "groups": null,
        "offset": 0,
        "data": null,
        "from": "2023-10-27T10:00:00+00:00",
        "entities": [
            459
        ],
        "section": 1,
        "partition": "entity_hos",
        "ids": null,
        "to": "2023-10-28T00:00:00+00:00",
        "limit": 100
    },
    "total": 3,
    "data": [
        {
            "uuid": "d1981395-cf9a-4f2d-9630-9944dd5ea8cd",
            "start_time": "2023-10-27T19:30:18+00:00",
            "partition": "entity_hos",
            "end_time": "2023-10-28T05:46:56+00:00",
            "identifier": "459",
            "data": {
                "resting_start": 1698453990.0,
                "entity_id": 459,
                "start_time": 1698435018.0,
                "end_event": {
                    "lon": -74.03672,
                    "mph": 0.0,
                    "label": "aaa",
                    "count_dev_idle": 143164.0,
                    "event_time__epoch": 1698472016.0,
                    "moving": false,
                    "count_dev_dist": 18879172.0,
                    "lat": 4.81661,
                    "valid_gps": true,
                    "io_ign": false,
                    "count_dev_ign": 184697633.0
                },
                "breaks": [
                    {
                        "start_event": {
                            "lon": -74.03717,
                            "mph": 0.0,
                            "label": "aaa",
                            "count_dev_idle": 143158.0,
                            "event_time__epoch": 1698440995.0,
                            "moving": false,
                            "count_dev_dist": 18859311.0,
                            "lat": 4.8172,
                            "valid_gps": true,
                            "io_ign": true,
                            "count_dev_ign": 184666653.0
                        },
                        "end_event": {
                            "lon": -74.0372,
                            "mph": 4.3,
                            "label": "aaa",
                            "count_dev_idle": 143158.0,
                            "event_time__epoch": 1698441702.0,
                            "moving": true,
                            "count_dev_dist": 18859343.0,
                            "lat": 4.81714,
                            "valid_gps": true,
                            "io_ign": true,
                            "count_dev_ign": 184667361.0
                        }
                    },
                    {
                        "start_event": {
                            "lon": -74.03736,
                            "mph": 0.0,
                            "label": "aaa",
                            "count_dev_idle": 143158.0,
                            "event_time__epoch": 1698441866.0,
                            "moving": false,
                            "count_dev_dist": 18859392.0,
                            "lat": 4.81737,
                            "valid_gps": true,
                            "io_ign": true,
                            "count_dev_ign": 184667525.0
                        },
                        "end_event": {
                            "lon": -74.03735,
                            "mph": 3.7,
                            "label": "aaa",
                            "count_dev_idle": 143158.0,
                            "event_time__epoch": 1698442471.0,
                            "moving": true,
                            "count_dev_dist": 18859553.0,
                            "lat": 4.8173,
                            "valid_gps": true,
                            "io_ign": true,
                            "count_dev_ign": 184668129.0
                        }
                    },
                    {
                        "start_event": {
                            "lon": -74.03762,
                            "mph": 1.9,
                            "label": "aaa",
                            "count_dev_idle": 143158.0,
                            "event_time__epoch": 1698442495.0,
                            "moving": false,
                            "count_dev_dist": 18859594.0,
                            "lat": 4.81703,
                            "valid_gps": true,
                            "io_ign": true,
                            "count_dev_ign": 184668154.0
                        },
                        "end_event": {
                            "lon": -74.03768,
                            "mph": 3.7,
                            "label": "aaa",
                            "count_dev_idle": 143158.0,
                            "event_time__epoch": 1698442920.0,
                            "moving": true,
                            "count_dev_dist": 18859716.0,
                            "lat": 4.81705,
                            "valid_gps": true,
                            "io_ign": true,
                            "count_dev_ign": 184668578.0
                        }
                    },
                    {
                        "start_event": {
                            "lon": -74.04323,
                            "mph": 2.5,
                            "label": "aaa",
                            "count_dev_idle": 143158.0,
                            "event_time__epoch": 1698445183.0,
                            "moving": false,
                            "count_dev_dist": 18864338.0,
                            "lat": 4.77578,
                            "valid_gps": true,
                            "io_ign": true,
                            "count_dev_ign": 184670831.0
                        },
                        "end_event": {
                            "lon": -74.04397,
                            "mph": 3.1,
                            "label": "aaa",
                            "count_dev_idle": 143158.0,
                            "event_time__epoch": 1698445629.0,
                            "moving": true,
                            "count_dev_dist": 18864485.0,
                            "lat": 4.77519,
                            "valid_gps": true,
                            "io_ign": true,
                            "count_dev_ign": 184671273.0
                        }
                    },
                    {
                        "start_event": {
                            "lon": -74.04421,
                            "mph": 2.5,
                            "label": "aaa",
                            "count_dev_idle": 143158.0,
                            "event_time__epoch": 1698445983.0,
                            "moving": false,
                            "count_dev_dist": 18864607.0,
                            "lat": 4.77516,
                            "valid_gps": true,
                            "io_ign": true,
                            "count_dev_ign": 184671623.0
                        },
                        "end_event": {
                            "lon": -74.04471,
                            "mph": 3.1,
                            "label": "aaa",
                            "count_dev_idle": 143158.0,
                            "event_time__epoch": 1698447109.0,
                            "moving": true,
                            "count_dev_dist": 18864703.0,
                            "lat": 4.77535,
                            "valid_gps": true,
                            "io_ign": true,
                            "count_dev_ign": 184672745.0
                        }
                    },
                    {
                        "start_event": {
                            "lon": -74.04461,
                            "mph": 0.0,
                            "label": "aaa",
                            "count_dev_idle": 143158.0,
                            "event_time__epoch": 1698447277.0,
                            "moving": false,
                            "count_dev_dist": 18864749.0,
                            "lat": 4.77511,
                            "valid_gps": true,
                            "io_ign": true,
                            "count_dev_ign": 184672912.0
                        },
                        "end_event": {
                            "lon": -74.04456,
                            "mph": 3.1,
                            "label": "aaa",
                            "count_dev_idle": 143158.0,
                            "event_time__epoch": 1698448659.0,
                            "moving": true,
                            "count_dev_dist": 18864797.0,
                            "lat": 4.77526,
                            "valid_gps": true,
                            "io_ign": true,
                            "count_dev_ign": 184674294.0
                        }
                    },
                    {
                        "start_event": {
                            "lon": -74.04466,
                            "mph": 0.6,
                            "label": "aaa",
                            "count_dev_idle": 143164.0,
                            "event_time__epoch": 1698448773.0,
                            "moving": false,
                            "count_dev_dist": 18864842.0,
                            "lat": 4.77521,
                            "valid_gps": true,
                            "io_ign": true,
                            "count_dev_ign": 184674409.0
                        },
                        "end_event": {
                            "lon": -74.04381,
                            "mph": 3.1,
                            "label": "aaa",
                            "count_dev_idle": 143164.0,
                            "event_time__epoch": 1698449896.0,
                            "moving": true,
                            "count_dev_dist": 18865088.0,
                            "lat": 4.77518,
                            "valid_gps": true,
                            "io_ign": true,
                            "count_dev_ign": 184675531.0
                        }
                    },
                    {
                        "start_event": {
                            "lon": -74.04378,
                            "mph": 0.0,
                            "label": "aaa",
                            "count_dev_idle": 143164.0,
                            "event_time__epoch": 1698450268.0,
                            "moving": false,
                            "count_dev_dist": 18865207.0,
                            "lat": 4.77558,
                            "valid_gps": true,
                            "io_ign": true,
                            "count_dev_ign": 184675904.0
                        },
                        "end_event": {
                            "lon": -74.04344,
                            "mph": 3.1,
                            "label": "aaa",
                            "count_dev_idle": 143164.0,
                            "event_time__epoch": 1698450632.0,
                            "moving": true,
                            "count_dev_dist": 18865270.0,
                            "lat": 4.7756,
                            "valid_gps": true,
                            "io_ign": true,
                            "count_dev_ign": 184676268.0
                        }
                    },
                    {
                        "start_event": {
                            "lon": -74.03755,
                            "mph": 1.2,
                            "label": "aaa",
                            "count_dev_idle": 143164.0,
                            "event_time__epoch": 1698452976.0,
                            "moving": false,
                            "count_dev_dist": 18878732.0,
                            "lat": 4.81683,
                            "valid_gps": true,
                            "io_ign": true,
                            "count_dev_ign": 184678613.0
                        },
                        "end_event": {
                            "lon": -74.03764,
                            "mph": 5.0,
                            "label": "aaa",
                            "count_dev_idle": 143164.0,
                            "event_time__epoch": 1698453360.0,
                            "moving": true,
                            "count_dev_dist": 18878838.0,
                            "lat": 4.81645,
                            "valid_gps": true,
                            "io_ign": true,
                            "count_dev_ign": 184678996.0
                        }
                    },
                    {
                        "start_event": {
                            "lon": -74.03778,
                            "mph": 1.2,
                            "label": "aaa",
                            "count_dev_idle": 143164.0,
                            "event_time__epoch": 1698453509.0,
                            "moving": false,
                            "count_dev_dist": 18878939.0,
                            "lat": 4.81679,
                            "valid_gps": true,
                            "io_ign": true,
                            "count_dev_ign": 184679145.0
                        },
                        "end_event": {
                            "lon": -74.03749,
                            "mph": 3.1,
                            "label": "aaa",
                            "count_dev_idle": 143164.0,
                            "event_time__epoch": 1698453911.0,
                            "moving": true,
                            "count_dev_dist": 18879058.0,
                            "lat": 4.81671,
                            "valid_gps": true,
                            "io_ign": true,
                            "count_dev_ign": 184679547.0
                        }
                    }
                ],
                "secondary_id": 2142,
                "min_rest_hours": 4,
                "max_work_hours": 8,
                "state": "working",
                "end_time": 1698472016.0,
                "max_continuous_work_hours": 2,
                "device": 866771027161925,
                "start_event": {
                    "lon": -74.03044,
                    "mph": 36.7,
                    "label": "aaa",
                    "event_time__epoch": 1698435018.0,
                    "moving": true,
                    "lat": 4.8508,
                    "valid_gps": true,
                    "io_ign": true
                },
                "min_break_hours": 0.1,
                "signal": "moving",
                "resting_start_event": {
                    "lon": -74.03704,
                    "mph": 0.0,
                    "label": "aaa",
                    "count_dev_idle": 143164.0,
                    "event_time__epoch": 1698453990.0,
                    "moving": false,
                    "count_dev_dist": 18879141.0,
                    "lat": 4.81661,
                    "valid_gps": true,
                    "io_ign": true,
                    "count_dev_ign": 184679626.0
                }
            }
        },
        {
            "uuid": "04865143-176f-4176-9f38-61df28069279",
            "start_time": "2023-10-27T10:55:46+00:00",
            "partition": "entity_hos",
            "end_time": "2023-10-27T19:39:02.366268+00:00",
            "identifier": "459",
            "data": {
                "resting_start": 1698435542.366268,
                "entity_id": 459,
                "start_time": 1698404146.0,
                "end_event": {
                    "$forced": true,
                    "lon": 4.82651,
                    "mph": null,
                    "label": "aaa",
                    "count_dev_idle": 143158.0,
                    "event_time__epoch": 1698435542.366268,
                    "moving": null,
                    "count_dev_dist": 17318739,
                    "lat": 4.82651,
                    "valid_gps": true,
                    "io_ign": true,
                    "count_dev_ign": 29037750
                },
                "breaks": [
                    {
                        "start_event": {
                            "lon": -74.03691,
                            "mph": 0.0,
                            "label": "aaa",
                            "count_dev_idle": 143088.0,
                            "event_time__epoch": 1698410430.0,
                            "moving": false,
                            "count_dev_dist": 18803383.0,
                            "lat": 4.81659,
                            "valid_gps": true,
                            "io_ign": true,
                            "count_dev_ign": 184636129.0
                        },
                        "end_event": {
                            "lon": -74.03698,
                            "mph": 7.5,
                            "label": "aaa",
                            "count_dev_idle": 143103.0,
                            "event_time__epoch": 1698411014.0,
                            "moving": true,
                            "count_dev_dist": 18803387.0,
                            "lat": 4.81658,
                            "valid_gps": true,
                            "io_ign": true,
                            "count_dev_ign": 184636713.0
                        }
                    },
                    {
                        "start_event": {
                            "lon": -74.05419,
                            "mph": 0.0,
                            "label": "aaa",
                            "count_dev_idle": 143128.0,
                            "event_time__epoch": 1698415197.0,
                            "moving": false,
                            "count_dev_dist": 18818195.0,
                            "lat": 4.69393,
                            "valid_gps": true,
                            "io_ign": true,
                            "count_dev_ign": 184640897.0
                        },
                        "end_event": {
                            "lon": -74.05428,
                            "mph": 3.1,
                            "label": "aaa",
                            "count_dev_idle": 143128.0,
                            "event_time__epoch": 1698416811.0,
                            "moving": true,
                            "count_dev_dist": 18818547.0,
                            "lat": 4.69399,
                            "valid_gps": true,
                            "io_ign": true,
                            "count_dev_ign": 184642509.0
                        }
                    },
                    {
                        "start_event": {
                            "lon": -74.03743,
                            "mph": 0.6,
                            "label": "aaa",
                            "count_dev_idle": 143128.0,
                            "event_time__epoch": 1698420759.0,
                            "moving": false,
                            "count_dev_dist": 18835848.0,
                            "lat": 4.81682,
                            "valid_gps": true,
                            "io_ign": true,
                            "count_dev_ign": 184646456.0
                        },
                        "end_event": {
                            "lon": -74.03722,
                            "mph": 3.1,
                            "label": "aaa",
                            "count_dev_idle": 143128.0,
                            "event_time__epoch": 1698421251.0,
                            "moving": true,
                            "count_dev_dist": 18835942.0,
                            "lat": 4.81675,
                            "valid_gps": true,
                            "io_ign": true,
                            "count_dev_ign": 184646947.0
                        }
                    },
                    {
                        "start_event": {
                            "lon": -74.03725,
                            "mph": 1.2,
                            "label": "aaa",
                            "count_dev_idle": 143128.0,
                            "event_time__epoch": 1698421330.0,
                            "moving": false,
                            "count_dev_dist": 18836051.0,
                            "lat": 4.81696,
                            "valid_gps": true,
                            "io_ign": true,
                            "count_dev_ign": 184647027.0
                        },
                        "end_event": {
                            "lon": -74.03718,
                            "mph": 3.7,
                            "label": "aaa",
                            "count_dev_idle": 143128.0,
                            "event_time__epoch": 1698423836.0,
                            "moving": true,
                            "count_dev_dist": 18836063.0,
                            "lat": 4.81697,
                            "valid_gps": true,
                            "io_ign": false,
                            "count_dev_ign": 184649533.0
                        }
                    },
                    {
                        "start_event": {
                            "lon": -74.03717,
                            "mph": 0.0,
                            "label": "ignon",
                            "event_time__epoch": 1698423828.0,
                            "moving": false,
                            "lat": 4.81695,
                            "valid_gps": true,
                            "io_ign": true
                        },
                        "end_event": {
                            "lon": -74.03722,
                            "mph": 3.1,
                            "label": "aaa",
                            "count_dev_idle": 143128.0,
                            "event_time__epoch": 1698424641.0,
                            "moving": true,
                            "count_dev_dist": 18836206.0,
                            "lat": 4.81725,
                            "valid_gps": true,
                            "io_ign": true,
                            "count_dev_ign": 184650338.0
                        }
                    },
                    {
                        "start_event": {
                            "lon": -74.03762,
                            "mph": 2.5,
                            "label": "aaa",
                            "count_dev_idle": 143128.0,
                            "event_time__epoch": 1698424693.0,
                            "moving": false,
                            "count_dev_dist": 18836359.0,
                            "lat": 4.81685,
                            "valid_gps": true,
                            "io_ign": true,
                            "count_dev_ign": 184650390.0
                        },
                        "end_event": {
                            "lon": -74.03756,
                            "mph": 3.7,
                            "label": "aaa",
                            "count_dev_idle": 143128.0,
                            "event_time__epoch": 1698425313.0,
                            "moving": true,
                            "count_dev_dist": 18836566.0,
                            "lat": 4.8168,
                            "valid_gps": true,
                            "io_ign": true,
                            "count_dev_ign": 184651010.0
                        }
                    },
                    {
                        "start_event": {
                            "lon": -74.03625,
                            "mph": 1.2,
                            "label": "aaa",
                            "event_time__epoch": 1698425399.0,
                            "moving": false,
                            "lat": 4.81568,
                            "valid_gps": true,
                            "io_ign": true
                        },
                        "end_event": {
                            "lon": -74.03726,
                            "mph": 7.5,
                            "label": "aaa",
                            "event_time__epoch": 1698425784.0,
                            "moving": true,
                            "lat": 4.80684,
                            "valid_gps": true,
                            "io_ign": true
                        }
                    },
                    {
                        "start_event": {
                            "lon": -74.04442,
                            "mph": 0.0,
                            "label": "aaa",
                            "count_dev_idle": 143128.0,
                            "event_time__epoch": 1698429619.0,
                            "moving": false,
                            "count_dev_dist": 18848731.0,
                            "lat": 4.85131,
                            "valid_gps": true,
                            "io_ign": true,
                            "count_dev_ign": 184655301.0
                        },
                        "end_event": {
                            "lon": -74.044,
                            "mph": 3.1,
                            "label": "aaa",
                            "count_dev_idle": 143158.0,
                            "event_time__epoch": 1698431725.0,
                            "moving": true,
                            "count_dev_dist": 18849104.0,
                            "lat": 4.85113,
                            "valid_gps": true,
                            "io_ign": true,
                            "count_dev_ign": 184657387.0
                        }
                    },
                    {
                        "start_event": {
                            "lon": -74.04317,
                            "mph": 0.0,
                            "label": "aaa",
                            "count_dev_idle": 143158.0,
                            "event_time__epoch": 1698432209.0,
                            "moving": false,
                            "count_dev_dist": 18849578.0,
                            "lat": 4.8529,
                            "valid_gps": true,
                            "io_ign": true,
                            "count_dev_ign": 184657867.0
                        },
                        "end_event": {
                            "lon": -74.0431,
                            "mph": 3.1,
                            "label": "aaa",
                            "count_dev_idle": 143158.0,
                            "event_time__epoch": 1698432846.0,
                            "moving": true,
                            "count_dev_dist": 18849591.0,
                            "lat": 4.85293,
                            "valid_gps": true,
                            "io_ign": true,
                            "count_dev_ign": 184658503.0
                        }
                    },
                    {
                        "start_event": {
                            "lon": -74.04422,
                            "mph": 1.9,
                            "label": "aaa",
                            "count_dev_idle": 143158.0,
                            "event_time__epoch": 1698433479.0,
                            "moving": false,
                            "count_dev_dist": 18849741.0,
                            "lat": 4.85365,
                            "valid_gps": true,
                            "io_ign": true,
                            "count_dev_ign": 184659137.0
                        },
                        "end_event": {
                            "lon": -74.04448,
                            "mph": 5.0,
                            "label": "aaa",
                            "count_dev_idle": 143158.0,
                            "event_time__epoch": 1698434214.0,
                            "moving": true,
                            "count_dev_dist": 18849783.0,
                            "lat": 4.85367,
                            "valid_gps": true,
                            "io_ign": true,
                            "count_dev_ign": 184659871.0
                        }
                    }
                ],
                "secondary_id": 2142,
                "min_rest_hours": 4,
                "max_work_hours": 8,
                "state": "working",
                "end_time": 1698435542.366268,
                "max_continuous_work_hours": 2,
                "device": 866771027161925,
                "start_event": {
                    "lon": -74.03712,
                    "mph": 3.1,
                    "label": "aaa",
                    "count_dev_idle": 142952.0,
                    "event_time__epoch": 1698404146.0,
                    "moving": true,
                    "count_dev_dist": 18802100.0,
                    "lat": 4.81719,
                    "valid_gps": true,
                    "io_ign": true,
                    "count_dev_ign": 184629856.0
                },
                "min_break_hours": 0.1,
                "signal": "moving",
                "resting_start_event": {
                    "$forced": true,
                    "lon": 4.82651,
                    "mph": null,
                    "label": "aaa",
                    "count_dev_idle": 143158.0,
                    "event_time__epoch": 1698435542.366268,
                    "moving": null,
                    "count_dev_dist": 17318739,
                    "lat": 4.82651,
                    "valid_gps": true,
                    "io_ign": true,
                    "count_dev_ign": 29037750
                }
            }
        }

Note that we have two continuous working segments. The first one (the recent one) is a working segment that was automatically completed because it reached the configured min_rest_hours and belongs to one cycle. The second one is a working segment that we manually closed and belongs to a different cycle. In this example, the cycle corresponding to the manually closed segment has only this segment.

If the next event generated by the vehicle had been a rest instead of movement, then the new segment would have been resting.

In the case of a disconnected entity, in the API the current segment will remain in the "working" state. When the device reconnects, all buffered events will be received and the segments will be updated based on this data.

🚧

Unlink a driver from a vehicle

A vehicle can have several drivers associated with it. Pegasus records the vehicle data and the associated drivers can see that data. If a driver disassociates from a vehicle that is in working state, the driver will continue to see the vehicle's data during the time specified in min_rest hours.