Neowit developer docs
API referenceSupportKnowledge baseStatusApp
  • Overview
  • REST API
    • Introduction
    • Authentication
      • OAuth2
      • Basic Auth
    • Error codes
    • API reference
    • Coordinate systems
    • Query Language
      • Query Language Reference
  • Service Accounts
    • Introduction
    • Creating service accounts
  • Integrations
    • Introduction
    • MQTT
      • Native Sparkplug
      • Custom Starlark
  • Starlark
    • Introduction
    • Modules
      • time module
      • json module
      • math module
      • devices module
      • series module
      • sensors module
  • Tutorials
    • Introduction
    • Create users using API
Powered by GitBook
On this page
  • Introduction
  • Example
  • Types
  • Device
  • Functions
  • def Device(external_id: str, name: str = None, status: str = None, status_reason: str = None, vendor: str = None, model: str = None) -> Device:
  • def upsert(device: Device):
  1. Starlark
  2. Modules

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.

Previousmath moduleNextseries module

Last updated 11 months ago