Add modern template lock (#38998)

Co-authored-by: c0ffeeca7 <38767475+c0ffeeca7@users.noreply.github.com>
This commit is contained in:
Petro31 2025-05-15 09:38:19 -04:00 committed by GitHub
parent 0b2682722b
commit 6a2722e0c7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -10,6 +10,7 @@ ha_category:
- Helper
- Image
- Light
- Lock
- Number
- Select
- Sensor
@ -48,20 +49,20 @@ related:
The `template` integration allows creating entities which derive their values from other data. This is done by specifying [templates](/docs/configuration/templating/) for properties of an entity, like the name or the state.
Alarm control panels, binary (on/off) sensors, buttons, images, numbers, selects, sensors, switches and weathers are covered on this page. They can be configured using [UI](#configuration) or [YAML](#yaml-configuration) file.
Alarm control panels, binary sensors, buttons, covers, fans, images, lights, locks, numbers, selects, sensors, switches, and weathers are covered on this page. They can be configured using [UI](#configuration) or [YAML](#yaml-configuration) file.
For other types, please see the specific pages:
- [Lock](/integrations/lock.template/)
- [Vacuum](/integrations/vacuum.template/)
- [Weather](/integrations/weather.template/)
For Legacy types, please see the specific pages:
- [Alarm control panel](/integrations/alarm_control_panel.template/)
- [Cover](/integrations/cover.template/)
- [Fan](/integrations/fan.template/)
- [Light](/integrations/light.template/)
- [Lock](/integrations/lock.template/)
- [Switch](/integrations/switch.template/)
- [Weather](/integrations/weather.template/)
{% include integrations/config_flow.md %}
@ -77,7 +78,7 @@ If you need more specific features for your use case, the manual [YAML-configura
## YAML configuration
Entities (alarm control panels, binary sensors, buttons, covers, fans, images, lights, numbers, selects, sensors, switches, and weathers) are defined in your YAML configuration files under the `template:` key. You can define multiple configuration blocks as a list. Each block defines sensor/binary sensor/number/select entities and can contain optional update triggers.
Entities (alarm control panels, binary sensors, buttons, covers, fans, images, lights, locks, numbers, selects, sensors, switches, and weathers) are defined in your YAML configuration files under the `template:` key. You can define multiple configuration blocks as a list. Each block defines sensor/binary sensor/number/select entities and can contain optional update triggers.
_For old sensor/binary sensor configuration format, [see below](#legacy-binary-sensor-configuration-format)._
@ -571,6 +572,37 @@ light:
description: Defines an action to run when the light is given an effect command. Receives the variable `effect`. May also receive the variables `brightness`, and/or `transition`.
required: inclusive
type: action
lock:
description: List of locks
required: true
type: map
keys:
state:
description: Defines a template to set the state of the lock.
required: true
type: template
code_format:
description: Defines a template to get the `code_format` attribute of the entity. This template must evaluate to a valid [Python regular expression](https://docs.python.org/3/library/re.html#regular-expression-syntax) or `None`. If it evaluates to a not-`None` value, you are prompted to enter a code when interacting with the lock. The code will be matched against the regular expression, and the lock/unlock actions will be executed only if they match. The actual _validity_ of the entered code must be verified within these actions. If there's a syntax error in the template, the entity will be unavailable. If the template fails to render for other reasons or if the regular expression is invalid, no code will be accepted, and the lock/unlock actions will never be invoked.
required: false
type: template
default: None
lock:
description: Defines an action to run when the lock is locked.
required: true
type: action
unlock:
description: Defines an action to run when the lock is unlocked.
required: true
type: action
open:
description: Defines an action to run when the lock is opened.
required: false
type: action
optimistic:
description: Flag that defines if the lock works in optimistic mode.
required: false
type: boolean
default: false
switch:
description: List of switches
required: true