
* Split MQTT documentation * Add more details * Move content to /docs * Enable sidebar * Move content to /docs * Enable sidebar * Move content * Update links * Remove wizard stuff * Enable sidebar * Minor changes * Move MQTT parts to /docs * update links * Update links and sync content * Fix link * Enable sidebar * Remove navigation * Remove navigation and other minor updates * Update links * Add overview page * Make title linkable * Update * Plit content * Update links * Rearrange content * New getting-started section * Add icons for docs * Update for new structure * Update for new structure * Add docs navigation * Add docs overview page * Remove ecosystem navigation * Add docs and remove other collections * Move ecosystem to docs * Remove duplicate files * Re-add ecosystem overview * Move to ecosystem * Fix permission * Update navigation * Remove collection * Move overview to right folder * Move mqtt to upper level * Move notebook to ecosystem * Remove un-used files * Add one more rectangle for iOS * Move two parts back from docs and rename Run step * Remove colon * update getting-started section * Add redirect * Update * Update navigation
2.5 KiB
layout | title | description | date | sidebar | comments | sharing | footer | logo | redirect_from |
---|---|---|---|---|---|---|---|---|---|
page | MQTT Discovery | Instructions how to setup MQTT Discovery within Home Assistant. | 2015-08-07 18:00 | true | false | true | true | mqtt.png | /components/mqtt/#discovery |
The discovery of MQTT devices will enable one to use MQTT devices with only minimal configuration effort on the side of Home Assistant. The configuration is done on the device itself and the topic used by the device. Similar to the HTTP binary sensor and the HTTP sensor. Only support for binary sensor is available at the moment.
To enable MQTT discovery, add the following to your configuration.yaml
file:
# Example configuration.yaml entry
mqtt:
discovery: true
discovery_prefix: homeassistant
Configuration variables:
- discovery (Optional): If the MQTT discovery should be enabled or not. Defaults to
False
. - discovery_prefix (Optional): The prefix for the discovery topic. Defaults to
homeassistant
.
The discovery topic need to follow a specific format:
<discovery_prefix>/<component>/<object_id>/<>
<component>
: One of the supported components, eg.binary_sensor
.<object_id>
: The ID of the device. This will become theentity_id
in Home Assistant.<config>
: The topicconfig
orstate
which defines the current action.
The payload will be checked like an entry in your configuration.yaml
file if a new device is added. This means that missing variables will be filled with the platform's default values.
{% linkable_title Example %}
A motion detection device which can be represented by a binary sensor for your garden would sent its configuration as JSON payload to the Configuration topic. After the first message to config
, then the MQTT messages sent to the State topic will update the state in Home Assistant.
- Configuration topic:
homeassistant/binary_sensor/garden/config
- State topic:
homeassistant/binary_sensor/garden/state
- Payload:
{"name": "garden", "sensor_class": "motion"}
To create a new sensor manually. For more details please refer to the MQTT testing section.
$ mosquitto_pub -h 127.0.0.1 -p 1883 -t "homeassistant/binary_sensor/garden/config" -m '{"name": "garden", "sensor_class": "motion"}'
Update the state.
$ mosquitto_pub -h 127.0.0.1 -p 1883 -t "homeassistant/binary_sensor/garden/state" -m ON