devices module

Introduction

The device module is a collection of types and functions that enables the integration to defined Neowit devices in the database.

Example

This snippet defines a new Device and registers it to the database.

device = devices.Device(
  external_id = "myuniquedeviceid1",
  name = "Temperature room 1",
  vendor = "My sensor vendor",
  model = "My sensor model",
  status = "STATUS_CONNECTED",
  status_reason = "OK"
)
devices.upsert(device)

Types

Device

A Device represents a Neowit Device. It needs an identifier that is unique among the devices for the specific integration.

external_id: str

The integration unique id of the device.

Functions

def Device(external_id: str, name: str = None, status: str = None, status_reason: str = None, vendor: str = None, model: str = None) -> Device:

Creates a new Device. External id is the only required attribute, but we recommend that you provide as much information as possible. Status can be of the following values:

  • STATUS_CONNECTED: The device is connected.

  • STATUS_NOT_CONNECTED: The device is not connected.

  • STATUS_UNKNOWN: The status of the device is not known.

def upsert(device: Device):

Will register or update the device with the provided attributes. First time this is called, a new device with external_id will be added to the database. After this the attributes will be updated if there are any changes.

Last updated