esi-r2d7
Async Python client for ESI R2D7 RS-232 blind and shade controllers (now Hunter Douglas; also used with Draper shades). Built on serialx, so it works with local serial ports and with any URL that serialx can open, such as socket:// or the Home Assistant Connect AUX-2 ESPHome serial proxy.
This library holds the protocol code for the Home Assistant ESI R2D7 integration. It has no Home Assistant dependency.
Install
pip install esi-r2d7
Use
import asyncio
from esi_r2d7 import R2D7Connection
async def main() -> None:
r2d7 = R2D7Connection("/dev/ttyUSB0", system=1)
await r2d7.connect()
await r2d7.open_blind(4) # sends *1o04;
await r2d7.close_blind(5) # sends *1c05;
await r2d7.stop_system() # sends *1s; - stops EVERY moving blind on system 1
await r2d7.disconnect()
asyncio.run(main())
The serial settings are fixed at 9600 baud, 8 data bits, no parity, 1 stop bit.
Important: Stop is system-wide
The R2D7 has no per-blind stop. The v4.1 protocol, footnote 15, says STOP is universal, and a channel suffix such as *1s05; is ignored. Real hardware confirms this. So the library offers only stop_system(), and command(1, "s", 4) raises ValueError.
Behaviour
command(system, operation, channel)builds one frame. System is 1–7, channel is 1–60, operation is"o","c"or"s". Any other input raisesValueError; a malformed frame never reaches the wire.- One connection, one lock: commands from many callers never interleave bytes.
- Stops sent within
STOP_COALESCE_SECONDS(0.3 s) collapse into one frame, unless an Open or Close was sent in between, or the link dropped. - If a write fails, Stop is sent again once after a reconnect. Open and Close are not resent, because a repeated Open or Close can act as a stop on some motor controls.
- A reader task watches the link.
add_listener()callbacks run when the link comes up or is lost. - Controller replies
U(not understood),O(buffer overflow) and X-off are logged and counted (rejected_commands,buffer_overflows). They are not acted on yet. take_recently_moved(window)returns the channels sent Open or Close in the lastwindowseconds, so a caller can mark them as stopped after a Stop.CONNECT_ERRORSlists every exception a caller should catch for connection problems.
Limitations
- No command pacing yet. The controller has a 256-byte buffer and discards everything on overflow, so avoid sending more than about 20 commands at once.
- The controller reports no position.
Tests
pip install -e ".[test]"
pytest
The tests use a fake R2D7 on a loopback socket and real serialx. No hardware is needed.
Releasing
Publishing uses PyPI trusted publishing, so no PyPI token is stored in GitHub.
- One time: on pypi.org, add a pending trusted publisher for project
esi-r2d7, ownerdavidfi01, repositoryesi-r2d7, workflowpublish.yml, environmentpypi. - Set
versioninpyproject.toml, commit and push. - Publish a GitHub release named
vX.Y.Z. ThePublish to PyPIworkflow builds and uploads it.
License
Apache License 2.0. See LICENSE.
Metadata
Release files for esi-r2d7 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| esi_r2d7-0.1.0.tar.gz | 12.8 kB | With provenance | Details for esi_r2d7-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| esi_r2d7-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for esi_r2d7-0.1.0-py3-none-any.whl |
Total release size: 23.5 kB
Release files / esi_r2d7-0.1.0.tar.gz
| Download URL | esi_r2d7-0.1.0.tar.gz |
|---|---|
| Size | 12.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f4426974f1d320a78057afce4d02f66eaaacad6dd51aec82879aaaecee8c9ce5
|
|
BLAKE2b-256 checksum How to use checksums |
007edceefdf2dc145d12057e4f6731ecbefbc1b79b94248e47528577604ca972
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 23, 2026.
Transparency logRelease files / esi_r2d7-0.1.0-py3-none-any.whl
| Download URL | esi_r2d7-0.1.0-py3-none-any.whl |
|---|---|
| Size | 10.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
dd788bd363df8ed7222a8abd1d2e8905f61214def00386f03f51ea966d14a1c8
|
|
BLAKE2b-256 checksum How to use checksums |
eae77d70b95e6536a533d75a3af107d4c3de49f41314db104f9b71b638bc570a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 23, 2026.
Transparency logSecurity for esi-r2d7 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for esi_r2d7-0.1.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 23, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.