From 8541f1e0def8b6ed4cb0960ab603a8d88d18a761 Mon Sep 17 00:00:00 2001 From: lukie80 Date: Wed, 4 Oct 2017 07:50:45 +0200 Subject: [PATCH] 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. --- source/_docs/mqtt/discovery.markdown | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/source/_docs/mqtt/discovery.markdown b/source/_docs/mqtt/discovery.markdown index 38be23ffab0..07b68640113 100644 --- a/source/_docs/mqtt/discovery.markdown +++ b/source/_docs/mqtt/discovery.markdown @@ -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 }`