Improve formatting of the Splitting Configuration page (which itself is helping to improve formatting of configuration ha ha)

This commit is contained in:
Robbie Trencheny 2016-03-26 00:09:53 -07:00
parent aacf326cc0
commit d41a5cabf6

View File

@ -9,12 +9,12 @@ sharing: true
footer: true
---
So you've been using Home Assistant (HA, hass, or any number of other abbreviations) for a while now and your configuration.yaml file brings people to tears (https://home-assistant.io/cookbook/configuration_yaml_from_bassclarinetl2/) or you simply want to start off with the distributed approach, here's how to "split the configuration.yaml" into more manageable (read: husmanly readable) pieces.
So you've been using Home Assistant (HA, hass, or any number of other abbreviations) for a while now and your [configuration.yaml file brings people to tears](https://home-assistant.io/cookbook/configuration_yaml_from_bassclarinetl2/) or you simply want to start off with the distributed approach, here's how to "split the configuration.yaml" into more manageable (read: husmanly readable) pieces.
First off, several community members have sanitized (read: without api keys/passwords etc) versions of their configurations available for viewing:
- https://github.com/bassclarinetl2/HASS
- https://github.com/happyleavesaoc/my-home-automation/tree/master/homeassistant
- [bassclarinetl2](https://github.com/bassclarinetl2/HASS)
- [happyleavesaoc](https://github.com/happyleavesaoc/my-home-automation/tree/master/homeassistant)
As commenting code doesn't always happen, please read on for the details.
@ -22,7 +22,8 @@ Now despite the logical assumption that the configuration.yaml will be replaced
In this lighter version we will still need what could be called the core snippet:
homeassistant:
```yaml
homeassistant:
# Name of the location where Home Assistant is running
name: My Hass Instance
# Location required to calculate the time the sun rises and sets
@ -33,6 +34,7 @@ In this lighter version we will still need what could be called the core snippet
# Pick yours from here: http://en.wikipedia.org/wiki/List_of_tz_database_time_zones
time_zone: America/Los_Angeles
customize: !include customize.yaml
```
Note that each line after `homeassistant:` is indented two (2) spaces. Since the configuration files in Home Assistant are based on the YAML "language", indentation and spacing are important. Also note that seemingly strange entry under `customize:`.
@ -40,7 +42,7 @@ Note that each line after `homeassistant:` is indented two (2) spaces. Since th
Now before we start splitting out the different components, let's look at the other components (in our example) that will stay in the base file:
```
```yaml
#discovery:
sun:
#updater:
@ -82,23 +84,25 @@ While some of these components can technically be moved to a separate file they
Now, lets assume that a blank file has been created in the hass configuration directory for each of the following:
groups.yaml
zones.yaml
automation.yaml
notifications.yaml
sensors.yaml
switches.yaml
scripts.yaml
media_player.yaml
device_tracker.yaml
customize.yaml
```text
groups.yaml
zones.yaml
automation.yaml
notifications.yaml
sensors.yaml
switches.yaml
scripts.yaml
media_player.yaml
device_tracker.yaml
customize.yaml
```
`automation.yaml`will hold all the automation component details
`zones.yaml` will hold the zone component details
and so forth. These files can be called anything but giving them names that match their function will make things easier to keep track of.
`automation.yaml` will hold all the automation component details
`zones.yaml` will hold the zone component details and so forth. These files can be called anything but giving them names that match their function will make things easier to keep track of.
Inside the base configuration file add the following entries:
```
```yaml
group: !include groups.yaml
zone: !include zones.yaml
automation: !include automation.yaml
@ -109,17 +113,14 @@ scripts: !include: scripts.yaml
media_player: !include media_player.yaml
device_tracker: !include device_tracker.yaml
```
Note that there can only be one `!include:` for each component so chaining them isn't going to work. If that sounds like greek, don't worry about it.
Alright, so we've got the single components and the include statements in the base file, what goes in those extra files?
Let's look at the `device_tracker` file from our example:
```
### device_tracker.yaml
###
###
Let's look at the `device_tracker.yaml` file from our example:
```yaml
- platform: owntracks
- platform: nmap_tracker
hosts: 192.168.2.0/24
@ -129,10 +130,12 @@ Let's look at the `device_tracker` file from our example:
interval_seconds: 40
consider_home: 120
```
This small example illustrates how the "split" files work. In this case, we start with a "comment block" identifying the file followed by two (2) device tracker entries (owntracks and nmap). These files follow "style 2" that is to say a fully left aligned leading entry (`- platform: owntracks`) followed by the parameter entries indented two (2) spaces.
This (large) sensor configuration gives us another example:
```
```yaml
### sensors.yaml
###
###