Home

Awesome

hm2mqtt

Written and (C) 2015-16 Oliver Wagner owagner@tellerulam.com

Provided under the terms of the MIT license.

Overview

hm2mqtt is a gateway between a Homematic home automation system and MQTT.

It is intended as a building block in heterogenous smart home environments where an MQTT message broker is used as the centralized message bus. See https://github.com/mqtt-smarthome for a rationale and architectural overview.

hm2mqtt communicates with Homematic using the documented XML-RPC API and thus requires either an CCU1/CCU2 or a Homematic configuration adapter with the XML-RPC service running on a host (currently Windows-only). It is not able to talk directly to Homematic devices using 3rd party hardware like a CUL.

Dependencies

It is possible to run hm2mqtt directly on a CCU2, using the Embedded JRE. Courtesy of hobbyquaker, a CCU2 addon wrapper is available.

Build Status Automatically built jars (and the CCU2 addon) can be downloaded from the release page on GitHub at https://github.com/owagner/hm2mqtt/releases

Device names and topic structure

hm2mqtt will try to read device and channel names from the specified HM hosts using the ReGa TCL interface on port 8181. If this succeeds, channel names will be resolved into symbolic names before publishing.

The topics generated and accepted are of the form

prefix/function/channel/datapoint

The function is status for published status reports, set for inbound change requests, get to synchronously and activly request a value from a device, and command to send commands.

The channel is either the raw address or a name resolved by querying the ReGa.

Note that incoming messages are accepted on both the symbolic and the address channel name.

A special topic is prefix/connected. It holds an enum value which denotes whether the adapter is currently running (1) and connected to HM (2). It's set to 0 on disconnect using a MQTT will.

Homematic Data types

Homematic datapoints can have a variety of data types:

hm2mqtt needs to know the type of a data point in order to properly encode the outgoing messages. Types are obtained using getParamsetDescription calls when new devices show up, and are cached in the device cache file.

Registering as a link partner

An application (like hm2mqtt) can tell an interface server (rfd/hs485d) that it is activly using a datapoint. This will in turn cause the interface server to register itself as a link partner with the remote device.

This means that everytime the remote device sends a status message, it expects the interface server to acknowledge this (true bidirectional communication), like it does with any other direct link partners.

If the interface server is not linked with the device, it will still receive and process status messages. However, there is no bidirectional communication in that case -- if the interface server does, for any reason (like RF interference), not receive a status message, the remote device will not resend it. This particular behavior is often not well understood.

hm2mqtt will not automatically register itself as a user of a datapoint. You can do this manually by publishing to the bind/unbind command, or e.g. using https://github.com/hobbyquaker/homematic-manager

MQTT Message format

The message format generated is a JSON encoded object with the following members:

Datapoints with type ACTION are sent with the MQTT retain flag set to false, all others with retain set to true. _ACTION_s e.G. are press reports (PRESS_SHORT, PRESS_LONG, PRESS_CONT)

Usage

Configuration options can either be specified on the command line, or as system properties with the prefix "hm2mqtt". Examples:

java -jar hm2mqtt.jar hm.host=192.168.0.10

java -Dhm.hm.host=192.168.0.10 -jar hm2mqtt.jar

Available options:

See also

Changelog