aliro_mqtt_bridge.py
Republish the lock's console log to MQTT as Home Assistant entities.
Overview
Republish the lock's console log to MQTT as Home Assistant entities.
Usage: aliro_mqtt_bridge.py --port /dev/tty.usbmodem1234 [--broker HOST] [--node NAME] aliro_mqtt_bridge.py --port - --dry-run < captured.log
Reads the UWB console line by line, extracts the per-block range line and the access verdict, and publishes them as two MQTT Discovery entities: a distance sensor in millimetres and an access event carrying granted/denied. Lines matching neither pattern are ignored.
The range line is gated on the firmware side behind CONFIG_WOZ_PRETTY_SHELL and
uwb_rxdiag_rng_get(), so it only appears once aliro frames on has been issued
on the shell. Without that, the access events still flow but distance stays
unpublished.
Reading from '-' takes the log on stdin, which with --dry-run exercises the parser and the payloads without a broker or a board attached. paho-mqtt is imported only when publishing, pyserial only for a real port, so neither is needed for a dry run.
API
Fparse_line(line: str) -> Optional[dict]
Return a reading dict for a range or access line, else None.
Zephyr prefixes every line with a timestamp and module tag, so both patterns are searched for rather than anchored.
mainFdiscovery_payloads(node: str) -> list[tuple[str, dict]]
Return (topic, config) pairs announcing both entities to Home Assistant.
mainFreading_to_message(node: str, reading: dict) -> tuple[str, str]
Map a parsed reading to the (topic, payload) that carries it.
mainFopen_lines(port: str, baud: int) -> Iterator[str]
Yield console lines from stdin ('-') or from a serial port.
mainUndocumented (1)
main