Merge branch 'current' into next

This commit is contained in:
Fabian Affolter 2018-05-08 09:36:29 +02:00
commit 01a57548f9
No known key found for this signature in database
GPG key ID: DDF3D6F44AAB1336
44 changed files with 223 additions and 108 deletions

View file

@ -16,10 +16,12 @@ ha_iot_class: depends
This `mqtt` sensor platform uses the MQTT message payload as the sensor value. If messages in this `state_topic` are published with *RETAIN* flag, the sensor will receive an instant update with last known value. Otherwise, the initial state will be undefined.
## {% linkable_title Configuration %}
To use your MQTT sensor in your installation, add the following to your `configuration.yaml` file:
```yaml
# Example configuration.yml entry
# Example configuration.yaml entry
sensor:
- platform: mqtt
state_topic: "home/bedroom/temperature"
@ -97,17 +99,17 @@ In this section you find some real life examples of how to use this sensor.
### {% linkable_title JSON attributes configuration %}
The example sensor below shows a configuration example which uses JSON in the state topic to add extra attributes. It also makes use of the availability topic. Attributes can then be extracted in [Templates](configuration/templating/#attributes); Example to extract data from the sensor below {% raw %}'{{ states.sensor.bs_client_name.attributes.ClientName }}'{% endraw %}.
The example sensor below shows a configuration example which uses JSON in the state topic to add extra attributes. It also makes use of the availability topic. Attributes can then be extracted in [Templates](/docs/configuration/templating/#attributes). For example, to extract the `ClientName` attribute from the sensor below, use a template similar to: {% raw %}`{{ state_attr('sensor.bs_rssi', 'ClientName') }}`{% endraw %}.
{% raw %}
```yaml
# Example configuration.yml entry
# Example configuration.yaml entry
sensor:
- platform: mqtt
state_topic: "HUISHS/BunnyShed/NodeHealthJSON"
name: "BS RSSI"
unit_of_measurement: "dBm"
value_template: '{{ value_json.RSSI }}'
state_topic: "HUISHS/BunnyShed/NodeHealthJSON"
unit_of_measurement: 'dBm'
value_template: "{{ value_json.RSSI }}"
availability_topic: "HUISHS/BunnyShed/status"
payload_available: "online"
payload_not_available: "offline"
@ -123,7 +125,7 @@ sensor:
### {% linkable_title Get battery level %}
If you are using the [Owntracks](/components/device_tracker.owntracks/) and enable the reporting of the battery level then you can use a MQTT sensor to keep track of your battery. A regular MQTT message from Owntracks looks like this:
If you are using the [OwnTracks](/components/device_tracker.owntracks/) and enable the reporting of the battery level then you can use a MQTT sensor to keep track of your battery. A regular MQTT message from OwnTracks looks like this:
```bash
owntracks/tablet/tablet {"_type":"location","lon":7.21,"t":"u","batt":92,"tst":144995643,"tid":"ta","acc":27,"lat":46.12}
@ -133,13 +135,13 @@ Thus the trick is extracting the battery level from the payload.
{% raw %}
```yaml
# Example configuration.yml entry
# Example configuration.yaml entry
sensor:
- platform: mqtt
state_topic: "owntracks/tablet/tablet"
name: "Battery Tablet"
unit_of_measurement: "%"
value_template: '{{ value_json.batt }}'
state_topic: "owntracks/tablet/tablet"
unit_of_measurement: '%'
value_template: "{{ value_json.batt }}"
```
{% endraw %}
@ -159,18 +161,18 @@ Then use this configuration example to extract the data from the payload:
{% raw %}
```yaml
# Example configuration.yml entry
# Example configuration.yaml entry
sensor:
- platform: mqtt
state_topic: 'office/sensor1'
name: 'Temperature'
name: "Temperature"
state_topic: "office/sensor1"
unit_of_measurement: '°C'
value_template: '{{ value_json.temperature }}'
value_template: "{{ value_json.temperature }}"
- platform: mqtt
state_topic: 'office/sensor1'
name: 'Humidity'
name: "Humidity"
state_topic: "office/sensor1"
unit_of_measurement: '%'
value_template: '{{ value_json.humidity }}'
value_template: "{{ value_json.humidity }}"
```
{% endraw %}
@ -195,10 +197,10 @@ The configuration will look like the example below:
{% raw %}
```yaml
# Example configuration.yml entry
# Example configuration.yaml entry
sensor:
- platform: mqtt
state_topic: 'home/bathroom/analog/brightness'
name: Brightness
name: "Brightness"
state_topic: "home/bathroom/analog/brightness"
```
{% endraw %}