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
Copy file name to clipboardExpand all lines: source/_components/lock.mqtt.markdown
+37-13Lines changed: 37 additions & 13 deletions
Original file line number
Diff line number
Diff line change
@@ -17,7 +17,7 @@ The `mqtt` lock platform let you control your MQTT enabled locks.
17
17
18
18
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.
19
19
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`).
21
21
22
22
Optimistic mode can be forced, even if state topic is available. Try to enable it, if experiencing incorrect lock operation.
23
23
@@ -26,30 +26,54 @@ To enable MQTT locks in your installation, add the following to your `configurat
26
26
```yaml
27
27
# Example configuration.yml entry
28
28
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"
39
31
```
40
32
41
33
Configuration variables:
42
34
35
+
- **command_topic** (*Required*): The MQTT topic to publish commands to change the lock state.
43
36
- **name** (*Optional*): The name of the lock. Default is 'MQTT Lock'.
44
37
- **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.
46
38
- **payload_lock** (*Optional*): The payload that represents enabled/locked state. Default is "LOCK".
47
39
- **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`.
49
41
- **qos** (*Optional*): The maximum QoS level of the state topic. Default is 0 and will also be used to publishing messages.
50
42
- **retain** (*Optional*): If the published message should have the retain flag on or not.
51
43
- **value_template** (*Optional*): Defines a [template](/topics/templating/) to extract a value from the payload.
52
44
53
45
<p class='note warning'>
54
46
Make sure that your topic match exact. `some-topic/` and `some-topic` are different topics.
55
47
</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:
0 commit comments