Home Assistant custom integration for controlling Hafele LED lights via MQTT using local control. You need a "Gateway, Häfele Connect Mesh"-device which will be the bridge between the Bluetooth LE network and the MQTT.
Please note that this should be considered unstable and is definitely in an alpha stage.
Important: When installing this integration in Home Assistant, you need to copy the entire custom_components/hafele_local_mqtt/ folder to your Home Assistant's custom_components/ directory. The custom_components/ folder structure is required for Home Assistant to recognize the integration.
- ✅ Auto-discovery of Hafele devices from MQTT topics
- ✅ Light control (on/off, brightness)
- ✅ Status polling to keep device states up to date
- ✅ Configurable polling intervals
The first part of installation should be enabling the MQTT functionality on your hafele devices. Please follow directions found in this github issue: qnimbus/haefele-connect-mesh#2 and the official documentation Gateway into Network integration and Local MQTT setup and Network upload
I ended up installing Mosquito Broker and MQTT Explorer on my HA instance as well to facilitate the installation.
- Open HACS in Home Assistant
- Go to Integrations
- Click the three dots menu (⋮) in the top right
- Select "Custom repositories"
- Add repository:
https://github.com/josephyanks/ha-hafele-mqtt-integration - Select category: "Integration"
- Click "Add"
- Find "Hafele Local MQTT" in HACS and install it
- Restart Home Assistant
- Go to Settings > Devices & Services > Add Integration
- Search for "Hafele Local MQTT" and follow the setup wizard
- Download or clone this repository
- Copy the
custom_components/hafele_local_mqttfolder to your Home Assistantconfig/custom_components/directory - Restart Home Assistant
- Go to Settings > Devices & Services > Add Integration
- Search for "Hafele Local MQTT" and follow the setup wizard
- Home Assistant 2024.1 or later
- MQTT broker configured in Home Assistant
- Hafele devices configured to publish to MQTT topics
The integration will guide you through setup via the config flow. You can configure:
- MQTT topic prefix (default:
hafele) - Polling interval (default: 60 seconds)
- Polling timeout (default: 5 seconds)
- Enable/disable group entities
- Enable/disable scene entities
The integration uses the following MQTT topics:
hafele/lights- JSON array of light deviceshafele/groups- JSON array of groupshafele/scenes- JSON array of scenes
hafele/device/{device_addr}/set- Control individual lightshafele/device/{device_addr}/get- Request device status
hafele/device/{device_addr}/statusorhafele/device/{device_addr}/response- Device status responses
Note: The exact topic patterns may need to be adjusted based on your Hafele MQTT API documentation. You can modify these in custom_components/hafele_local_mqtt/const.py if needed.
Uses the kind-of-public Hafele MQTT api for connect mesh
-
Discovery: The integration subscribes to MQTT discovery topics (
hafele/lights,hafele/groups,hafele/scenes) to automatically discover your Hafele devices. -
Status Polling: Since Hafele devices don't automatically publish state updates, the integration uses a polling mechanism:
- Publishes status requests to each device at regular intervals
- Subscribes to response topics to receive status updates
- Updates entity states based on received responses
-
Control: When you control a light in Home Assistant, the integration publishes MQTT commands to the appropriate control topic.
- Verify MQTT broker is connected in Home Assistant
- Check that Hafele devices are publishing to the discovery topics
- Use an MQTT client to verify messages are being published
- Check Home Assistant logs for errors
- Verify the status response topic matches your Hafele API
- Adjust polling interval/timeout in integration settings
- Check MQTT broker logs for message flow
- Verify device addresses match between discovery and status topics
- Ensure the folder structure is correct:
config/custom_components/hafele_local_mqtt/ - Check that all files are present in the integration folder
- Restart Home Assistant completely
- Check Home Assistant logs for import errors
- Color Temperature of Multiwhite lights not settable on single light / but working on Group Temperature setting in MQTT
- API / MQTT mismatch -> nowhere in the mqtt light temperature data is available
- Due to high polling rates or big networks the response time of buttons/inputs will decrease due to high bluetooh LE traffic
This integration is built following Home Assistant's custom integration guidelines. Key components:
__init__.py: Integration setup and entry pointconfig_flow.py: Configuration UIdiscovery.py: Device discovery from MQTT topicsmqtt_client.py: MQTT client wrapperlight.py: Light platform with polling coordinatorconst.py: Constants and MQTT topic patterns
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.
For issues, questions, or feature requests, please open an issue on GitHub.
This absolutely wouldn't have been possible without the work done by individuals in qnimbus/haefele-connect-mesh#2 - specifically to @qnimbus for reaching out to Hafele and figuring out about the firmware / internal mqtt api.
- Inspired by the ha-shellies-discovery project
- Built for the Home Assistant community