You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Mar 20, 2019. It is now read-only.
* Add documentation for availability topic and payloads
Added documentation for availabiltiy topic and payloads added in a pull request. Also cleaned up documentation for the MQTT cover generally to make clear the differences between state topic and messages and availability topic and messages.
* Add default qos level
* Add documentation for availability topic and payloads
Added documentation for availability topic and payloads added to the MQTT binary sensor in a pull request. Also cleaned up documentation for the MQTT binary sensor generally.
* Remove sending
Copy file name to clipboardExpand all lines: source/_components/binary_sensor.mqtt.markdown
+21-12Lines changed: 21 additions & 12 deletions
Original file line number
Diff line number
Diff line change
@@ -14,9 +14,13 @@ ha_iot_class: "depends"
14
14
---
15
15
16
16
17
-
The `mqtt` binary 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 the last known value. Otherwise, the initial state will be off.
17
+
The `mqtt` binary sensor platform uses an MQTT message payload to set the binary sensor to one of two states: `on` or `off`.
18
18
19
-
To use your MQTT binary sensor in your installation, add the following to your `configuration.yaml` file:
19
+
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`.
20
+
21
+
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` is defined, Home Assistant will consider the MQTT device to be available.
22
+
23
+
To use an MQTT binary sensor in your installation, add the following to your `configuration.yaml` file:
20
24
21
25
```yaml
22
26
# Example configuration.yaml entry
@@ -27,32 +31,37 @@ binary_sensor:
27
31
28
32
Configuration variables:
29
33
34
+
- **name** (*Optional*): The name of the binary sensor. Default is `MQTT Binary Sensor`.
30
35
- **state_topic** (*Required*): The MQTT topic subscribed to receive sensor values.
31
-
- **name** (*Optional*): The name of the sensor. Default is 'MQTT Sensor'.
32
-
- **qos** (*Optional*): The maximum QoS level of the state topic. Default is 0.
33
-
- **payload_on** (*Optional*): The payload that represents on state. Default is "ON".
34
-
- **payload_off** (*Optional*): The payload that represents state. Default is "OFF".
36
+
- **payload_on** (*Optional*): The payload that represents the on state. Default is `ON`.
37
+
- **payload_off** (*Optional*): The payload that represents the off state. Default is `OFF`.
38
+
- **availability_topic** (*Optional*): 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.
39
+
- **payload_available** (*Optional*): The payload that represents the online state. Default is `online`.
40
+
- **payload_not_available** (*Optional*): The payload that represents the offline state. Default is `offline`.
41
+
- **qos** (*Optional*): The maximum QoS level to be used when receiving messages. Default is `0`.
35
42
- **device_class** (*Optional*): The [type/class](/components/binary_sensor/) of the sensor to set the icon in the frontend.
36
43
- **value_template** (*Optional*): Defines a [template](/docs/configuration/templating/#processing-incoming-data) to extract a value from the payload.
37
44
38
-
For a quick check you can use the commandline tools shipped with `mosquitto` to send MQTT messages. Set the state of a sensor manually:
45
+
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:
Copy file name to clipboardExpand all lines: source/_components/cover.mqtt.markdown
+36-25Lines changed: 36 additions & 25 deletions
Original file line number
Diff line number
Diff line change
@@ -13,39 +13,44 @@ ha_iot_class: "depends"
13
13
ha_release: 0.18
14
14
---
15
15
16
-
The `mqtt` cover platform enables the possibility to control an MQTT cover. The device state will be updated only after receiving the a new
17
-
state from `state_topic`. If these messages are published with `RETAIN` flag, the MQTT device will receive an instant state update after subscription and will start with correct state. Otherwise, the initial state will be `unknown`.
16
+
The `mqtt` cover platform allows you to control an MQTT cover (such as blinds, a rollershutter, or a garage door).
18
17
19
-
There is a state attribute that stores the relative position of the device, where 0 means the device is `closed`and all other intermediate positions means the device is `open`.
18
+
The device state (`open` or `closed`) will be updated only after a new message is published on `state_topic` matching `state_open` or `state_closed`. If these messages are published with the `retain` flag set, the cover 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`.
20
19
21
-
When a state topic is not available, the cover will work in optimistic mode. In this mode, the cover will immediately change state after every command. Otherwise, the cover will wait for state confirmation from device (message from `state_topic`).
20
+
There is an attribute that stores the relative position of the device, where 0 means the device is `closed` and all other intermediate positions means the device is `open`.
22
21
23
-
Optimistic mode can be forced, even if `state_topic` is available. Try to enable it, if experiencing incorrect cover operation.
22
+
If a state topic is not defined, the cover will work in optimistic mode. In this mode, the cover will immediately change state (`open` or `closed`) after every command sent by Home Assistant. If a state topic is defined, the cover will wait for a message on `state_topic` matching `state_open` or `state_closed` before changing state in Home Assistant.
23
+
24
+
Optimistic mode can be forced, even if a `state_topic` is defined. Try to enable it if experiencing incorrect cover operation.
25
+
26
+
The `mqtt` cover platform optionally supports an `availability_topic` to receive online and offline messages (birth and LWT messages) from the MQTT cover 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 cover as "unavailable". If these messages are published with the `retain` flag set, the cover will receive an instant update after subscription and Home Assistant will display correct availability state of the cover when Home Assistant starts up. If the `retain` flag is not set, Home Assistant will display the cover as "unavailable" when Home Assistant starts up.
24
27
25
28
To use your MQTT cover in your installation, add the following to your `configuration.yaml` file:
26
29
27
30
```yaml
28
-
# Example configuration.yml entry
31
+
# Example configuration.yaml entry
29
32
cover:
30
33
- platform: mqtt
31
34
name: "MQTT Cover"
32
-
state_topic: "home-assistant/cover"
33
35
command_topic: "home-assistant/cover/set"
34
36
```
35
37
36
38
Configuration variables:
37
39
38
40
- **name** (*Optional*): The name of the sensor. Default is `MQTT Cover`.
39
-
- **state_topic** (*Optional*): The MQTT topic subscribed to receive sensor values.
40
-
- **command_topic** (*Optional*): The MQTT topic to publish commands to control the rollershutter.
41
+
- **command_topic** (*Optional*): The MQTT topic to publish commands to control the cover.
41
42
- **payload_open** (*Optional*): The payload that opens the cover. Default is `OPEN`.
42
43
- **payload_close** (*Optional*): The payload that closes the cover. Default is `CLOSE`.
43
-
- **payload_stop** (*Optional*): The payload that stops the rollershutter. default is `STOP`.
44
-
- **state_open** (*Optional*): The payload that represents open state. Default is `open`.
45
-
- **state_closed** (*Optional*): The payload that represents closed state. Default is `closed`.
44
+
- **payload_stop** (*Optional*): The payload that stops the cover. default is `STOP`.
45
+
- **state_topic** (*Optional*): The MQTT topic subscribed to receive cover state messages.
46
+
- **state_open** (*Optional*): The payload that represents the open state. Default is `open`.
47
+
- **state_closed** (*Optional*): The payload that represents the closed state. Default is `closed`.
48
+
- **availability_topic** (*Optional*): The MQTT topic subscribed to to receive birth and LWT messages from the MQTT cover device. If `availability_topic` is not defined, the cover availability state will always be "available". If `availability_topic` is defined, the cover availability state will be "unavailable" by default.
49
+
- **payload_available** (*Optional*): The payload that represents the online state. Default is `online`.
50
+
- **payload_not_available** (*Optional*): The payload that represents the offline state. Default is `offline`.
46
51
- **optimistic** (*Optional*): Flag that defines if switch works in optimistic mode. Default is `true` if no state topic defined, else `false`.
47
-
- **qos** (*Optional*): The maximum QoS level of the state topic. Default is `0`. Will also be used when publishing messages.
48
-
- **retain** (*Optional*): If the published message should have the retain flag on or not. Default is `false`.
52
+
- **qos** (*Optional*): The maximum QoS level to be used when receiving and publishing messages. Default is `0`.
53
+
- **retain** (*Optional*): Defines if published messages should have the retain flag set. Default is `false`.
49
54
- **value_template** (*Optional*): Defines a [template](/docs/configuration/templating/#processing-incoming-data) to extract a value from the payload.
50
55
- **set_position_topic** (*Optional*): The MQTT topic to publish position commands to.
51
56
- **set_position_template** (*Optional*): Defines a [template](/topics/templating/) to define the position to be sent to the `set_position_topic` topic. Incoming position value is available for use in the template `{{position}}`. If no template is defined, the numeric position (0-100) will be written directly to the topic.
@@ -60,7 +65,7 @@ Configuration variables:
60
65
61
66
## {% linkable_title Examples %}
62
67
63
-
In this section you find some real life examples of how to use this sensor.
68
+
In this section you find some real life examples of how to use this platform.
64
69
65
70
### {% linkable_title Full configuration without tilt %}
66
71
@@ -70,16 +75,19 @@ The example below shows a full configuration for a cover without tilt.
For a check you can use the command line tools `mosquitto_pub` shipped with `mosquitto` to send MQTT messages. This allows you to operate your cover manually:
126
+
To test, you can use the command line tool `mosquitto_pub` shipped with `mosquitto` or the `mosquitto-clients` package to send MQTT messages. This allows you to operate your cover manually:
0 commit comments