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.

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'

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, 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.

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

__init__(celsius, samples=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.

  • 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:
  • temperature (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:
  • temperature (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, rssi, transmission_mode, cloud_connectors, 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, rssi, transmission_mode, cloud_connectors, 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 Cloud Connector is on “ETHERNET”, “CELLULAR”, or “OFFLINE”.

  • available (list[str]) – Lists available connections. Can contain “ETHERNET”, “CELLULAR”, or both.

  • 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 Cloud Connector is on “ETHERNET”, “CELLULAR”, or “OFFLINE”.

  • available (list[str]) – Lists available connections. Can contain “ETHERNET”, “CELLULAR”, or both.

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

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).