Skip to main content

Async Python client for OPUS SmartHome gateway REST API

Project description

pyopus-smarthome

Async Python client library for the OPUS SmartHome gateway (also marketed as OPUS greenNet). It provides HTTP API access and a real-time NDJSON event stream over a local network connection.


Credentials

The gateway uses HTTP Basic Auth on port 8080. The password is derived from the gateway's EURID — the last 8 hex characters, uppercased.

You can find the EURID on the QR code label on the gateway, or decode it with the included opus-qr CLI tool. The library handles password derivation automatically — just pass the EURID.


Installation

pip install pyopus-smarthome

Or with uv:

uv add pyopus-smarthome

Quick start

import asyncio
from pyopus_smarthome import OpusClient

async def main():
    # Connect using gateway IP and EURID (from GET /system/info)
    client = OpusClient("192.168.1.100", eurid="YOUR_EURID")

    gateway = await client.get_system_info()
    print(f"Gateway: {gateway.version}")

    devices = await client.get_devices()
    for d in devices:
        print(f"  {d.friendly_id}: cover={d.is_cover} climate={d.is_climate}")

    # Control a roller shutter
    await client.set_state("DEVICE_ID", "position", 50)

    await client.close()

asyncio.run(main())

Real-time event stream

OpusStream connects to the gateway's NDJSON server-sent event endpoint and dispatches callbacks when device states change or telegrams arrive.

import asyncio
from pyopus_smarthome import OpusStream, Device, Telegram

def on_devices(devices: list[Device]) -> None:
    for d in devices:
        print(f"Device update: {d.friendly_id}")

def on_telegram(telegram: Telegram) -> None:
    for fn in telegram.functions:
        print(f"Telegram: {fn.key} = {fn.value}")

async def main():
    stream = OpusStream(
        "192.168.1.100",
        eurid="YOUR_EURID",
        on_devices=on_devices,
        on_telegram=on_telegram,
        reconnect_delay=30.0,
    )
    await stream.start()

    # Run until interrupted
    try:
        await asyncio.sleep(3600)
    finally:
        await stream.stop()

asyncio.run(main())

See examples/ for runnable scripts — copy .env.example to .env and fill in your gateway details.


Supported device types

The library models the following device categories (detected from deviceType and function keys):

Category is_* property Description
Roller shutters device.is_cover Position control (0–100%)
Heating zones device.is_climate Set-point and current temperature
Temperature/humidity sensors device.is_sensor Read-only sensor values
Doorbell device.is_doorbell Binary press events

API reference

OpusClient

OpusClient(host: str, eurid: str, port: int = 8080, session: aiohttp.ClientSession | None = None)
Method Description
await client.get_system_info() Returns a Gateway with version and EURID
await client.get_devices() Returns list[Device]
await client.set_state(device_id, key, value) Send a state update to a device
await client.update_device(device_id, friendly_id, room_name) Rename a device or room
await client.get_device_configuration(device_id) Raw configuration dict
await client.close() Close the underlying HTTP session

OpusStream

OpusStream(host, eurid, port=8080, on_devices=None, on_telegram=None, reconnect_delay=30.0)
Method Description
await stream.start() Open the stream and begin dispatching callbacks
await stream.stop() Stop the stream and close the connection

Models

  • Gateway — gateway system info (version, eurid, serial)
  • Device — device with device_id, friendly_id, location, states: list[DeviceState]
  • DeviceState — a key/value/unit triplet
  • Telegram — incoming radio telegram with device_id and functions: list[TelegramFunction]
  • TelegramFunctionkey + value pair from a telegram

Auth helpers

from pyopus_smarthome import derive_admin_password, derive_config_password, parse_qr_code

password = derive_admin_password("00AABBCCDD")   # -> "AABBCCDD"

# Or derive credentials from the gateway QR code label
creds = parse_qr_code("30S0000AABBCCDD+1P00400000002B+S12345678")
creds.admin_password   # -> "AABBCCDD"
creds.config_password  # -> "AABBCCDD-12345678"

Exceptions

Exception Raised when
OpusError Base class
OpusConnectionError Network-level failure
OpusAuthError HTTP 401 from gateway
OpusApiError HTTP 4xx/5xx other than 401

License

MIT

Project details


Download files

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

Source Distribution

pyopus_smarthome-0.1.2.tar.gz (58.7 kB view details)

Uploaded Source

Built Distribution

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

pyopus_smarthome-0.1.2-py3-none-any.whl (10.9 kB view details)

Uploaded Python 3

File details

Details for the file pyopus_smarthome-0.1.2.tar.gz.

File metadata

  • Download URL: pyopus_smarthome-0.1.2.tar.gz
  • Upload date:
  • Size: 58.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pyopus_smarthome-0.1.2.tar.gz
Algorithm Hash digest
SHA256 cef76570a0597a0e18ae885ddff207c2327e910cdbe77a724a98df38606f0db2
MD5 2f6979ca443a3a28f461607eccd7d6b4
BLAKE2b-256 94558a7dccb7d8be4babd8e1795b8f2877c3761cbba151cafa74c25f3390fd0f

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyopus_smarthome-0.1.2.tar.gz:

Publisher: release.yml on thepiwo/pyopus-smarthome

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyopus_smarthome-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for pyopus_smarthome-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 dc328593797ffd0e24ca4f0c1948c532d925d0947ccf6171c5513a425b66ae03
MD5 5aa2810be4fe0033d38bca2ea11e92ef
BLAKE2b-256 aeaabdde65a04196d663a1c140eb99e91330b14aa9db9d004b3299cf0ca75c3e

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyopus_smarthome-0.1.2-py3-none-any.whl:

Publisher: release.yml on thepiwo/pyopus-smarthome

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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