Add documentation for include substitution defaults (#3370)

Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com>
This commit is contained in:
mknjc 2023-12-21 01:08:16 +01:00 committed by GitHub
parent 1b497bfa82
commit 159663ac62
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 2 deletions

View File

@ -472,6 +472,8 @@ variables can be provided to them. This means that packages can be
used as `templates`, allowing complex or repetitive configurations to
be stored in a package file and then incorporated into the
configuration more than once.
Additionally packages could contain a ``defaults`` block which provides
subsitutions for variables not provided by the ``!include`` block.
As an example, if the configuration needed to support three garage
doors using the ``gpio`` switch platform and the ``time_based`` cover
@ -502,11 +504,17 @@ platform, it could be constructed like this:
door_location: right
open_switch_gpio: 15
close_switch_gpio: 18
open_duration: "1min"
close_duration: "50s"
.. code-block:: yaml
# In garage-door.yaml
defaults:
open_duration: "2.1min"
close_duration: "2min"
switch:
- id: open_${door_location}_door_switch
name: ${door_name} Garage Door Open Switch
@ -524,11 +532,11 @@ platform, it could be constructed like this:
open_action:
- switch.turn_on: open_${door_location}_door_switch
open_duration: 2.1min
open_duration: ${open_duration}
close_action:
- switch.turn_on: close_${door_location}_door_switch
close_duration: 2min
close_duration: ${close_duration}
stop_action:
- switch.turn_off: open_${door_location}_door_switch