# hm2mqtt [![mqtt-smarthome](https://img.shields.io/badge/mqtt-smarthome-blue.svg)](https://github.com/mqtt-smarthome/mqtt-smarthome) [![NPM version](https://badge.fury.io/js/hm2mqtt.svg)](http://badge.fury.io/js/hm2mqtt) [![CI](https://github.com/hobbyquaker/hm2mqtt.js/actions/workflows/ci.yml/badge.svg)](https://github.com/hobbyquaker/hm2mqtt.js/actions/workflows/ci.yml) [![License](https://img.shields.io/badge/License-MIT-blue.svg?style=flat)](LICENSE) > Interface between the Homematic CCU and MQTT hm2mqtt connects a Homematic CCU (CCU2/CCU3/RaspberryMatic — BidCos-RF, BidCos-Wired, HmIP-RF, virtual devices/groups, CUxD, ReGaHSS variables and programs) to an MQTT broker following the [mqtt-smarthome](https://github.com/mqtt-smarthome/mqtt-smarthome) convention. Version 3 is an adapter on [mqtt-interfaces-core](https://github.com/hobbyquaker/mqtt-interfaces-core) and a drop-in replacement for the `ccu-mqtt` node of [node-red-contrib-ccu](https://github.com/rdmtc/node-red-contrib-ccu): same topics, same payloads. Contents: [Install](#install) · [Options](#options) · [Topics](#topics) · [Payloads](#payloads) · [Names](#names) · [Home Assistant](#home-assistant) · [Migration](#migration) · [Development](#development) ## Install Node.js ≥ 20.19. The host must be reachable from the CCU: the interface processes call back on `--xmlrpc-port` 2126 (and 2127 for binrpc/CUxD) — open them in the host firewall and, on a CCU with the firewall set to _restricted_, allow the host in the CCU's firewall settings. ``` npm install -g hm2mqtt hm2mqtt -a homematic-ccu3 -u mqtt://broker # foreground sudo hm2mqtt --install -n hm -a homematic-ccu3 -u mqtt://broker # systemd service hm2mqtt@hm ``` `--install` writes the template unit `/etc/systemd/system/hm2mqtt@.service`, the instance config `/etc/hm2mqtt/hm.env` (every option as `HM2MQTT_*`) and uses `/var/lib/hm2mqtt/hm/` as state directory; broker credentials can live in the shared `/etc/mqtt-interfaces/broker.env`. `--uninstall -n hm` removes the instance. `--config-schema` prints a JSON schema of all options (management UIs like [she](https://github.com/hobbyquaker/she) build their config forms from it). Docker (multi-arch image for amd64, arm64 and armv7): ``` docker run -d --name hm2mqtt --restart unless-stopped --network host -v hm2mqtt:/data \ -e HM2MQTT_CCU_ADDRESS=homematic-ccu3 -e HM2MQTT_MQTT_URL=mqtt://broker \ ghcr.io/hobbyquaker/hm2mqtt.js ``` Host networking, or publish 2126/2127 and set `HM2MQTT_INIT_ADDRESS` to the docker host's address so the CCU can call back. `--restart unless-stopped` brings it back after `maintenance/set/restart`. ### On the CCU itself (addon package) For a setup without a server: hm2mqtt also ships as an addon for the Homematic CCU3, [openccu-lite](https://github.com/hobbyquaker/openccu-lite) and OpenCCU. On a CCU3 or OpenCCU it is installed in the WebUI under _Systemsteuerung → Zusatzsoftware_. Pick the package for your hardware from the [latest release](https://github.com/hobbyquaker/hm2mqtt.js/releases/latest): | Platform | Package | | ---------------------------------------------------------------- | -------------------------------------- | | CCU3 with the official eQ-3 firmware, ELV-Charly, OpenCCU 32-bit | `hm2mqtt-ccu-armv7l-.tar.gz` | | OpenCCU 64-bit (Raspberry Pi 4/5) | `hm2mqtt-ccu-aarch64-.tar.gz` | | OpenCCU on x86_64 (debmatic, virtual machines) | `hm2mqtt-ccu-x86_64-.tar.gz` | The architecture decides, not the firmware — `uname -m` on the CCU says which one it is. A CCU3 with the original eQ-3 firmware is always `armv7l`. Each package has a `.sha256` next to it. After the install a **hm2mqtt** button appears in _Systemsteuerung_: it configures every option of this README in a form, starts and stops the service and shows the log. The only setting that has to be made is the broker URL — a CCU has no MQTT broker of its own, so point hm2mqtt at one on your network (or install the Mosquitto addon). Everything the addon needs lives in `/usr/local/addons/hm2mqtt`, including its own Node.js runtime (the CCU3's firmware is far too old to run a current Node, so the addon brings a musl build that depends on nothing outside its own directory — another addon's Node.js is neither used nor disturbed). On the CCU it talks to the interface processes directly instead of through lighttpd: binrpc on 32001/32000 for BidCos, hmipserver on 32010, ReGa on 8183 — no CCU authentication, no firewall rules, and nothing of hm2mqtt listening on the network. `--local` / `--no-local` overrides the automatic detection. The addon packages are marked `-beta` until someone has confirmed an install on real hardware. On [openccu-lite](#openccu-lite) the same package is installed from the system's addon catalogue (_Addons → Catalogue_); there is nothing to download by hand. ## Finding the CCU ``` hm2mqtt --discover ``` broadcasts the eQ-3 discovery datagram (UDP 43439) and prints every CCU that answers, with its firmware version and the interfaces whose ports are open: ``` 192.168.1.10 eQ3-HmIP-CCU3-App serial 3014F711A0000000000ABCDE [ReGa BidCos-RF BidCos-Wired HmIP-RF VirtualDevices] (udp) ``` `--discover-json` prints the same as JSON. `-a auto` runs the scan at start and uses the CCU it found — it refuses to start when none or more than one answers, rather than bridging the wrong house: ``` hm2mqtt -a auto -u mqtt://broker ``` A broadcast does not cross a router. If the CCU is on another subnet — a separate VLAN for the house automation is a common setup — name it (or its subnet's broadcast address): ``` hm2mqtt --discover --discover-address 192.168.1.10 hm2mqtt -a auto --discover-address 192.168.1.255 -u mqtt://broker ``` `--discover-timeout` (default 5 s) is how long the scan listens. The scanning itself lives in [mqtt-interfaces-core](https://github.com/hobbyquaker/mqtt-interfaces-core); this adapter only declares the probe and the interface ports ([lib/discovery.js](lib/discovery.js)). The probe and the reply layout come from [hm-discover](https://github.com/hobbyquaker/hm-discover). ## Options `hm2mqtt --help` lists everything; every option is also an environment variable `HM2MQTT_