mirror of
https://github.com/home-assistant/home-assistant.io.git
synced 2025-07-22 16:56:50 +00:00
Added new kind of example and added description (#3510)
Added a new sensor example which requires multiple configuration topics but one state topic. I'm convinced that this example is very widespread and is useful for beginners (like me). Added sentence to outline the idea of MQTT discovery.
This commit is contained in:
parent
dd6c65d28b
commit
8541f1e0de
@ -11,7 +11,7 @@ logo: mqtt.png
|
||||
redirect_from: /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](/components/binary_sensor.http/) and the [HTTP sensor](/components/sensor.http/).
|
||||
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](/components/binary_sensor.http/) and the [HTTP sensor](/components/sensor.http/). The basic idea is that the device itself adds its configuration into your `configuration.yaml` automatically. To prevent multiple identical entries if a device reconnects a unique identifier is necessary. Two parts are required on the device side: The configuration topic which contains the necessary device type and unique identifier and the remaining device configuration without the device type.
|
||||
|
||||
Supported by MQTT discovery:
|
||||
|
||||
@ -83,3 +83,11 @@ Set the state.
|
||||
```bash
|
||||
$ mosquitto_pub -h 127.0.0.1 -p 1883 -t "homeassistant/switch/irrigation/set" -m ON
|
||||
```
|
||||
|
||||
Setting up a sensor with multiple measurement values requires multiple consecutive configuration topic submissions.
|
||||
|
||||
- Configuration topic no1: `homeassistant/sensor/sensorBedroomT/config`
|
||||
- Configuration payload no1: `{"device_class": "sensor", "name": "Temperature", "state_topic": "homeassistant/sensor/sensorBedroom/state", "unit_of_measurement": "°C", "value_template": "{{ value_json.temperature}}" }`
|
||||
- Configuration topic no2: `homeassistant/sensor/sensorBedroomH/config`
|
||||
- Configuration payload no2: `{"device_class": "sensor", "name": "Humidity", "state_topic": "homeassistant/sensor/sensorBedroom/state", "unit_of_measurement": "%", "value_template": "{{ value_json.humidity}}" }`
|
||||
- Common state payload: `{ "temperature": 23.20, "humidity": 43.70 }`
|
||||
|
Loading…
x
Reference in New Issue
Block a user