Skip to main content

Library for controlling Doit protocol lights

Project description

DoHome API

PyPI version Quality assurance

Async Python library for controlling smart LED bulbs and strips that use the DoIt protocol (DoHome app). Communicates with devices over the local network via TCP/UDP — no cloud required.

Features

  • Device discovery via UDP broadcast
  • RGB color and white temperature control
  • Brightness adjustment
  • Built-in light effects (gradients, strobes, jumps)
  • Device info, state reading, and power management
  • Wi-Fi credential provisioning

Installation

pip install dohome-api

Requires Python 3.12+.

Quick Start

import asyncio
from dohome.api import APIClient, discover
from dohome.transport import TCPStream, UDPBroadcast

async def main():
    # Discover devices on the local network
    broadcast = UDPBroadcast()
    devices = await discover(broadcast)
    broadcast.close()

    if not devices:
        print("No devices found")
        return

    # Connect to the first device
    client = APIClient(TCPStream(devices[0]["sta_ip"]))

    await client.set_power(True)
    await client.set_color((255, 0, 0), 128)  # Red at 50% brightness
    await asyncio.sleep(2)
    await client.set_power(False)

asyncio.run(main())

More examples (device info, Wi-Fi setup, state inspection) are available in the examples/ directory.

Provisioning

You can use this library to perform the initial device setup without using the DoHome app.

To do this:

  1. Clone this repository
  2. Install dependencies with make configure command
  3. Set the DOHOME_SSID and DOHOME_PASSWORD environment variables
  4. Connect to the light bulb's access point
  5. Run uv run examples/configure.py

API Reference

Discovery

Function Description
discover(transport) Finds all DoIt devices on the local network

APIClient

Method Description
set_power(is_on) Turn the device on or off
set_color(rgb, brightness) Set RGB color with brightness (0–255)
set_white(kelvin, brightness) Set white temperature (3000–6400 K) with brightness
set_effect(effect) Activate a built-in light effect
get_state() Read current light state
get_device_info() Read device hardware info
get_datetime() / set_datetime(dt) Read or set the device clock
set_wifi_credentials(ssid, password) Provision Wi-Fi credentials
reboot() Reboot the device

License

MIT © Mikhael Khrustik

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

dohome_api-2.1.0.tar.gz (54.2 kB view details)

Uploaded Source

Built Distribution

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

dohome_api-2.1.0-py3-none-any.whl (18.2 kB view details)

Uploaded Python 3

File details

Details for the file dohome_api-2.1.0.tar.gz.

File metadata

  • Download URL: dohome_api-2.1.0.tar.gz
  • Upload date:
  • Size: 54.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.13.9

File hashes

Hashes for dohome_api-2.1.0.tar.gz
Algorithm Hash digest
SHA256 460a0fcc38544dc29137c71094027b9af948607967afa1cdaa6793d94f3e770d
MD5 9a0e2a4e14bef76265ff317476dd634a
BLAKE2b-256 727f390a43eb09b5c5ce34b7649cd5327fb894608c95642baf9d6b7cc7b1b11c

See more details on using hashes here.

File details

Details for the file dohome_api-2.1.0-py3-none-any.whl.

File metadata

  • Download URL: dohome_api-2.1.0-py3-none-any.whl
  • Upload date:
  • Size: 18.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.13.9

File hashes

Hashes for dohome_api-2.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0154b3b0cd1300a06bf3b028798824a4f6f17313693f05beedc0b7c08212e091
MD5 fe4ea97c710f52a9cb53021d72fa0e8d
BLAKE2b-256 4c155e92118ee3a4da38e436443c0dd6c759fc3f08ed8cb1b69a2eb74441060f

See more details on using hashes here.

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