Skip to main content

python-steronix

Async Python client of the Steronix integrations API (integrations-v1, contract version 1.1.0). It reads one Steronix device and opens its relays with an integration token. It is the library behind the Steronix Home Assistant integration.

  • Typed models: TokenInfo, Device (relays and inputs), OpenResult.
  • One error class per answer of the API.
  • Opens with an idempotency key per button press; never retried on their own.
  • Long polling for live changes, with plain polling as the fallback.
  • HTTPS only: the client refuses an http:// base URL and never follows a redirect, so the token is never sent in clear.

Install

pip install python-steronix

Python 3.13 or newer; the only dependency is aiohttp.

The token

The device's owner creates a token on the portal, Controls → Integrations → Create token. It is shown once. A token is for one device and the relays chosen when it was made. It ends when it expires, when it is revoked, when the device changes owner, or when its creator's account is deleted. Treat it as an opaque string and keep it secret.

Use

import asyncio

import aiohttp

from steronix import Actor, ActorType, SteronixClient


async def main() -> None:
    async with aiohttp.ClientSession() as session:
        client = SteronixClient(session, "stx_…")

        token = await client.get_token()
        print(token.name, token.relays, token.expires_at)

        result = await client.get_device()
        device = result.device
        print(device.name, device.online, [i.active for i in device.inputs])

        opened = await client.open_relay(1, Actor(ActorType.USER, name="Ivan", login="ivan"))
        print("opened, log event", opened.open_number)


asyncio.run(main())

The default base URL is production, https://evo-lab.cloud/api/integrations/v1. Pass base_url= for another server.

Following the device

DeviceWatcher yields the device's state at start and after every change. It asks GET /device?wait=30 with the last ETag; the server answers as soon as the state changes, else after 30 s with 304, and it asks again at once. When long polling fails it polls every 10 s and tries long polling again after 5 minutes.

from steronix import DeviceWatcher, SteronixAuthenticationError, SteronixError

watcher = DeviceWatcher(client)
try:
    async for update in watcher.updates():
        if isinstance(update, SteronixError):
            ...  # the API cannot be reached now; show the device as unavailable
        else:
            ...  # a new state of the device
except SteronixAuthenticationError:
    ...  # the token no longer works: ask for a new one

For one wait yourself: await client.wait_for_change(etag, wait=30) returns the new state, or None when nothing changed.

Errors

Every error is a SteronixError.

Error When
SteronixConnectionError The API cannot be reached: network, TLS or timeout
SteronixInvalidResponseError An answer the contract does not describe
SteronixBadRequestError 400: the request does not match the contract
SteronixAuthenticationError 401: the token is missing, unknown, expired or revoked, or its grant ended
SteronixRelayNotAllowedError 403: the token may not open this relay
SteronixDeviceOfflineError 409 DEVICE_OFFLINE: nothing was sent to the device
SteronixRelayBlockedError 409 RELAY_BLOCKED: the schedule or the manual lock holds the relay
SteronixRateLimitError 429: too many requests; wait retry_after seconds
SteronixUnavailableError 503: integrations are off or the token cannot be checked now
SteronixNoAnswerError 504: the open was sent, the device did not answer; whether it opened is unknown
SteronixResponseError Any other error status; the base class of the ones above

A response error has status, code, problem (the RFC 9457 body, or None) and retry_after (from Retry-After, or None). A 429 from the edge's flood brake has no body; it is the same SteronixRateLimitError.

Limits

The server limits each token: one open per relay every 2 seconds, 60 opens an hour, a few immediate reads a minute and at most 2 waiting reads at once. Over a limit the answer is 429 with Retry-After.

Development

uv sync
uv run pytest
uv run ruff check . && uv run ruff format --check . && uv run mypy src
uv build

The tests run a fake API over real HTTPS. contract/ holds the pinned contract the tests check against. examples/smoke.py tries a real token:

STX_TOKEN=stx_… uv run python examples/smoke.py --seconds 60

Licence

Apache-2.0

Metadata

Release files for python-steronix 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for python-steronix 0.1.0
File Size Uploaded Provenance Actions
python_steronix-0.1.0.tar.gz 28.9 kB With provenance Details for python_steronix-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for python-steronix 0.1.0
File Interpreter ABI Platform Actions
python_steronix-0.1.0-py3-none-any.whl Python 3 none any Details for python_steronix-0.1.0-py3-none-any.whl

Total release size: 46.8 kB

Release files / python_steronix-0.1.0.tar.gz

Download URL python_steronix-0.1.0.tar.gz
Size 28.9 kB
Tags Source
SHA-256 checksum
How to use checksums
e75ef57b15eb020bc52f58352e4408462222dc3a785abbe09c742fa5bccaf05e
BLAKE2b-256 checksum
How to use checksums
7885aa4b8d47994b6aea34c598ae77cea51172bb78fa7f426ad0103d3f2bce32
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 29, 2026.

Transparency log

Release files / python_steronix-0.1.0-py3-none-any.whl

Download URL python_steronix-0.1.0-py3-none-any.whl
Size 17.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8051602bf0d5dad73c53baf78d3b1a8fe9bf8b637510a00f83c27085c5b6e7af
BLAKE2b-256 checksum
How to use checksums
1bd137df3b96246aba2e72a8ed06c56bf5a802429200a7d46b95befae1d204a6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 29, 2026.

Transparency log

Security for python-steronix 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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for python_steronix-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 29, 2026.

Transparency log

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.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page