Skip to content

Home

dlight-client

Async Python for dLight smart lamps. Local Wi-Fi. Zero dependencies.

PyPI version Python Versions CI License: MIT


dlight-client is a pure-asyncio Python library for discovering and controlling dLight smart lamps entirely on your local network. No cloud relay, no vendor accounts, no third-party packages — just UDP discovery, persistent TCP connections, and a clean async API.

It is the Python layer powering the dlight-hass Home Assistant integration.


Why dlight-client?

  • Purely local

    UDP broadcast discovery + TCP control on your LAN. Your lamp data never leaves your network.

  • Zero dependencies

    Pure asyncio and stdlib. pip install dlight-client adds nothing else to your environment.

  • State caching

    DLightDevice keeps an internal cache and applies optimistic updates — commands feel instant even on lossy Wi-Fi.

  • Robust by design

    Per-device locking, idle connection eviction, configurable retries with exponential backoff, and optional TLS.

Quick start

import asyncio
from dlightclient import AsyncDLightClient, DLightDevice, discover_devices

async def main():
    devices = await discover_devices()           # UDP broadcast, 3 s window
    info = devices[0]

    async with AsyncDLightClient(persistent=True) as client:
        lamp = DLightDevice(info["ip_address"], info["deviceId"], client)
        await lamp.turn_on()
        await lamp.set_brightness(75)
        await lamp.set_color_temperature(3000)   # warm white

asyncio.run(main())

Get started API Reference


Where to go next

Getting Started Install, discover devices, send your first command.
User Guide Deep dives: discovery, control, connections, error handling.
API Reference Full reference for every class, method, and exception.
Architecture How the library is layered — for contributors and the curious.
Contributing Set up a dev environment and send a PR.
Changelog What's changed in each release.

dlight-hass users

If you use the Home Assistant integration, this is the library it depends on. You don't need to install or configure dlight-client separately — but understanding the API can be handy when troubleshooting.