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.1.tar.gz (310.9 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.1-py3-none-any.whl (198.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pydsvdcapi-0.9.1.tar.gz
  • Upload date:
  • Size: 310.9 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.1.tar.gz
Algorithm Hash digest
SHA256 fae9cc5cf804d0b6b9df1e0ad27c99945b5791c805ef31d6ac48889ad6901778
MD5 778477a30cf1d29462ae6ee0984bb33b
BLAKE2b-256 4fceb7cd405dc56daf8bf1f4cd3b620d953e0317eabe7b432a1b9d697611ff4e

See more details on using hashes here.

Provenance

The following attestation bundles were made for pydsvdcapi-0.9.1.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.1-py3-none-any.whl.

File metadata

  • Download URL: pydsvdcapi-0.9.1-py3-none-any.whl
  • Upload date:
  • Size: 198.7 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ffce41dd6636a168de8b28b12d89cad7d793b7b84d734f7c56068960b3545dd6
MD5 d7ad14f4872ce22781236f2de9d72ba9
BLAKE2b-256 ed197389c4691d40559c4ceab84d7122b630d710aae78eb010f483c00b9b9510

See more details on using hashes here.

Provenance

The following attestation bundles were made for pydsvdcapi-0.9.1-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