update_items

To add, remove, or clear items monitored in the session, use the events/update_items method. Items can be units or resources. For the available detectors, see the Detectors section.

Event updates are delivered either in the units_update data of avl_evts or through events/check_updates, depending on the event flags.

If you monitor only units, you can also use events/update_units, but for new integrations use events/update_items.

Endpoint

The request format depends on the operation mode.

To add items to the session and set the detectors to monitor for each of them:

Copied!
svc=events/update_items&params={
  "mode": "add",
  "items": [
    {
      "id": <long>,
      "detect": {
        "<detector_name>": <long>
      }
    },
    ...
  ],
  "evt_flags": <uint>   /* optional */
}

To stop monitoring events for specific items:

Copied!
svc=events/update_items&params={
  "mode": "remove",
  "items": [
    <long>
  ]
}

To stop monitoring events for all items in the session:

Copied!
svc=events/update_items&params={
  "mode": "clear"
}

To get the items in the session and their detector settings:

Copied!
svc=events/update_items&params={
  "mode": "list"
}

Parameters

The request can contain the following parameters:

Parameter Description
mode Required. Operation mode: add, remove, clear, or list.
items Required for add and remove. Items to add or remove.
id Required for add. Item ID: a unit ID or a resource ID.
detect Required for add. Detectors to monitor and their filters. See the Detectors section.
evt_flags Optional. Event flags. See the Event flags section.

In add mode, only the items to which the current user has view access are added. If a listed item is already monitored, its detector configuration is replaced. Invalid individual detector filter values are ignored.

Detectors

The detect parameter defines which detectors are monitored in the session. For each detector, specify a filter value that selects the events to monitor. The available detectors depend on the item type.

Item type Detectors
Unit All unit event detectors. For the full list and the filter values, see the Event detector types section on the events/update_units page. Use the filter value to select the events:
  • For sensor-based detectors (sensors, ignition, lls, filling, theft, fuel_level, ev, charge, battery_level), specify a sensor ID, or 0 to monitor all sensors of that detector’s type. The lls, filling, theft, and fuel_level detectors use the fuel level sensor ID.
  • For eco_driving, specify a criterion ID, or 0 to monitor all criteria.
  • For trips, counters, and speedings, use 0.
Resource The resource_drivers detector, which registers events about driver assignments. Specify a driver ID to monitor assignments of this driver, or 0 to monitor assignments of all drivers of the resource.

To monitor several detectors with the same filter, list them separated by commas:

Copied!
"detect":{"sensors,lls,ignition":0}

To monitor all detectors available for the item, use the value *. For a unit, it covers all unit detectors; for a resource, all detectors available for resources, currently resource_drivers.

Copied!
"detect":{"*":0}

Event flags

The evt_flags value is stored in the session, so it’s enough to set it once. The default value is 0, which means the updates are retrieved with events/check_updates.

To receive event updates in the units_update data of avl_evts, set the delivery flag 0x200 (512). You can combine it with the detail flags in bits 0x1 to 0x100. If no detail flags are specified, the value 0x7 is used, which returns basic event data, detector-specific data, and parameters of the message associated with the event.

When the 0x200 flag is set, events/check_updates returns an empty object. To retrieve updates with events/check_updates, don’t set this flag.

Response

If the request is completed successfully, the response format depends on the operation mode. Otherwise, an error code is returned.

For the add, remove, and clear modes, the total number of monitored items is returned:

Copied!
{
  "items": <uint>   /* total number of items monitored in the session; 0 after the clear mode */
}

For the list mode, the monitored items and their detector settings are returned. The evt_flags field is returned only if event flags are set in the session.

Copied!
{
  "items": [
    {
      "id": <long>,          /* item ID */
      "detect": {
        "<detector_name>": <long>   /* detector filter */
      }
    },
    ...
  ],
  "evt_flags": <uint>
}

Error codes

Code Description
1 Invalid or obsolete request SID.
4 Parameter validation error.
7 The event service is unavailable.

Examples

The following examples show the most common operations with the method.

Subscribing to driver assignment events

To monitor assignments of all drivers of the resource with ID 1003, use the following request:

Copied!
svc=events/update_items&params={
  "mode": "add",
  "items": [
    {
      "id": 1003,
      "detect": {
        "resource_drivers": 0
      }
    }
  ]
}

Response:

Copied!
{
  "items": 1
}

To get the updates, call events/check_updates.

Receiving updates in avl_evts

In the following request, the evt_flags value 0x222 (546) combines the delivery flag 0x200 with the detail flags 0x2 (detector-specific data) and 0x20 (formatted detector values).

Copied!
svc=events/update_items&params={
  "mode": "add",
  "items": [
    {
      "id": 1003,
      "detect": {
        "resource_drivers": 0
      }
    }
  ],
  "evt_flags": 546
}

The updates are returned in the units_update data of avl_evts, grouped by item ID, detector, and driver ID. For the structure of the event objects, see events/check_updates.

Response
Copied!
{
  "tm": 1732710040,
  "events": [],
  "units_update": {
    "1003": [
      {
        "resource_drivers": {
          "1": {
            "from": {
              "t": 1732637187,
              "y": 0,
              "x": 0
            },
            "to": {
              "t": 1732637187,
              "y": 0,
              "x": 0
            },
            "m": 1732637187,
            "f": 0,
            "state": 1,
            "aflags": 4,
            "unit_id": 1633,
            "format": {
              "propitem_name": "driver4_1"
            }
          }
        }
      }
    ]
  }
}

Getting the list of monitored items

To check which items are monitored in the session, use the following request:

Copied!
svc=events/update_items&params={
  "mode": "list"
}

The response shows that two units and all drivers of the resource with ID 1003 are monitored:

Copied!
{
  "items": [
    {
      "id": 1026,
      "detect": {
        "sensors,lls,ignition,ev,health_check": 0
      }
    },
    {
      "id": 1082,
      "detect": {
        "sensors,lls,ignition,ev,health_check": 0
      }
    },
    {
      "id": 1003,
      "detect": {
        "resource_drivers": 0
      }
    }
  ],
  "evt_flags": 546
}

If you find a mistake in the text, please select it and press Ctrl+Enter.

Report a mistake

Your message was sent. Thank you!

An error occurred while submitting the form