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.3.tar.gz (58.8 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.3-py3-none-any.whl (11.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pyopus_smarthome-0.1.3.tar.gz
  • Upload date:
  • Size: 58.8 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.3.tar.gz
Algorithm Hash digest
SHA256 d6177a597b7a7f04c9f00cb8765102e0b5e42db10dbdb9e4077093df9d126621
MD5 8d8e115a0a1fce15bb1b65651e6346ca
BLAKE2b-256 84179b062682ec159958d2440070b6fef9031009dac422e328582871b82c475f

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyopus_smarthome-0.1.3.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.3-py3-none-any.whl.

File metadata

File hashes

Hashes for pyopus_smarthome-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 c0db6bbc4fa76cf3f0d69e81b8b2adf2b4660666bb61899e47fc2fbb0f5d5a73
MD5 02143d047b9723f5ba061605e4f34f40
BLAKE2b-256 a5be4d0667bca4629214bac1a832754522da75da2839dce24d5d04b9ba776143

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyopus_smarthome-0.1.3-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