Skip to main content

Python library for the digitalSTROM vDC API

Project description

pydsvdcapi

CI PyPI Python License: GPLv3

Python library for the digitalSTROM virtual Device Connector (vDC) API.

What this library does

  • Implements the full vDC protobuf protocol over TCP
  • Manages the session lifecycle (hello/pong, announcement, reconnect)
  • Models all device classes: lights, blinds, sensors, buttons, heating, audio, and more
  • Provides a composable API: VdcHostVdcVdsd → components
  • Persists device state across restarts via a YAML property store
  • Automatically derives modelFeatures flags from configured components
  • Supports value converters for uplink/downlink data transformation

Installation

pip install pydsvdcapi

Requires Python 3.10+.

Quick start

import asyncio
from pydsvdcapi import (
    VdcHost, Vdc, Device, Vdsd,
    DsUid,
    Output, OutputFunction, OutputUsage,
    ColorGroup, DeviceLifecycleState,
)

async def main():
    host = VdcHost(name="My Gateway", state_path="state.yaml")

    vdc = Vdc(host=host, implementation_id="x-myapp-lights",
              name="My Lights", model="Light Controller")
    host.add_vdc(vdc)

    device = Device(vdc=vdc, dsuid=DsUid.from_gtin_serial("0000000000001", "001"))
    vdsd = Vdsd(device=device, primary_group=ColorGroup.YELLOW,
                name="Living Room Light", model="My Light v1")
    output = Output(vdsd=vdsd, function=OutputFunction.DIMMER,
                    output_usage=OutputUsage.ROOM)
    vdsd.set_output(output)

    async def apply_channels(out: Output, updates: dict) -> None:
        if 0 in updates:  # brightness = dsIndex 0
            print(f"Set brightness to {updates[0]:.1f}%")
    output.on_channel_applied = apply_channels

    await vdsd.set_lifecycle_state(DeviceLifecycleState.ACTIVE)
    device.add_vdsd(vdsd)
    vdc.add_device(device)
    await host.start()
    await asyncio.Event().wait()

asyncio.run(main())

See the Developer Guide for a full walkthrough and API reference.

Development

git clone https://github.com/KarlKiel/pyDSvDCAPI.git
cd pyDSvDCAPI
python -m venv .venv && source .venv/bin/activate
pip install -e ".[dev]"
Command Purpose
python -m pytest Run tests
ruff check src/ tests/ Lint
ruff format src/ tests/ Format
mypy src/pydsvdcapi Type-check

See CONTRIBUTING.md for full guidance.

Documentation

License

GPLv3 — see LICENSE.

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

pydsvdcapi-0.9.0.tar.gz (309.8 kB view details)

Uploaded Source

Built Distribution

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

pydsvdcapi-0.9.0-py3-none-any.whl (198.1 kB view details)

Uploaded Python 3

File details

Details for the file pydsvdcapi-0.9.0.tar.gz.

File metadata

  • Download URL: pydsvdcapi-0.9.0.tar.gz
  • Upload date:
  • Size: 309.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pydsvdcapi-0.9.0.tar.gz
Algorithm Hash digest
SHA256 b9687cd197884e0dc1f1c0a10fdec4f9fcdec2f62e39c0d051bc1eb0cd5b77cf
MD5 91b64109853ac6226be05bc481476303
BLAKE2b-256 5502c8038afb5b934118929be64c81f58ecb62b70715324eb5b042555c4654d2

See more details on using hashes here.

Provenance

The following attestation bundles were made for pydsvdcapi-0.9.0.tar.gz:

Publisher: publish.yml on KarlKiel/pydsvdcapi

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

File details

Details for the file pydsvdcapi-0.9.0-py3-none-any.whl.

File metadata

  • Download URL: pydsvdcapi-0.9.0-py3-none-any.whl
  • Upload date:
  • Size: 198.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pydsvdcapi-0.9.0-py3-none-any.whl
Algorithm Hash digest
SHA256 53d5bb77302bc7a5d290d1e2f6e710ce26b9645b85a3c42b2dae3791c67be4be
MD5 fd2346bffd8a036254319ee757484820
BLAKE2b-256 d385860195eae51082c79803b6afbb7509a34ae3dcf4509d61451ac727793204

See more details on using hashes here.

Provenance

The following attestation bundles were made for pydsvdcapi-0.9.0-py3-none-any.whl:

Publisher: publish.yml on KarlKiel/pydsvdcapi

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