Skip to main content

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

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

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.

Metadata

Release files for broadlink-magic 0.1.1

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

Source distribution (sdist)

Source distribution for broadlink-magic 0.1.1
File Size Uploaded Provenance Actions
broadlink_magic-0.1.1.tar.gz 35.5 kB With provenance Details for broadlink_magic-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for broadlink-magic 0.1.1
File Interpreter ABI Platform Actions
broadlink_magic-0.1.1-py3-none-any.whl Python 3 none any Details for broadlink_magic-0.1.1-py3-none-any.whl

Total release size: 66.2 kB

Security for broadlink-magic 0.1.1

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.

Select from 2 files

A 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.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files Full provenance

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