Skip to main content

zencontrol-python

A Python implementation of the Zencontrol TPI Advanced protocol, organised in three layers:

  • zencontrol.io: raw TPI Advanced UDP packet framing;
  • zencontrol.api: control surface for TPI Advanced API commands and events;
  • zencontrol.interface: an opinionated world model, suitable for smart-building integrations. It provides a fully resolved set of methods, objects, and callbacks for lights, groups, buttons, sensors and everything else in your zencontrol universe.

Documentation

In addition to its own test suite, this library is exercised heavily by zencontrol-simulator, a nearly feature-complete simulator of zencontrol hardware. As part of that suite, the simulator imports and drives this library to a substantial extent.

As a practical demonstration of the library in production use, zencontrol-homeassistant exposes the full capability of this library. Home Assistant is an open source smart building system ostensibly designed for residential homes, but is seeing increasing use in office environments too, because nothing else can match it for the sheer breadth of compatibility.

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 configuration and event emission if a controller reboots while the listener stays up
  • Multicast controller discovery — find controllers on the LAN without a preconfigured host
  • Fans and blinds — smart detection of fan and blind ECGs with a specific control plane for each
  • 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
  • Fans and blinds have not been tested with field-deployed hardware

Out of scope

  • Any commands involving DMX, Control4, or virtual instances (I don't have licenses for these, so I couldn't test them even if I wanted to — but the scaffolding is there if anyone wishes to add support)

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 address, 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

MIT

Metadata

Release files for zencontrol-python 3.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for zencontrol-python 3.1.0
File Size Uploaded
zencontrol_python-3.1.0.tar.gz 122.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for zencontrol-python 3.1.0
File Interpreter ABI Platform
zencontrol_python-3.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 207.4 kB

Release files / zencontrol_python-3.1.0.tar.gz

Download URL zencontrol_python-3.1.0.tar.gz
Size 122.0 kB
Tags Source
SHA-256 checksum
How to use checksums
86b1e5152e82c7caedfb96307a0ee0a539d44dbd8f8a1f932f65690b5396ebbb
BLAKE2b-256 checksum
How to use checksums
7b9f1d48d5745a29b53fa7e433233f124d5d2bab8a7231433b7d1de494f2f7e7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.8

Release files / zencontrol_python-3.1.0-py3-none-any.whl

Download URL zencontrol_python-3.1.0-py3-none-any.whl
Size 85.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
739c46eff448a03a2bdc0812d4bc99ea93e63abcd2d23cdf8a1047637c46e148
BLAKE2b-256 checksum
How to use checksums
be36c1cff7c59edbf0971a219feefb35e2c329203be1c8055d5011a1c2b447c2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.8

Release history Release notifications | RSS feed

This release

3.1.0 This release

2 release files

3.0.0

2 release files

2.5.0

2 release files

2.0.0

2 release files

1.0.0

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page