simpleiot
A Python client for Simple IoT. Read and write nodes and points, and watch for changes, over the NATS API.
The client connects with the instance's shared token (SIOT_AUTH_TOKEN), which
reaches the whole tree. It suits scripts and services running alongside an
instance you operate.
A typical setup runs the Python process next to SIOT on an edge device. What it writes reaches the cloud through sync, and a person sees it in the web UI on site or remotely.
Install
pip install simpleiot
Requires Python 3.10 or newer. The client is built on
nats-py and uses asyncio.
Usage
import asyncio
import simpleiot
from simpleiot import Point
async def main():
async with await simpleiot.connect() as c:
root = await c.get_root()
print("root:", root.description)
id = await c.create_node(root.id, "variable", description="tank level")
await c.send_point(id, "value", 42.5)
async with await c.subscribe_node(id) as sub:
async for m in sub:
for p in m.points:
print(p.type, p.value)
asyncio.run(main())
connect() reads SIOT_NATS_SERVER (default nats://localhost:4222) and
SIOT_AUTH_TOKEN from the environment, or takes them as arguments:
c = await simpleiot.connect("nats://10.0.0.5:4222", token="...")
Nodes and points
Data in Simple IoT is a tree of nodes, each holding points. A point has
a type, a key ("0" unless a node holds several of a type), a value, and
a time. The edge from a node to its parent carries its own points, such as
tombstone for a deleted node. See the
data reference.
Point.value sets the encoding when sending:
| Value | Sent as |
|---|---|
float, int, bool |
a float point |
str |
a string point |
dict, list |
a JSON point |
None |
a point with no value |
Pass data_type=DataType.INT to send an integer as an int point. A received
point's value is a float, int, or str by its data type; number and
text read it as a number or string either way.
API
All methods are coroutines on Client.
get_root(),get_node(id, parent="all"),get_children(parent, type=...)get_nodes(parent, id="all", type=..., include_deleted=..., depth=...), thenodes.<parent>.<id>requestsearch(below, query, limit=..., type=...)send_points(id, points),send_point(id, type, value, key="0")send_edge_points(id, parent, points)create_node(parent, type, points, id=..., description=..., primary=...)delete_node(id, parent),move_node(id, old_parent, new_parent)provision(name, yaml)uploads a node file for the server to apply, assiot importwould, and waits until it hassubscribe_node(id),subscribe_tree(id),subscribe(subject): async iterators ofPointsMessageclose()
A server error raises SiotError; a missing node raises NotFoundError.
Examples
Each example is a short script in its own directory with a README:
- tree prints the node tree
- send_points creates a node and writes a value to it once a second
- watch prints every point change below a node
- mirror_temperature reacts to one point by writing another
- rover drives a simulated autonomous rover from a dashboard, with a live map, status, and commands
Run them against a local instance:
SIOT_AUTH_TOKEN=... python examples/tree/tree.py
Development
The client lives in the
Simple IoT repository under python/,
so it changes together with the server.
cd python
uv sync
uv run pytest
The tests need uv. The codec tests check the
encoder against the fixtures data/point_fixture_test.go writes, the same ones
the JavaScript client is checked against. The integration tests start a scratch
siot when SIOT_BIN names one; siot_test_python in envsetup.sh builds it
and runs them.
To publish a release, set the version in python/src/simpleiot/__init__.py, add
a python/CHANGELOG.md entry, and push a py-v<version> tag. The
Python release workflow builds the package and publishes it to PyPI.
Metadata
Release files for simpleiot 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| simpleiot-0.1.0.tar.gz | 117.2 kB | Without provenance | Details for simpleiot-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| simpleiot-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for simpleiot-0.1.0-py3-none-any.whl |
Total release size: 134.8 kB
Release files / simpleiot-0.1.0.tar.gz
| Download URL | simpleiot-0.1.0.tar.gz |
|---|---|
| Size | 117.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a779fbb1173c51b65e997fce8674778c25a012f6b2c60b688f237618d47e33aa
|
|
BLAKE2b-256 checksum How to use checksums |
ac8d9a291fc8eafec5c8de726f2066b0bffca06a38109c3d9cd581c1d9a04364
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.8 {"installer":{"name":"uv","version":"0.13.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / simpleiot-0.1.0-py3-none-any.whl
| Download URL | simpleiot-0.1.0-py3-none-any.whl |
|---|---|
| Size | 17.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0cd03e553b3388551c345dd885ad5334cc3d915c8efd7aa40926d8a46984a47f
|
|
BLAKE2b-256 checksum How to use checksums |
d87b76da3af5a29af5bf3e05c38ac72e3d75cbc87730bacf31dc90b40413d57a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.8 {"installer":{"name":"uv","version":"0.13.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for simpleiot 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.