Update binary_sensor.mqtt.markdown for #19195 (#8021)

* Update binary_sensor.mqtt.markdown

* Update binary_sensor.mqtt.markdown

* Update source/_components/binary_sensor.mqtt.markdown

Co-Authored-By: emontnemery <erik@montnemery.com>

* Update source/_components/binary_sensor.mqtt.markdown

Co-Authored-By: emontnemery <erik@montnemery.com>

* Update source/_components/binary_sensor.mqtt.markdown

Co-Authored-By: emontnemery <erik@montnemery.com>
This commit is contained in:
emontnemery 2019-01-02 20:23:34 +01:00 committed by Franck Nijhof
parent a730cd97bc
commit 386a104517

View File

@ -86,7 +86,7 @@ device_class:
required: false required: false
type: string type: string
value_template: value_template:
description: Defines a [template](/docs/configuration/templating/#processing-incoming-data) to extract a value from the payload. description: "Defines a [template](/docs/configuration/templating/#processing-incoming-data) to extract a value from the payload. Available variables: `entity_id`."
required: false required: false
type: string type: string
force_update: force_update:
@ -163,13 +163,24 @@ binary_sensor:
``` ```
{% endraw %} {% endraw %}
### {% linkable_title Toggle the binary sensor each time a message is received on state_topic %}
{% raw %}
```yaml
# Example configuration.yaml entry
binary_sensor:
- platform: mqtt
state_topic: "lab_button/cmnd/POWER"
value_template: "{%if is_state(entity_id,\"on\")-%}OFF{%-else-%}ON{%-endif%}"
```
{% endraw %}
### {% linkable_title Get the state of a device with ESPEasy %} ### {% linkable_title Get the state of a device with ESPEasy %}
Assuming that you have flashed your ESP8266 unit with [ESPEasy](https://github.com/letscontrolit/ESPEasy). Under "Config" is a name ("Unit Name:") set for your device (here it's "bathroom"). A configuration for a "Controller" for MQTT with the protocol "OpenHAB MQTT" is present and the entries ("Controller Subscribe:" and "Controller Publish:") are adjusted to match your needs. In this example, the topics are prefixed with "home". Also, add a "Switch Input" in the "Devices" tap with the name "switch" and "button" as value. Assuming that you have flashed your ESP8266 unit with [ESPEasy](https://github.com/letscontrolit/ESPEasy). Under "Config" is a name ("Unit Name:") set for your device (here it's "bathroom"). A configuration for a "Controller" for MQTT with the protocol "OpenHAB MQTT" is present and the entries ("Controller Subscribe:" and "Controller Publish:") are adjusted to match your needs. In this example, the topics are prefixed with "home". Also, add a "Switch Input" in the "Devices" tap with the name "switch" and "button" as value.
As soon as the unit is online, you will get the state of the attached button. As soon as the unit is online, you will get the state of the attached button.
```bash ```
home/bathroom/status Connected home/bathroom/status Connected
... ...
home/bathroom/switch/button 1 home/bathroom/switch/button 1
@ -186,4 +197,3 @@ binary_sensor:
payload_on: "1" payload_on: "1"
payload_off: "0" payload_off: "0"
``` ```