zencontrol-python
This is an implementation of the Zencontrol TPI Advanced protocol, written in Python. This library has been written with three levels of abstraction:
- zencontrol.io: Implementation of the raw TPI Advanced UDP packet specification;
- zencontrol.api: Implementation of most TPI Advanced API commands and events;
- zencontrol.interface: An opinionated abstraction layer suitable for integration into smart building control software. It provides methods, objects, and callbacks for managing lights, groups, profiles, buttons, motion sensors, and system variables.
This library has now undergone validation in multiple environments. There is an extensive test suite, some of which uses zencontrol-simulator, a nearly feature-complete simulator of zencontrol hardware. A practical demonstration is zencontrol-homeassistant, a comprehensive Home Assistant integration.
Features
Beyond basic lighting control, this library supports:
- Broad command surface — inhibit, custom fade, step/up/down helpers, colour scene membership queries, EAN/serial, and most related TPI Advanced commands
- Object-based entity model — Optional. Expresses lights, groups, profiles, buttons, motion sensors, absolute inputs, and system variables as rich objects with interview/discovery helpers
- UDP transport resilience — request retries and queue-failure backoff
- Event keepalive — periodic emit-state ping; re-enables TPI events (and unicast target) if a controller reboots while the listener stays up
- Multicast controller discovery — find controllers on the LAN without a preconfigured host
- Button events — discovery of control-device button instances, plus press and long-press event callbacks
- Absolute inputs — discovery of numerical ECD instances (dials/sliders) with 16-bit value-change event callbacks
- Event filtering — configure which TPI events the controller emits
- System variables — labelled SV discovery, read/write, and change events
- Profiles — query, change, and return to the scheduled profile
- Simulator-backed tests — protocol path exercised against zencontrol-simulator
Known limitations
- RGB+ and XY colour commands have not been tested with hardware
- Numerical (absolute) instances have not been tested with hardware
Out of scope
- Any commands involving DMX, Control4, or virtual instances (I don't have licenses for any of these so I couldn't test them even if I wanted to, but the scaffolding is there if anyone wishes to add support)
- Any commands described in the documentation as "legacy" (they aren't useful)
Requirements
- Python 3.14 (or later)
- Controller firmware 2.2.130 or later is strongly recommended (minimum 2.2.11 required)
Install
This library is available on PyPI.
Testing
Integration tests start zencontrol-simulator on an ephemeral local port and exercise a real UDP TPI protocol path. Either install the simulator, or check it out as a sibling directory (../zencontrol-simulator); tests will pick it up automatically. Note that PyYAML is a simulator dependency.
pip install -e ".[dev]"
pip install PyYAML
# optional if not using a sibling checkout:
# pip install -e ../zencontrol-simulator
pytest -m simulator
pytest -m "not simulator"
# or run everything:
pytest
TPI Advanced wishlist
- Command to return a controller's MAC address used for multicast packets (There are other ways to get or infer the MAC access, but they're unreliable.)
- Command to list active system variables (As a workaround, you can query every number for its label. This assumes no system variables of interest are unlabelled.)
- Command to read an ambient light sensor's lux value. (As a workaround, you can target a light sensor to a system variable. Not elegant but it works.)
- Event notification for ambient light sensor lux values. (Same workaround as above.)
License
Links
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file zencontrol_python-0.1.6.tar.gz.
File metadata
- Download URL: zencontrol_python-0.1.6.tar.gz
- Upload date:
- Size: 94.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.2.0 CPython/3.14.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b9791051459e39d0975f6419e0fd0d81da436ca5959584add79770c9f340f5ce
|
|
| MD5 |
0363fbf3e6daedcf615aca9bb5e6213f
|
|
| BLAKE2b-256 |
37420aa3dfb73507b5fe928eec9527669ae214029ed144b39b4fa0c826e1e45a
|
File details
Details for the file zencontrol_python-0.1.6-py3-none-any.whl.
File metadata
- Download URL: zencontrol_python-0.1.6-py3-none-any.whl
- Upload date:
- Size: 88.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.2.0 CPython/3.14.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
674eb0611ea195c1a63f09e3828bdd2f8c45b280822dab040b655aac5f112577
|
|
| MD5 |
0a4d25fbdc6625eb0a8f8dba00638168
|
|
| BLAKE2b-256 |
2408a9e5e89f57c9d042255aef7d9009f849efc2c30c1efa49483c6c0a3d48b1
|