Fix platform

This commit is contained in:
Fabian Affolter 2018-12-30 22:06:54 +01:00
parent 011e423d2e
commit 572ff69932
No known key found for this signature in database
GPG Key ID: E23CD2DD36A4397F

View File

@ -13,28 +13,15 @@ ha_release: 0.9
ha_iot_class: "depends"
---
The `mqtt` binary sensor platform uses an MQTT message payload
to set the binary sensor to one of two states: `on` or `off`.
The `mqtt` binary sensor platform uses an MQTT message payload to set the binary sensor to one of two states: `on` or `off`.
The binary sensor state will be updated only after a new message is published on
`state_topic` matching `payload_on` or `payload_off`.
If these messages are published with the `retain` flag set,
the binary sensor will receive an instant state update after subscription and
Home Assistant will display the correct state on startup.
The binary sensor state will be updated only after a new message is published on `state_topic` matching `payload_on` or `payload_off`. If these messages are published with the `retain` flag set,
the binary sensor will receive an instant state update after subscription and Home Assistant will display the correct state on startup.
Otherwise, the initial state displayed in Home Assistant will be `unknown`.
## {% linkable_title Configuration %}
The `mqtt` binary sensor platform optionally supports an `availability_topic` to
receive online and offline messages (birth and LWT messages) from the MQTT
device. During normal operation, if the MQTT cover device goes offline
(i.e., publishes `payload_not_available` to `availability_topic`), Home
Assistant will display the binary sensor as `unavailable`. If these messages are
published with the `retain` flag set, the binary sensor will receive an instant
update after subscription and Home Assistant will display the correct
availability state of the binary sensor when Home Assistant starts up.
If the `retain` flag is not set, Home Assistant will display the binary sensor
as `unavailable` when Home Assistant starts up. If no `availability_topic`
The `mqtt` binary sensor platform optionally supports an `availability_topic` to receive online and offline messages (birth and LWT messages) from the MQTT device. During normal operation, if the MQTT sensor device goes offline (i.e., publishes `payload_not_available` to `availability_topic`), Home Assistant will display the binary sensor as `unavailable`. If these messages are published with the `retain` flag set, the binary sensor will receive an instant update after subscription and Home Assistant will display the correct availability state of the binary sensor when Home Assistant starts up. If the `retain` flag is not set, Home Assistant will display the binary sensor as `unavailable` when Home Assistant starts up. If no `availability_topic`
is defined, Home Assistant will consider the MQTT device to be available.
To use an MQTT binary sensor in your installation,
@ -48,15 +35,15 @@ binary_sensor:
```
{% configuration %}
state_topic:
description: The MQTT topic subscribed to receive sensor values.
required: true
type: string
name:
description: The name of the binary sensor.
required: false
type: string
default: MQTT Binary Sensor
state_topic:
description: The MQTT topic subscribed to receive sensor values.
required: true
type: string
payload_on:
description: The payload that represents the on state.
required: false
@ -68,11 +55,7 @@ payload_off:
type: string
default: "OFF"
availability_topic:
description: >
The MQTT topic subscribed to receive birth and LWT messages from the MQTT
device. If `availability_topic` is not defined, the binary sensor availability
state will always be `available`. If `availability_topic` is defined,
the binary sensor availability state will be `unavailable` by default.
description: "The MQTT topic subscribed to receive birth and LWT messages from the MQTT device. If `availability_topic` is not defined, the binary sensor availability state will always be `available`. If `availability_topic` is defined, the binary sensor availability state will be `unavailable` by default."
required: false
type: string
payload_available:
@ -91,21 +74,15 @@ qos:
type: integer
default: 0
unique_id:
description: >
An ID that uniquely identifies this sensor. If two sensors have
the same unique ID, Home Assistant will raise an exception.
description: An ID that uniquely identifies this sensor. If two sensors have the same unique ID, Home Assistant will raise an exception.
required: false
type: string
device_class:
description: >
The [type/class](/components/binary_sensor/) of
the sensor to set the icon in the frontend.
description: The [type/class](/components/binary_sensor/) of the sensor to set the icon in the frontend.
required: false
type: string
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.
required: false
type: string
force_update:
@ -114,36 +91,36 @@ force_update:
type: boolean
default: False
off_delay:
description: For sensors that only sends On state updates, this variable sets a delay in seconds after which the sensor state will be updated back to Off.
description: "For sensors that only sends `On` state updates, this variable sets a delay in seconds after which the sensor state will be updated back to `Off`."
required: false
type: integer
device:
description: 'Information about the device this binary sensor is a part of to tie it into the [device registry](https://developers.home-assistant.io/docs/en/device_registry_index.html). Only works through [MQTT discovery](/docs/mqtt/discovery/) and when [`unique_id`](#unique_id) is set.'
description: "Information about the device this binary sensor is a part of to tie it into the [device registry](https://developers.home-assistant.io/docs/en/device_registry_index.html). Only works through [MQTT discovery](/docs/mqtt/discovery/) and when [`unique_id`](#unique_id) is set."
required: false
type: map
keys:
identifiers:
description: 'A list of IDs that uniquely identify the device. For example a serial number.'
description: A list of IDs that uniquely identify the device. For example a serial number.
required: false
type: list, string
connections:
description: 'A list of connections of the device to the outside world as a list of tuples `[connection_type, connection_identifier]`. For example the MAC address of a network interface: `"connections": [["mac", "02:5b:26:a8:dc:12"]]`.'
description: "A list of connections of the device to the outside world as a list of tuples `[connection_type, connection_identifier]`. For example the MAC address of a network interface: `'connections': ['mac', '02:5b:26:a8:dc:12']`."
required: false
type: list, tuple
manufacturer:
description: 'The manufacturer of the device.'
description: The manufacturer of the device.
required: false
type: string
model:
description: 'The model of the device.'
description: The model of the device.
required: false
type: string
name:
description: 'The name of the device.'
description: The name of the device.
required: false
type: string
sw_version:
description: 'The firmware version of the device.'
description: The firmware version of the device.
required: false
type: string
{% endconfiguration %}
@ -154,8 +131,8 @@ In this section, you will find some real-life examples of how to use this sensor
### {% linkable_title Full configuration %}
To test, you can use the command line tool `mosquitto_pub` shipped with
`mosquitto` or the `mosquitto-clients` package to send MQTT messages.
To test, you can use the command line tool `mosquitto_pub` shipped with `mosquitto` or the `mosquitto-clients` package to send MQTT messages.
To set the state of the binary sensor manually:
```bash
@ -184,14 +161,7 @@ binary_sensor:
### {% 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.
@ -203,7 +173,6 @@ home/bathroom/switch/button 1
The configuration will look like the example below:
{% raw %}
```yaml
# Example configuration.yaml entry
binary_sensor:
@ -213,4 +182,4 @@ binary_sensor:
payload_on: "1"
payload_off: "0"
```
{% endraw %}