EventHistory

The EventHistory resource can be used fetch historic event data for a device. This can be achieved by using the API Method included in the class.

All the fetched historic events are returned to the user in a list.

API Methods

disruptive.EventHistory.list_events(device_id, project_id, event_types=None, start_time=None, end_time=None, **kwargs)

Get the event history for a single device.

Parameters:
  • device_id (str) – Unique ID of the target device.

  • project_id (str) – Unique ID of the target project.

  • event_types (list[str], optional) – If provided, only the specified event types are fetched.

  • start_time (str, datetime, optional) – Specifies from when event history is fetched. Defaults to 24 hours ago.

  • end_time (str, datetime, optional) – Specified until when event history is fetched. Defaults to now.

  • **kwargs (Any) – Arbitrary keyword arguments. See the Configuration page.

Returns:

events – A list of all events fetched by the call.

Return type:

EventHistory[Event]

Examples

>>> # Fetch all events in the last 24h for a device.
>>> events = dt.EventHistory.list_events(
...     device_id='<DEVICE_ID>',
...     project_id='<PROJECT_ID',
... )
>>> # Fetch all touch- and objectPresent events
>>> # for a device in the last 7 days.
>>> events = dt.EventHistory.list_events(
...     device_id=DEVICE_1,
...     project_id=PROJECT_ID,
...     event_types=[
...         dt.events.TOUCH,
...         dt.events.OBJECT_PRESENT,
...     ],
...     start_time=datetime.utcnow() - timedelta(7),
... )