From ed0309ee7dc4faf9a66a157fb9863502c98ef4f0 Mon Sep 17 00:00:00 2001 From: Jan Bouwhuis Date: Mon, 23 Jan 2023 18:47:34 +0100 Subject: [PATCH] Add code support for MQTT lock (#25781) --- source/_integrations/lock.mqtt.markdown | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/source/_integrations/lock.mqtt.markdown b/source/_integrations/lock.mqtt.markdown index 592cebea832..32cf958a9e3 100644 --- a/source/_integrations/lock.mqtt.markdown +++ b/source/_integrations/lock.mqtt.markdown @@ -69,6 +69,14 @@ availability_topic: description: The MQTT topic subscribed to receive availability (online/offline) updates. Must not be used together with `availability`. required: false 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: description: The MQTT topic to publish commands to change the lock state. required: true @@ -255,7 +263,9 @@ mqtt: lock: - name: Frontdoor state_topic: "home-assistant/frontdoor/state" + code_format: "^\\d{4}$" command_topic: "home-assistant/frontdoor/set" + command_template: '{ "action": "{{ value }}", "code":"{{ code }}" }' payload_lock: "LOCK" payload_unlock: "UNLOCK" state_locked: "LOCK"