Add code support for MQTT lock (#25781)

This commit is contained in:
Jan Bouwhuis 2023-01-23 18:47:34 +01:00 committed by GitHub
parent fa92030139
commit ed0309ee7d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -69,6 +69,14 @@ availability_topic:
description: The MQTT topic subscribed to receive availability (online/offline) updates. Must not be used together with `availability`. description: The MQTT topic subscribed to receive availability (online/offline) updates. Must not be used together with `availability`.
required: false required: false
type: string type: string
code_format:
description: A regular expression to validate a supplied code when it is set during the service call to `open`, `lock` or `unlock` the MQTT lock.
required: false
type: string
command_template:
description: Defines a [template](/docs/configuration/templating/#using-templates-with-the-mqtt-integration) to generate the payload to send to `command_topic`. The lock command template accepts the parameters `value` and `code`. The `value` parameter will contain the configured value for either `payload_open`, `payload_lock` or `payload_unlock`. The `code` parameter is set during the service call to `open`, `lock` or `unlock` the MQTT lock and will be set `None` if no code was passed.
required: false
type: template
command_topic: command_topic:
description: The MQTT topic to publish commands to change the lock state. description: The MQTT topic to publish commands to change the lock state.
required: true required: true
@ -255,7 +263,9 @@ mqtt:
lock: lock:
- name: Frontdoor - name: Frontdoor
state_topic: "home-assistant/frontdoor/state" state_topic: "home-assistant/frontdoor/state"
code_format: "^\\d{4}$"
command_topic: "home-assistant/frontdoor/set" command_topic: "home-assistant/frontdoor/set"
command_template: '{ "action": "{{ value }}", "code":"{{ code }}" }'
payload_lock: "LOCK" payload_lock: "LOCK"
payload_unlock: "UNLOCK" payload_unlock: "UNLOCK"
state_locked: "LOCK" state_locked: "LOCK"