MQTT API for RF-HUB

API Updated 2026-05-27

RF-HUB's MQTT API exposes all functionality via two topic tree branches and follows the Home Assistant Discovery format. This means RF-HUB integrates plug-and-play with Home Assistant and works with virtually any MQTT client.

For simple calls and scripts directly against the hub, there is also a REST API — see RF-HUB API.

Prerequisites

  • An MQTT broker (typically Mosquitto, often together with Home Assistant).
  • RF-HUB configured to the same broker — see Connect RF-Hub to Home Assistant.
  • Your device's UID — you can find it in the RF-HUB web interface under the Info tab.

Topic structure

RF-HUB uses two topic tree branches:

  • styrahem/rfhub/<UID>/... — own state and commands
  • homeassistant/... — Home Assistant Discovery configurations (retained)

State (what RF-HUB publishes)

styrahem/rfhub/<UID>/rfhub/info                          # online status + firmware version
styrahem/rfhub/<UID>/<device-id>-<nr>/<type>           # current status per device/endpoint

Commands (what RF-HUB listens to)

styrahem/rfhub/<UID>/<device>/<endpoint>/set/...        # send commands here

Discovery configuration (retained, automatic integration in HA)

homeassistant/<entity_type>/<unique_id>/<name>/config

The Discovery messages contain, among other things, state_topic, command_topic, and availability so that HA (or another client that speaks HA Discovery) automatically sets up the entities.

Example — turn on a switch via mosquitto_pub

mosquitto_pub -h homeassistant.local -t   homeassistant/switch/rfhub_kok_taklampa/set -m ON

Example — listen for events in Python

import paho.mqtt.client as mqtt

UID = "ABCD1234"  # from the Info tab in the RF-HUB web interface

def on_message(client, userdata, msg):
    print(f"{msg.topic} -> {msg.payload.decode()}")

c = mqtt.Client()
c.connect("homeassistant.local", 1883)
c.subscribe(f"styrahem/rfhub/{UID}/+/+")
c.on_message = on_message
c.loop_forever()

WebSocket API

The web interface uses WebSocket for real-time updates, but it is an internal protocol that may change between firmware versions. For integrations, we recommend REST or MQTT.

Questions

Need details on a specific topic or payload — get in touch.