mirror of
https://github.com/home-assistant/home-assistant.io.git
synced 2025-07-19 15:26:59 +00:00
Example of multiple !include files for integration (#13627)
For integrations that might have a large number of configured elements (`light`, `sensor`, `automation`) it can be nice to split them across multiple files. This PR adds an example of doing so, and corrects some wording that might lead people to believe it's not possible!
This commit is contained in:
parent
ebf71969dc
commit
2e18cba029
@ -84,7 +84,44 @@ switch: !include switch.yaml
|
||||
device_tracker: !include device_tracker.yaml
|
||||
```
|
||||
|
||||
Note that there can only be one `!include:` for each integration so chaining them isn't going to work. If that sounds like Greek, don't worry about it.
|
||||
Nesting `!include`s (having an `!include` within a file that is itself `!include`d) isn't going to work. You can, however, have multiple top-level `!include`s for a given integration, if you give a different label to each one:
|
||||
|
||||
```yaml
|
||||
light:
|
||||
- platform: group
|
||||
name: Bedside Lights
|
||||
entities:
|
||||
- light.left_bedside_light
|
||||
- light.right_bedside_light
|
||||
|
||||
# define more light groups in a separate file
|
||||
light groups: !include light-groups.yaml
|
||||
|
||||
# define some light switch mappings in a different file
|
||||
light switches: !include light-switches.yaml
|
||||
```
|
||||
|
||||
where `light-groups.yaml` might look like:
|
||||
|
||||
```yaml
|
||||
- platform: group
|
||||
name: Outside Lights
|
||||
entities:
|
||||
- light.porch_lights
|
||||
- light.patio_lights
|
||||
```
|
||||
|
||||
with `light-switches.yaml` containing:
|
||||
|
||||
```yaml
|
||||
- platform: switch
|
||||
name: Patio Lights
|
||||
entity_id: switch.patio_lights
|
||||
|
||||
- platform: switch
|
||||
name: Floor Lamp
|
||||
entity_id: switch.floor_lamp_plug
|
||||
```
|
||||
|
||||
Alright, so we've got the single integrations and the include statements in the base file, what goes in those extra files?
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user