Events

When interacting the EventHistory or Stream resources, fetched events are represented by an instance of the Event class.

class disruptive.events.Event(event)

Represents device events.

Variables:
  • event_id (str) – Unique event ID.

  • event_type (str) – Event type.

  • device_id (str) – Unique ID of the source device.

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

  • data (Event Data) – An object representing type-specific event data.

  • raw (dict[str, str]) – Unmodified API response JSON.

Type Constants

A constant for each event type is available in the events module.

events.TOUCH = 'touch'
events.TEMPERATURE = 'temperature'
events.OBJECT_PRESENT = 'objectPresent'
events.HUMIDITY = 'humidity'
events.OBJECT_PRESENT_COUNT = 'objectPresentCount'
events.TOUCH_COUNT = 'touchCount'
events.WATER_PRESENT = 'waterPresent'
events.NETWORK_STATUS = 'networkStatus'
events.BATTERY_STATUS = 'batteryStatus'
events.LABELS_CHANGED = 'labelsChanged'
events.CONNECTION_STATUS = 'connectionStatus'
events.ETHERNET_STATUS = 'ethernetStatus'
events.CELLULAR_STATUS = 'cellularStatus'
events.CO2 = 'co2'
events.PRESSURE = 'pressure'
events.MOTION = 'motion'
events.DESK_OCCUPANCY = 'deskOccupancy'
events.CONTACT = 'contact'
events.PROBE_WIRE_STATUS = 'probeWireStatus'

This can be useful when using resource methods where one can filter on event types.

# Fetch touch- and humidity event history.
history = disruptive.EventHistory.list_events(
   device_id='<DEVICE_ID>',
   project_id='<PROJECT_ID>',
   event_types=[
      disruptive.events.TOUCH,
      disruptive.events.HUMIDITY,
   ],
)

Event Data

The following classes each represent one type-specific event data that can be encountered. Instances are found in the data attribute of an Event or the reported attribute of a Device.

class disruptive.events.Touch(timestamp=None)

Represents the data found in a touch event.

Variables:

timestamp (datetime) – Timestamp of when the event was received by a Cloud Connector.

__init__(timestamp=None)

Constructs the Touch object.

Parameters:

timestamp (datetime, str, optional) – Timestamp in either datetime or string iso8601 format (i.e. yyyy-MM-ddTHH:mm:ssZ).

class disruptive.events.Temperature(celsius, samples=None, is_backfilled=None, timestamp=None)

Represents the data found in a temperature event.

Variables:
  • celsius (float) – Temperature value in Celsius.

  • fahrenheit (float) – Temperature value in Fahrenheit.

  • samples (list[TemperatureSample]) – Temperature values sampled over a single heartbeat.

  • is_backfilled (bool) – Indicates if the temperature event is backfilled.

  • timestamp (datetime) – Timestamp of when the event was received by a Cloud Connector.

__init__(celsius, samples=None, is_backfilled=None, timestamp=None)

Constructs the Temperature object. The fahrenheit attribute is calculated from the provided celsius parameter.

Parameters:
  • celsius (float) – Temperature value in Celsius.

  • samples (list[TemperatureSample]) – Temperature values sampled over a single heartbeat.

  • is_backfilled (bool) – Indicates if the temperature event is backfilled.

  • timestamp (datetime, str, optional) – Timestamp in either datetime or string iso8601 format (i.e. yyyy-MM-ddTHH:mm:ssZ).

class disruptive.events.TemperatureSample(celsius, timestamp)

Represents a single temperature event sample from a heartbeat period.

Variables:
  • celsius (float) – Temperature value in Celsius.

  • fahrenheit (float) – Temperature value in Fahrenheit.

  • timestamp (datetime) – Interpolated inter-heartbeat timestamp.

__init__(celsius, timestamp)

Constructs the TemperatureSample object. The fahrenheit attribute is calculated from the provided celsius parameter.

Parameters:
  • celsius (float) – Temperature value in Celsius.

  • timestamp (datetime, str, optional) – Timestamp in either datetime or string iso8601 format (i.e. yyyy-MM-ddTHH:mm:ssZ).

class disruptive.events.ObjectPresent(state, timestamp=None)

Represents the data found in an objectPresent event.

Variables:
  • state (str) – Indicates whether an object is “PRESENT” or “NOT_PRESENT”.

  • timestamp (datetime) – Timestamp of when the event was received by a Cloud Connector.

__init__(state, timestamp=None)

Constructs the ObjectPresent object, inheriting parent class and setting the type-specific attributes.

Parameters:
  • state (str) – Indicates whether an object is “PRESENT” or “NOT_PRESENT”.

  • timestamp (datetime, str, optional) – Timestamp in either datetime or string iso8601 format (i.e. yyyy-MM-ddTHH:mm:ssZ).

class disruptive.events.Humidity(celsius, relative_humidity, timestamp=None)

Represents the data found in an humidity event.

Variables:
  • celsius (float) – Temperature value in Celsius.

  • relative_humidity (float) – Relative humidity in percent.

  • timestamp (datetime) – Timestamp of when the event was received by a Cloud Connector.

__init__(celsius, relative_humidity, timestamp=None)

Constructs the Humidity object.

Parameters:
  • celsius (float) – Temperature value in Celsius.

  • relative_humidity (float) – Relative humidity in percent.

  • timestamp (datetime, str, optional) – Timestamp in either datetime or string iso8601 format (i.e. yyyy-MM-ddTHH:mm:ssZ).

class disruptive.events.ObjectPresentCount(total, timestamp=None)

Represents the data found in an objectPresentCount event.

Variables:
  • total (int) – The total number of times the sensor has detected the appearance or disappearance of an object over its lifetime.

  • timestamp (datetime) – Timestamp of when the event was received by a Cloud Connector.

__init__(total, timestamp=None)

Constructs the ObjectPresentCount object.

Parameters:
  • total (int) – The total number of times the sensor has detected the appearance or disappearance of an object over its lifetime.

  • timestamp (datetime, str, optional) – Timestamp in either datetime or string iso8601 format (i.e. yyyy-MM-ddTHH:mm:ssZ).

class disruptive.events.TouchCount(total, timestamp=None)

Represents the data found in an touchCount event.

Variables:
  • total (int) – The total number of times the sensor has been touched over its lifetime.

  • timestamp (datetime) – Timestamp of when the event was received by a Cloud Connector.

__init__(total, timestamp=None)

Constructs the TouchCount object.

Parameters:
  • total (int) – The total number of times the sensor has been touched over its lifetime.

  • timestamp (datetime, str, optional) – Timestamp in either datetime or string iso8601 format (i.e. yyyy-MM-ddTHH:mm:ssZ).

class disruptive.events.WaterPresent(state, timestamp=None)

Represents the data found in an waterPresent event.

Variables:
  • state (str) – Indicates whether water is PRESENT or NOT_PRESENT.

  • timestamp (datetime) – Timestamp of when the event was received by a Cloud Connector.

__init__(state, timestamp=None)

Constructs the WaterPresent object.

Parameters:
  • state (str) – Indicates whether water is “PRESENT” or “NOT_PRESENT”.

  • timestamp (datetime, str, optional) – Timestamp in either datetime or string iso8601 format (i.e. yyyy-MM-ddTHH:mm:ssZ).

class disruptive.events.NetworkStatus(signal_strength=None, rssi=None, transmission_mode=None, cloud_connectors=None, timestamp=None)

Represents the data found in a networkStatus event.

Variables:
  • signal_strength (int) – The percentage signal strength (0% to 100%) of the strongest Cloud Connector, derived directly from the RSSI value.

  • rssi (float) – Raw Received Signal Strength Indication (RSSI) as measured by the strongest Cloud Connector.

  • transmission_mode (str) – Indicated whether the sensor is in LOW_POWER_STANDARD_MODE or HIGH_POWER_BOOST_MODE.

  • cloud_connectors (list[NetworkStatusCloudConnector]) – List of the Cloud Connector that forwarded the event.

  • timestamp (datetime) – Timestamp of when the event was received by a Cloud Connector.

__init__(signal_strength=None, rssi=None, transmission_mode=None, cloud_connectors=None, timestamp=None)

Constructs the NetworkStatus object.

Parameters:
  • signal_strength (int) – The percentage signal strength (0% to 100%) of the strongest Cloud Connector, derived directly from the RSSI value.

  • rssi (float) – Raw Received Signal Strength Indication (RSSI) as measured by the strongest Cloud Connector.

  • transmission_mode (str) – Indicated whether the sensor is in LOW_POWER_STANDARD_MODE or HIGH_POWER_BOOST_MODE.

  • cloud_connectors (list[NetworkStatusCloudConnector]) – List of the Cloud Connector that forwarded the event.

  • timestamp (datetime, str, optional) – Timestamp in either datetime or string iso8601 format (i.e. yyyy-MM-ddTHH:mm:ssZ).

class disruptive.events.BatteryStatus(percentage, timestamp=None)

Represents the data found in a batteryStatus event.

Variables:
  • percentage (int) – A coarse percentage estimate (0% to 100%) of the remaining battery.

  • timestamp (datetime) – Timestamp of when the event was received by a Cloud Connector.

__init__(percentage, timestamp=None)

Constructs the Temperature object.

Parameters:
  • percentage (int) – A coarse percentage estimate (0% to 100%) of the remaining battery.

  • timestamp (datetime, str, optional) – Timestamp in either datetime or string iso8601 format (i.e. yyyy-MM-ddTHH:mm:ssZ).

class disruptive.events.LabelsChanged(added, modified, removed, timestamp=None)

Represents the data found in an labelsChanged event.

Variables:
  • added (dict[str, str]) – Keys and values of new labels added.

  • modified (dict[str, str]) – New keys and values of modified labels.

  • removed (list[str]) – List of keys of removed labels.

  • timestamp (datetime) – Timestamp of when the event was received by a Cloud Connector.

class disruptive.events.ConnectionStatus(connection, available, timestamp=None)

Represents the data found in a connectionStatus event.

Variables:
  • connection (str) – Whether the current connection is SDS, ETHERNET, CELLULAR, or OFFLINE.

  • available (list[str]) – A list of the string types of networks available to the device. For Cloud Connectors, this can contain the values ETHERNET, CELLULAR, or both. For Sensors, it will contain only SDS when its online. This field will be empty when the device’s connection is OFFLINE.

  • timestamp (datetime) – Timestamp of when the event was received by a Cloud Connector.

__init__(connection, available, timestamp=None)

Constructs the ConnectionStatus object.

Parameters:
  • connection (str) – Whether the current connection is SDS, ETHERNET, CELLULAR, or OFFLINE.

  • available (list[str]) – A list of the string types of networks available to the device. For Cloud Connectors, this can contain the values ETHERNET, CELLULAR, or both. For Sensors, it will contain only SDS when its online. This field will be empty when the device’s connection is OFFLINE.

  • timestamp (datetime) – Timestamp of when the event was received by a Cloud Connector.

class disruptive.events.EthernetStatus(mac_address, ip_address, timestamp=None)

Represents the data found in a ethernetStatus event.

Variables:
  • mac_address (str) – MAC address of the local network interface.

  • ip_address (str) – IP address of the Cloud Connector on the local network.

  • timestamp (datetime) – Timestamp of when the event was received by a Cloud Connector.

__init__(mac_address, ip_address, timestamp=None)

Constructs the EthernetStatus object, inheriting parent class and setting the type-specific attributes.

Parameters:
  • mac_address (str) – MAC address of the local network interface.

  • ip_address (str) – IP address of the Cloud Connector on the local network.

  • timestamp (datetime, str, optional) – Timestamp in either datetime or string iso8601 format (i.e. yyyy-MM-ddTHH:mm:ssZ).

class disruptive.events.CellularStatus(signal_strength, timestamp=None)

Represents the data found in a cellularStatus event.

Variables:
  • signal_strength (int) – Cloud Connector cellular reception percentage.

  • timestamp (datetime) – Timestamp of when the event was received by a Cloud Connector.

__init__(signal_strength, timestamp=None)

Constructs the Temperature object.

Parameters:
  • signal_strength (int) – Cloud Connector cellular reception percentage.

  • timestamp (datetime, str, optional) – Timestamp in either datetime or string iso8601 format (i.e. yyyy-MM-ddTHH:mm:ssZ).

class disruptive.events.Co2(ppm, timestamp=None)

Represents the data found in a co2 event.

Variables:
  • ppm (int) – Co2 concentration in parts per million.

  • timestamp (datetime) – Timestamp of when the event was received by a Cloud Connector.

__init__(ppm, timestamp=None)

Constructs the Co2 object.

Parameters:
  • ppm (int) – Co2 concentration in parts per million.

  • timestamp (datetime, str, optional) – Timestamp in either datetime or string iso8601 format (i.e. yyyy-MM-ddTHH:mm:ssZ).

class disruptive.events.Pressure(pascal, timestamp=None)

Represents the data found in a pressure event.

Variables:
  • pascal (int) – Barometric pressure in pascal.

  • timestamp (datetime) – Timestamp of when the event was received by a Cloud Connector.

__init__(pascal, timestamp=None)

Constructs the Pressure object.

Parameters:
  • pascal (int) – Barometric pressure in pascal.

  • timestamp (datetime, str, optional) – Timestamp in either datetime or string iso8601 format (i.e. yyyy-MM-ddTHH:mm:ssZ).

class disruptive.events.Motion(state, timestamp=None)

Represents the data found in a motion event.

Variables:
  • state (str) – Indicates whether “MOTION_DETECTED” or “NO_MOTION_DETECTED”.

  • timestamp (datetime) – Timestamp of when the event was received by a Cloud Connector.

__init__(state, timestamp=None)

Constructs the Motion object, inheriting parent class and setting the type-specific attributes.

Parameters:
  • state (str) – Indicates whether “MOTION_DETECTED” or “NO_MOTION_DETECTED”.

  • timestamp (datetime, str, optional) – Timestamp in either datetime or string iso8601 format (i.e. yyyy-MM-ddTHH:mm:ssZ).

class disruptive.events.DeskOccupancy(state, timestamp=None, remarks=None)

Represents the data found in a deskOccupancy event.

Variables:
  • state (str) – Indicates whether the sensor predicts “OCCUPIED” or “NOT_OCCUPIED”.

  • remarks (list[str], optional) – Additional information about the estimated state, given as a list of string remarks. See https://developer.d21s.com/docs/concepts/events#remarks.

  • timestamp (datetime) – Timestamp of when the event was received by a Cloud Connector.

__init__(state, timestamp=None, remarks=None)

Constructs the DeskOccupancy object, inheriting parent class and setting the type-specific attributes.

Parameters:
  • state (str) – Indicates whether the sensor predicts “OCCUPIED” or “NOT_OCCUPIED”.

  • timestamp (datetime, str, optional) – Timestamp in either datetime or string iso8601 format (i.e. yyyy-MM-ddTHH:mm:ssZ).

  • remarks (list[str], optional) – Additional information about the estimated state, given as a list of string remarks. See https://developer.d21s.com/docs/concepts/events#remarks.

class disruptive.events.Contact(state, timestamp=None)

Represents the data found in a contact event.

Variables:
  • state (str) – Indicates whether the sensor detects “CLOSED” or “OPEN”.

  • timestamp (datetime) – Timestamp of when the event was received by a Cloud Connector.

__init__(state, timestamp=None)

Constructs the Contact object, inheriting parent class and setting the type-specific attributes.

Parameters:
  • state (str) – Indicates whether the sensor predicts “CLOSED” or “OPEN”.

  • timestamp (datetime, str, optional) – Timestamp in either datetime or string ISO8601 format (i.e. yyyy-MM-ddTHH:mm:ssZ).

class disruptive.events.ProbeWireStatus(state, timestamp=None)

Represents the data found in a contact event.

Variables:

timestamp (datetime) – Timestamp of when the event was received by a Cloud Connector.

__init__(state, timestamp=None)

Constructs the ProbeWireStatus object, inheriting parent class and setting the type-specific attributes.

Parameters:
  • state (str) – Probe wire status. Can be either “INVALID_WIRE_CONFIGURATION”, “INVALID_COEFFICIENT_CONFIGURATION”, “TWO_WIRE”, “THREE_WIRE”, or “FOUR_WIRE”.

  • timestamp (datetime, str, optional) – Timestamp in either datetime or string ISO8601 format (i.e. yyyy-MM-ddTHH:mm:ssZ).