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 and fuel 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). | Sensor ID, or 0 for all sensors of this type. |
charge |
Battery charge events (charge volume changes). | Sensor ID, or 0 for all sensors of this type. |
ev |
Combined electric vehicle battery detector (returns EV battery events, including battery_level and charge). |
Sensor ID, or 0 for all sensors of this type. |
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
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 session’s units_update data. 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. |