Skip to main content

Enapter Python SDK

Project description

Enapter Python SDK

CI PyPI version Code Style

Enapter software development kit for Python.

:warning: This project is work in progress. The API is not stable and may change at any time. :warning:

Installation

Stable from PyPI:

pip install enapter

Latest for GitHub:

pip install git+https://github.com/Enapter/python-sdk#egg=enapter

Usage

Checkout examples.

Implementing your own VUCM

Device Telemetry and Properties

Every method of enapter.vucm.Device subclass decorated with enapter.vucm.device_task decorator is considered a device task. When such a device is started, all of its tasks are started as well. Device tasks are started in random order and are being executed concurrently in the background. If a device task returns or raises an exception, device routine is terminated. A typical use of the task is to run a periodic job to send device telemetry and properties.

In order to send telemetry and properties define two corresponding device tasks. It is advised (but is not obligatory) to send telemetry every 1 second and to send properties every 10 seconds.

Examples:

Device Command Handlers

Every method of enapter.vucm.Device subclass decorated with enapter.vucm.device_command is considered a device command handler. Device command handlers receive the same arguments as described in device Blueprint manifest and can optionally return a payload as enapter.types.JSON.

In order to handle device commands define corresponding device command handlers.

Examples:

Device Alerts

Device alerts are stored in self.alerts. It is a usual Python set, so you can add an alert using alerts.add, remove an alert alerts.remove and clear alerts using alerts.clear.

Alerts are sent only as part of telemetry, so in order to report device alert, use send_telemetry with any payload.

Running your own VUCM via Docker

A simple Dockerfile can be:

FROM python:3.10-alpine3.16

WORKDIR /app

RUN python -m venv .venv
COPY requirements.txt requirements.txt
RUN .venv/bin/pip install -r requirements.txt

COPY script.py script.py

CMD [".venv/bin/python", "script.py"]

:information_source: If you are using Enapter Gateway and running Linux, you should connect your containers to host network :information_source::

docker run --network host ...

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

enapter-0.10.1-py3-none-any.whl (20.6 kB view details)

Uploaded Python 3

File details

Details for the file enapter-0.10.1-py3-none-any.whl.

File metadata

  • Download URL: enapter-0.10.1-py3-none-any.whl
  • Upload date:
  • Size: 20.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for enapter-0.10.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2a3ed4ac95c30cb3b9cf984aff9fe3738eb1d02d1124928cb44d1c69be8920d5
MD5 6502040c3141bb96130b96b67ab7e6a1
BLAKE2b-256 54b8d2b8c56ff44e7e0770dd55f8220530eaf5ba4bfbfc79338b8bfef6cdc9ac

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page