Metadata-Version: 2.4
Name: dalicontrol-e64
Version: 0.2.0
Summary: Unofficial protocol notes and Python tools for the IPAS DaliControl e64 KNX/DALI gateway
Author: NashEQify
License-Expression: MIT
Project-URL: Homepage, https://github.com/NashEQify/dalicontrol-e64
Project-URL: Documentation, https://github.com/NashEQify/dalicontrol-e64/tree/main/docs
Project-URL: Issues, https://github.com/NashEQify/dalicontrol-e64/issues
Keywords: dali,knx,ipas,dalicontrol,e64,lighting,home-assistant,home-automation
Classifier: Development Status :: 4 - Beta
Classifier: Framework :: AsyncIO
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Home Automation
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Provides-Extra: knx
Requires-Dist: xknx>=3; extra == "knx"
Dynamic: license-file

# dalicontrol-e64

Unofficial protocol notes, field experience and a small Python library for the
**IPAS DaliControl e64** KNX/DALI gateway.

The gateway is usually commissioned once with ETS and then only reached
through KNX group addresses. It can do more: its built-in web page uses a plain
HTTP interface, and the same commands can be sent over KNX without any ETS
change. Neither is documented by the manufacturer. This repository writes down
what was found while building a lighting control for a flat with 38 DALI
ballasts, including the parts that went wrong.

Use it with or without a home automation system.

## No ETS, no DCA, no KNX software

For working with the DALI side you do not need ETS, the DCA plug-in, an ETS
licence or any other KNX vendor software. Switching and dimming channels,
assigning groups, storing and recalling scenes and starting a DALI new
installation all work with this repository alone: over HTTP with a browser,
curl or Python, or over KNX with a free KNXnet/IP library such as
[xknx](https://github.com/XKNX/xknx).

ETS is only needed for the KNX side of the gateway: its individual address,
group objects and KNX application parameters. If the gateway was commissioned
once, you can leave that untouched. If you only use the HTTP interface, the
KNX side does not matter at all.

> **Tested on one device type and firmware only:** DaliControl e64, firmware
> 1.3_06, ETS application e64-01-0110. Not affiliated with or endorsed by
> IPAS. Several commands re-address or reconfigure your installation and have
> no confirmation step. Read [the command table](docs/http-api.md#commands)
> before you send anything. You act at your own risk.

## What is in here

| | |
|---|---|
| [docs/http-api.md](docs/http-api.md) | The HTTP interface: request format, every command with its risk, readable properties, timing |
| [docs/knx-management.md](docs/knx-management.md) | The same commands over KNX, with the gateway's LAN cable unplugged; reading ETS parameters without ETS |
| [docs/scenes.md](docs/scenes.md) | How DALI scenes are stored and recalled, and how to use them from software |
| [docs/lessons-learned.md](docs/lessons-learned.md) | What failed and what replaced it |
| [docs/home-automation.md](docs/home-automation.md) | Home Assistant, Node-RED, openHAB, ioBroker: from one HTTP request to a full integration |
| `src/dalicontrol_e64/` | Python library on PyPI: command encoding with an allowlist, HTTP client, KNX transport, request queue |
| `custom_components/dalicontrol_e64/` | Home Assistant integration (HACS): one light per channel, scene recall, all on/off, HTTP or KNX |

## Five things to know first

1. `010000` starts a DALI new installation. Nothing about the bytes tells you.
2. The answer `00` means "accepted". It does not mean a lamp reacted.
3. The channel-state read is a cache and is wrong after programming writes.
4. One scene recall beats twenty single-channel writes. Use the 16 slots.
5. If lights react late or not at all, check whether the gateway restarts
   itself every few minutes while its Ethernet port is connected.

## Home Assistant

Add this repository in HACS as a custom repository (type *Integration*),
install *DaliControl e64*, restart, then add the integration with the
gateway's IP address or its KNX individual address. Details, a YAML-only
alternative and examples for Node-RED, openHAB and ioBroker:
[docs/home-automation.md](docs/home-automation.md).

## Quick start (Python)

```bash
pip install dalicontrol-e64
```

```python
from dalicontrol_e64 import HttpClient, commands

gateway = HttpClient("192.0.2.10")          # the gateway's IP address
print(gateway.reachable())                  # read-only check

gateway.send(commands.level(4, 255))        # channel 4 to 100 %
gateway.send(commands.level(4, 0))          # channel 4 off
gateway.send(commands.scene_recall(5))      # recall scene slot 5
gateway.send(commands.ALL_OFF)
```

`send` refuses everything that is not a level, a scene recall or all-off, and
raises unless the gateway answers `00`.

With curl, no library needed:

```bash
curl -sS --max-time 15 'http://192.0.2.10/?x=F6C35101DA000100010B03FF'   # channel 4 on
```

### Over KNX

```bash
pip install "dalicontrol-e64[knx]"
```

```python
from dalicontrol_e64.knx import KnxTransport

transport = KnxTransport(lambda: xknx, "1.1.2")   # connected XKNX, gateway's individual address
await transport.send(commands.scene_recall(5))
```

### Many callers, one gateway

`Writer` serialises requests from switches, apps and automations. A newer
request replaces older waiting targets for the same channels; a failed write
aborts what is waiting instead of retrying.

```python
from dalicontrol_e64 import Writer, Macro, commands

writer = Writer(transport.send)                 # or an async wrapper around HttpClient.send
job = writer.submit({14: 0, 15: 0, 16: 0, 17: 200}, label="dining strip white")
result = await job.future                       # {'status': 'completed', 'commands': [...], ...}

room = {c: 0 for c in range(20, 28)}
writer.submit(room, macro=Macro(commands.scene_recall(8), dict(room)))   # one command
```

The Home Assistant integration in `custom_components/` is built on exactly
these two parts and reuses the KNX integration's connection.

## Tests

```bash
PYTHONPATH=src python3 -m unittest discover -s tests            # library
pip install pytest-homeassistant-custom-component xknx -e .
python3 -m pytest                                                # Home Assistant integration (Python 3.13)
```

The tests run against a simulated device. They prove the encoding, the
allowlist and the queue logic, not the behaviour of your hardware.

## Contributing

Reports from other firmware versions, the e64 Pro, or decoded error flags and
properties are welcome. Please say what you observed on the lamps, not only
what the gateway answered.

## License

MIT, see [LICENSE](LICENSE).
