-
Notifications
You must be signed in to change notification settings - Fork 41
Home Assistant MQTT Discovery
Since release: v0.5.0
If you're upgrading from a previous release, your config.h file needs to be updated with the following constants:
- MQTT_HOMEASSISTANT_DISCOVERY_ENABLED
- MQTT_HOMEASSISTANT_DISCOVERY_PREFIX
Please compare your version of these files to the new config.example.h
If you prefer to have Home Assistant set up your Ai-Thinker LED RGBW Light automatically, then follow the steps below. AiLight supports Home Assistants' MQTT Discovery functionality, which avoids any manual configuration in Home Assistant.
By default, the MQTT Discovery functionality in Home Assistant is disabled, so first thing to do is enable it. To do that, simply add discovery: true
to your MQTT configuration. Additionally, you can set the discovery prefix used by Home Assistant. Your configuration should look something like this:
mqtt:
broker: <YOUR_MQTT_SERVER_ADDRESS>
port: <YOUR_MQTT_PORT>
client_id: home-assistant // Not required
username: <YOUR_MQTT_USERNAME>
password: <YOUR_MQTT_PASSWORD>
discovery: true
discovery_prefix: homeassistant // 'homeassistant' is the default prefix, but can of course be changed
Next step is telling AiLight to use MQTT Discovery:
- Navigate to the 'Settings' page in the Web UI
- Enable MQTT Discovery by simply switching it on.
- If enabled, an input field for the 'Discovery Prefix' setting will appear. If this is the first time enabling it, it is defaulted to 'homeassistant'. If you like to change this, make sure the
discovery_prefix
setting in Home Assistant is the same (see above). - Press 'Save'
Once saved, AiLight will notify your Home Assistant instance about the new light and your Ai-Thinker LED RGBW Light will appear almost instantaneously in Home Assistant.
Some notes:
- AiLight will remember that your Ai-Thinker LED RGBW Light has been discovered already, so you need to do this configuration only once.
- AiLight will 'forget' the discovery if you change the hostname of your Ai-Thinker LED RGBW Light. This is because the hostname is used as the display name in Home Assistant.
- If you disable the MQTT discovery, AiLight will 'forget' the discovery, however you will see that in Home Assistant your Ai-Thinker LED RGBW Light is still present. This is because Home Assistant performs the discovery on runtime and currently there is no way to notify Home Assistant a device is no longer needed in the configuration. You will need to restart Home Assistant to have your Ai-Thinker LED RGBW Light removed.
- You can choose your own default discovery prefix by setting it in your 'config.h' file. This is especially convenient if you have many Ai-Thinker LED RGBW Lights you want to be discovered by Home Assistant.
Getting started
Home Assistant
Using the Firmware
Advanced topics