Update MQTT platforms that now support availablity (#4293)

To accompany changes from:
https://github.com/home-assistant/home-assistant/pull/11336

Updated platforms:
- Switch (previously supported)
- Binary sensor (previously supported)
- Cover (previously supported)
- Light
- JSON light
- Template light
- Sensor
- Alarm control panel
- Lock
- HVAC
- Fan
- Vacuum
This commit is contained in:
Dan Nixon 2018-01-02 02:33:19 +00:00 committed by Paulus Schoutsen
parent 943b2e3119
commit 5d321e66f7
12 changed files with 1024 additions and 229 deletions

View file

@ -30,17 +30,64 @@ lock:
command_topic: "home/frontdoor/set"
```
Configuration variables:
- **command_topic** (*Required*): The MQTT topic to publish commands to change the lock state.
- **name** (*Optional*): The name of the lock. Default is 'MQTT Lock'.
- **state_topic** (*Optional*): The MQTT topic subscribed to receive state updates.
- **payload_lock** (*Optional*): The payload that represents enabled/locked state. Default is "LOCK".
- **payload_unlock** (*Optional*): The payload that represents disabled/unlocked state. Default is "UNLOCK".
- **optimistic** (*Optional*): Flag that defines if lock works in optimistic mode. Default is `true` if no `state_topic` defined, else `false`.
- **qos** (*Optional*): The maximum QoS level of the state topic. Default is 0 and will also be used to publishing messages.
- **retain** (*Optional*): If the published message should have the retain flag on or not.
- **value_template** (*Optional*): Defines a [template](/docs/configuration/templating/#processing-incoming-data) to extract a value from the payload.
{% configuration %}
name:
description: The name of the lock.
required: false
type: string
default: MQTT Lock
command_topic:
description: The MQTT topic to publish commands to change the lock state.
required: true
type: string
state_topic:
description: The MQTT topic subscribed to receive state updates.
required: false
type: string
payload_lock:
description: The payload that represents enabled/locked state.
required: false
type: string
default: LOCK
payload_unlock:
description: The payload that represents disabled/unlocked state.
required: false
type: string
default: UNLOCK
optimistic:
description: Flag that defines if lock works in optimistic mode.
required: false
type: string
default: "`true` if no `state_topic` defined, else `false`."
qos:
description: The maximum QoS level of the state topic.
required: false
type: integer
default: 0
retain:
description: If the published message should have the retain flag on or not.
required: false
type: boolean
default: false
value_template:
description: "Defines a [template](/docs/configuration/templating/#processing-incoming-data) to extract a value from the payload."
required: false
type: string
availability_topic:
description: The MQTT topic subscribed to receive availability (online/offline) updates.
required: false
type: string
payload_available:
description: The payload that represents the available state.
required: false
type: string
default: online
payload_not_available:
description: The payload that represents the unavailable state.
required: false
type: string
default: offline
{% endconfiguration %}
<p class='note warning'>
Make sure that your topics match exactly. `some-topic/` and `some-topic` are different topics.
@ -58,7 +105,7 @@ The example below shows a full configuration for a MQTT lock.
# Example configuration.yml entry
lock:
- platform: mqtt
name: Frontdoor
name: Frontdoor
state_topic: "home-assistant/frontdoor/"
command_topic: "home-assistant/frontdoor/set"
payload_lock: "LOCK"
@ -69,7 +116,7 @@ lock:
value_template: '{% raw %}{{ value.x }}{% endraw %}'
```
Keep an eye on retaining messages to keep the state as you don't want to unlock your door by accident when you restart something.
Keep an eye on retaining messages to keep the state as you don't want to unlock your door by accident when you restart something.
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 lock manually: