Skip to content

Commit 3c3a645

Browse files
authored
Minimizing of the configuration sample (home-assistant#1025)
1 parent 53ab256 commit 3c3a645

File tree

1 file changed

+37
-13
lines changed

1 file changed

+37
-13
lines changed

source/_components/lock.mqtt.markdown

Lines changed: 37 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ The `mqtt` lock platform let you control your MQTT enabled locks.
1717

1818
In an ideal scenario, the MQTT device will have a `state_topic` to publish state changes. If these messages are published with `RETAIN` flag, the MQTT lock will receive an instant state update after subscription and will start with correct state. Otherwise, the initial state of the lock will be false/unlocked.
1919

20-
When a `state_topic` is not available, the lock will work in optimistic mode. In this mode, the lock will immediately change state after every command. Otherwise, the lock will wait for state confirmation from device (message from `state_topic`).
20+
When a `state_topic` is not available, the lock will work in optimistic mode. In this mode, the lock will immediately change state after every command. Otherwise, the lock will wait for state confirmation from the device (message from `state_topic`).
2121

2222
Optimistic mode can be forced, even if state topic is available. Try to enable it, if experiencing incorrect lock operation.
2323

@@ -26,30 +26,54 @@ To enable MQTT locks in your installation, add the following to your `configurat
2626
```yaml
2727
# Example configuration.yml entry
2828
lock:
29-
platform: mqtt
30-
name: Frontdoor
31-
state_topic: "home/frontdoor/"
32-
command_topic: "home/frontdoor/set"
33-
payload_lock: "LOCK"
34-
payload_unlock: "UNLOCK"
35-
optimistic: false
36-
qos: 0
37-
retain: true
38-
value_template: '{% raw %}{{ value.x }}{% endraw %}'
29+
- platform: mqtt
30+
command_topic: "home/frontdoor/set"
3931
```
4032
4133
Configuration variables:
4234
35+
- **command_topic** (*Required*): The MQTT topic to publish commands to change the lock state.
4336
- **name** (*Optional*): The name of the lock. Default is 'MQTT Lock'.
4437
- **state_topic** (*Optional*): The MQTT topic subscribed to receive state updates.
45-
- **command_topic** (*Required*): The MQTT topic to publish commands to change the lock state.
4638
- **payload_lock** (*Optional*): The payload that represents enabled/locked state. Default is "LOCK".
4739
- **payload_unlock** (*Optional*): The payload that represents disabled/unlocked state. Default is "UNLOCK".
48-
- **optimistic** (*Optional*): Flag that defines if lock works in optimistic mode. Default is true if no state topic defined, else false.
40+
- **optimistic** (*Optional*): Flag that defines if lock works in optimistic mode. Default is `true` if no `state_topic` defined, else `false`.
4941
- **qos** (*Optional*): The maximum QoS level of the state topic. Default is 0 and will also be used to publishing messages.
5042
- **retain** (*Optional*): If the published message should have the retain flag on or not.
5143
- **value_template** (*Optional*): Defines a [template](/topics/templating/) to extract a value from the payload.
5244

5345
<p class='note warning'>
5446
Make sure that your topic match exact. `some-topic/` and `some-topic` are different topics.
5547
</p>
48+
49+
## {% linkable_title Examples %}
50+
51+
In this section you find some real life examples of how to use this lock.
52+
53+
### {% linkable_title Full configuration %}
54+
55+
The example below shows a full configuration for a MQTT lock.
56+
57+
```yaml
58+
# Example configuration.yml entry
59+
lock:
60+
platform: mqtt
61+
name: Frontdoor
62+
state_topic: "home-assistant/frontdoor/"
63+
command_topic: "home-assistant/frontdoor/set"
64+
payload_lock: "LOCK"
65+
payload_unlock: "UNLOCK"
66+
optimistic: false
67+
qos: 1
68+
retain: true
69+
value_template: '{% raw %}{{ value.x }}{% endraw %}'
70+
```
71+
72+
Keep an eye on ratining messages to keep the state as you don't want to unlock your door by accident when you restart something.
73+
74+
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:
75+
76+
```bash
77+
$ mosquitto_pub -h 127.0.0.1 -t home-assistant/frontdoor/set -m "LOCK"
78+
```
79+

0 commit comments

Comments
 (0)