Metadata-Version: 2.4
Name: broadlink-magic
Version: 0.1.1
Summary: Local LAN protocol for BroadLink Magic Home families
Author: BroadLink
Maintainer: BroadLink
License-Expression: MIT
Project-URL: Homepage, https://github.com/ibroadlink/broadlink-magic
Project-URL: Source, https://github.com/ibroadlink/broadlink-magic
Project-URL: Issues, https://github.com/ibroadlink/broadlink-magic/issues
Project-URL: Changelog, https://github.com/ibroadlink/broadlink-magic/blob/main/CHANGELOG.md
Keywords: broadlink,magic-home,rm-max,home-assistant
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Home Automation
Classifier: Typing :: Typed
Requires-Python: >=3.13
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: cryptography>=43
Provides-Extra: dev
Requires-Dist: pytest>=8; extra == "dev"
Requires-Dist: pytest-asyncio>=0.25; extra == "dev"
Requires-Dist: ruff>=0.5; extra == "dev"
Requires-Dist: build; extra == "dev"
Dynamic: license-file

# broadlink-magic

Python library for the local LAN protocol of BroadLink Magic Home families,
maintained by BroadLink. It powers the Broadlink Magic Home integration in
Home Assistant.

A Magic Home family is set up in the BroadLink app. The family's gateways
(for example the RM MAX) connect to a UDP server on the local network
(port 12346 by default). The server answers discovery and heartbeat messages,
receives status uploads, and sends control packets for the family's devices.

## Install

```bash
pip install broadlink-magic
```

Requires Python 3.13 or newer.

## What it covers

- Parsing the family export the BroadLink app uploads (`import_data`).
- The gateway session: message framing, discovery, heartbeat, status upload
  and query, and control (`inbound`, `gateway`).
- Payload encoding for lights, switches, curtains, air conditioners and
  three-in-one climate devices.
- Remote-controlled devices learned on an RM MAX (`remote`).

## Security

The gateway protocol has no authentication. The server identifies a gateway
by the MAC address in its discovery and heartbeat messages, and the session
follows the address those messages come from, so a gateway that changes its
IP address or port reconnects right away. Another host on the same network
that knows the gateway's MAC address can therefore take over its session.
The library logs a warning whenever a session moves. Use it on a trusted
local network only, and do not expose the UDP port to the internet or to
untrusted networks.

Device and family keys are kept out of the `repr` of the data classes, so
logging a device or family does not write them to the log.

## Development

```bash
python -m venv .venv
.venv/bin/pip install -e ".[dev]"
.venv/bin/ruff check .
.venv/bin/ruff format --check .
.venv/bin/pytest
```

## Releases

Pushing a `v*` tag that matches the version in `pyproject.toml` publishes the
package to PyPI through trusted publishing. See `CHANGELOG.md`.

## License

MIT. See `LICENSE`.
