update_units
To add, remove, or clear units monitored in the session, use the events/update_units method.
To monitor resources as well as units, use events/update_items. For new integrations, use events/update_items.
Endpoint
The request format depends on the operation mode.
Adding units
To add specific units to the session, use the following request:
svc=events/update_units¶ms={
"mode": "add",
"units": [
{
"id": <long>,
"detect": {
"<detector_name>": <long>
}
},
...
],
"evt_flags": <uint> /* optional */
}
Removing specific units
To remove specific units from the session, use the following request:
svc=events/update_units¶ms={
"mode": "remove",
"units": [
<long>
]
}
Removing all units
To remove all units from the session, use the following request:
svc=events/update_units¶ms={
"mode": "clear"
}
Parameters
| Parameter | Description |
|---|---|
mode |
Required. Operation mode: add, remove, or clear. |
units |
Required for add and remove. Array of unit objects (for add) or unit IDs (for remove). |
id |
Required for add. Unit ID. |
detect |
Required for add. Detectors to monitor and their filters. See the Event detector types section. |
evt_flags |
Optional. Event flags. See the Event flags section. |
Event detector types
The following event detectors can be configured in the detect object. For each detector, specify a filter value that selects the events to monitor: a specific ID or type, or 0 to monitor all events of this detector.
"detect":{"<detector_name>":<filter_value>}
| Detector | Events | Filter value |
|---|---|---|
trips |
Trips and parking events. | 0 |
counters |
Engine hours, mileage, and GPRS traffic counter events. | 0 |
speedings |
Speeding events. | 0 |
ignition |
Ignition sensor events. | Sensor ID, or 0 for all sensors of this type. |
sensors |
Events from sensors other than ignition, fuel level, and battery level sensors. | Sensor ID, or 0 for all sensors of this type. |
lls |
Fuel level sensor events. | Fuel level sensor ID, or 0 for all fuel level sensors. |
filling |
Fuel filling events. | Fuel level sensor ID, or 0 for all fuel level sensors. |
theft |
Fuel drain events. | Fuel level sensor ID, or 0 for all fuel level sensors. |
fuel_level |
Fuel level events. | Fuel level sensor ID, or 0 for all fuel level sensors. |
battery_level |
Battery level events (processed and raw battery level values). | Battery level sensor ID, or 0 for all battery level sensors. |
charge |
Battery charge events (charge volume changes). | Battery level sensor ID, or 0 for all battery level sensors. |
ev |
Combined detector for electric vehicle batteries. Registers both battery level and charge events. | Battery level sensor ID, or 0 for all battery level sensors. |
health_check |
Health check incidents. | Incident type, or 0 for all incidents. |
eco_driving |
Eco driving violations. | Criterion type (1 acceleration, 2 brake, 3 turn, 4 speeding, 5 sensor, 6 smoothness, 7 idling), or 0 for all criteria. |
The table lists the detectors available for units. To monitor driver assignments registered on a resource, use the
resource_driversdetector with events/update_items and specify a resource ID.
The battery_level, charge, and ev detectors use the following battery level sensor settings: Calculate data by the sensor, Filtering type, Minimum charge volume (kWh), Detect charges only during stops, and Timeout to separate consecutive charges. If Calculate data by the sensor is disabled, no events are registered for the sensor.
The detectors register battery level and charges, but not battery discharges. The math consumption model, engine sensors, and temperature coefficient sensors aren’t taken into account.
The
eco_drivingdetector isn’t available in Wialon Local.
To add all available event detectors, use:
"detect":{"*":0}
In add mode, only units to which the current user has view access are added. If a listed unit is already monitored, its detector configuration is replaced. Invalid individual detector filter values are ignored.
Event flags
The evt_flags parameter is stored in the session and controls how event updates are delivered. Its default value is 0.
| Value | Name | Description |
|---|---|---|
0 |
check_updates |
Default mode. The events/check_updates method polls detectors and returns event data. |
0x200 |
units_update |
Event updates are sent automatically in the units_update data of avl_evts. In this mode, events/check_updates returns {}. Combine it with detail flags in bits 0x1 through 0x100. |
Combine the detail flags below with 0x200. If no detail flags are specified, the value 0x7 is used (0x1 | 0x2 | 0x4).
| Value | Description |
|---|---|
0x1 |
Basic event data. |
0x2 |
Detector-specific data. |
0x4 |
Parameters from the message associated with the event. |
0x8 |
Additional detail data. |
0x10 |
Detailed message data. |
0x20 |
Formatted detector values. |
0x40 |
Group results by intersection intervals. |
0x80 |
Detector summary data. |
0x100 |
Extended events. |
For example, evt_flags = 0x207 enables the units_update mode (0x200) with basic event data, detector-specific data, and visible message parameters (0x1 | 0x2 | 0x4 = 0x7).
Examples
The following examples show how to set the detect object when adding units to the session.
Adding all sensors of a type
To monitor events from all ignition sensors and all other sensors of the unit with ID 1001, use one of the following requests:
svc=events/update_units¶ms={
"mode": "add",
"units": [
{
"id": 1001,
"detect": {
"ignition": 0,
"sensors": 0
}
}
]
}
svc=events/update_units¶ms={
"mode": "add",
"units": [
{
"id": 1001,
"detect": {
"ignition,sensors": 0
}
}
]
}
Adding specific sensors
To monitor events from the fuel level sensor with ID 2 and another sensor with ID 6, use the following request:
svc=events/update_units¶ms={
"mode": "add",
"units": [
{
"id": 1001,
"detect": {
"lls": 2,
"sensors": 6
}
}
]
}
Response
If the request is completed successfully, the following response is returned:
{
"units": <uint> /* total number of units monitored in the session */
}
Otherwise, an error code is returned.
Error codes
| Code | Description |
|---|---|
| 1 | Invalid or obsolete request SID. |
| 4 | Parameter validation error. |
| 7 | The event service is unavailable. |