Site updated at 2016-03-26 06:16:06 UTC
This commit is contained in:
parent
5d092ed282
commit
1fc03e6378
13 changed files with 463 additions and 168 deletions
|
@ -117,7 +117,302 @@
|
|||
|
||||
<p><img src="https://i.imgur.com/WkBB4BV.gif" alt="Under Construction" /></p>
|
||||
|
||||
<p>!Coming Soon</p>
|
||||
<p>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.</p>
|
||||
|
||||
<p>First off, several community members have sanitized (read: without api keys/passwords etc) versions of their configurations available for viewing:</p>
|
||||
|
||||
<ul>
|
||||
<li>https://github.com/bassclarinetl2/HASS</li>
|
||||
<li>https://github.com/happyleavesaoc/my-home-automation/tree/master/homeassistant</li>
|
||||
</ul>
|
||||
|
||||
<p>As commenting code doesn’t always happen, please read on for the details.</p>
|
||||
|
||||
<p>Now despite the logical assumption that the configuration.yaml will be replaced by this process it will in fact remain all be it in a much less cluttered form.</p>
|
||||
|
||||
<p>In this lighter version we will still need what could be called the core snippet:</p>
|
||||
|
||||
<pre><code>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
|
||||
latitude: 37
|
||||
longitude: -121
|
||||
# C for Celcius, F for Fahrenheit
|
||||
temperature_unit: F
|
||||
# Pick yours from here: http://en.wikipedia.org/wiki/List_of_tz_database_time_zones
|
||||
time_zone: America/Los_Angeles
|
||||
customize: !include customize.yaml
|
||||
</code></pre>
|
||||
|
||||
<p>Note that each line after <code>homeassistant:</code> 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 <code>customize:</code>.</p>
|
||||
|
||||
<p><code>!include filename.yaml</code> is the statement that tells Home Assistant to insert the contents of <code>filename.yaml</code> at that point. This is how we are going to break a monolithic and hard to read file (when it gets big) into more manageable chunks.</p>
|
||||
|
||||
<p>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:</p>
|
||||
|
||||
<pre><code>#discovery:
|
||||
sun:
|
||||
#updater:
|
||||
history:
|
||||
#conversation:
|
||||
frontend:
|
||||
logbook:
|
||||
http:
|
||||
api_password: ImNotTelling!
|
||||
server_port: 8123
|
||||
ssl_certificate: /etc/letsencrypt/live/example.com/fullchain.pem
|
||||
ssl_key: /etc/letsencrypt/live/example.com/privkey.pem
|
||||
|
||||
ifttt:
|
||||
key: [nope]
|
||||
|
||||
wink:
|
||||
access_token: [wouldn't you]
|
||||
refresh_token: [like to know]
|
||||
|
||||
zwave:
|
||||
usb_path: /dev/ttyUSB0
|
||||
config_path: /usr/local/share/python-openzwave/config
|
||||
polling_interval: 10000
|
||||
|
||||
#zigbee:
|
||||
# device: /dev/ttyUSB1
|
||||
# baud: 115200
|
||||
|
||||
mqtt:
|
||||
broker: 127.0.0.1
|
||||
port: 8883
|
||||
username: user
|
||||
password: password
|
||||
</code></pre>
|
||||
<p>As with the core snippet, indentation makes a difference. The component headers (<code>mqtt:</code>) should be fully left aligned (aka no indent), and the parameters (<code>port:</code>) should be indented two (2) spaces.</p>
|
||||
|
||||
<p>While some of these components can technically be moved to a separate file they are so small or “one off’s” where splitting them off is superfluous. Also, you’ll notice the # symbol (hash/pound). This represents a “comment” as far as the commands are interpreted. Put another way, any line prefixed with a <code>#</code> will be ignored. This makes breaking up files for human readability really convenient , not to mention turning off features while leaving the entry intact. (Look at the <code>zigbee:</code> entry above and the sensors entry further down)</p>
|
||||
|
||||
<p>Now, lets assume that a blank file has been created in the hass configuration directory for each of the following:</p>
|
||||
|
||||
<pre><code>groups.yaml
|
||||
zones.yaml
|
||||
automation.yaml
|
||||
notifications.yaml
|
||||
sensors.yaml
|
||||
switches.yaml
|
||||
scripts.yaml
|
||||
media_player.yaml
|
||||
device_tracker.yaml
|
||||
customize.yaml
|
||||
</code></pre>
|
||||
|
||||
<p><code>automation.yaml</code>will hold all the automation component details<br />
|
||||
<code>zones.yaml</code> will hold the zone component details <br />
|
||||
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.</p>
|
||||
|
||||
<p>Inside the base configuration file add the following entries:<br />
|
||||
<code>
|
||||
group: !include groups.yaml
|
||||
zone: !include zones.yaml
|
||||
automation: !include automation.yaml
|
||||
notifications: !include notifications.yaml
|
||||
sensor: !include sensors.yaml
|
||||
switch: !include switches.yaml
|
||||
scripts: !include: scripts.yaml
|
||||
media_player: !include media_player.yaml
|
||||
device_tracker: !include device_tracker.yaml
|
||||
</code><br />
|
||||
Note that there can only be one <code>!include:</code> for each component so chaining them isn’t going to work. If that sounds like greek, don’t worry about it.</p>
|
||||
|
||||
<p>Alright, so we’ve got the single components and the include statements in the base file, what goes in those extra files?</p>
|
||||
|
||||
<p>Let’s look at the <code>device_tracker</code> file from our example:</p>
|
||||
|
||||
<pre><code>### device_tracker.yaml
|
||||
###
|
||||
###
|
||||
|
||||
- platform: owntracks
|
||||
- platform: nmap_tracker
|
||||
hosts: 192.168.2.0/24
|
||||
home_interval: 3
|
||||
|
||||
track_new_devices: yes
|
||||
interval_seconds: 40
|
||||
consider_home: 120
|
||||
</code></pre>
|
||||
<p>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 (<code>- platform: owntracks</code>) followed by the parameter entries indented two (2) spaces.</p>
|
||||
|
||||
<p>This (large) sensor configuration gives us another example:<br />
|
||||
```<br />
|
||||
### sensors.yaml<br />
|
||||
###<br />
|
||||
###<br />
|
||||
###<br />
|
||||
##############################################################<br />
|
||||
### METEOBRIDGE ####<br />
|
||||
### http://meteobridge.com/wiki/index.php/Add-On_Services ####<br />
|
||||
### Live Data as Plain text ####<br />
|
||||
##############################################################</p>
|
||||
|
||||
<ul>
|
||||
<li>platform: tcp<br />
|
||||
name: ‘Outdoor Temp (Meteobridge)’<br />
|
||||
host: 192.168.2.82<br />
|
||||
timeout: 6<br />
|
||||
payload: “Content-type: text/xml; charset=UTF-8\n\n” <br />
|
||||
value_template: “”<br />
|
||||
unit: C</li>
|
||||
<li>platform: tcp<br />
|
||||
name: ‘Outdoor Humidity (Meteobridge)’<br />
|
||||
host: 192.168.2.82<br />
|
||||
port: 5556<br />
|
||||
timeout: 6<br />
|
||||
payload: “Content-type: text/xml; charset=UTF-8\n\n”<br />
|
||||
value_template: “”<br />
|
||||
unit: Percent</li>
|
||||
<li>platform: tcp<br />
|
||||
name: ‘Outdoor Dewpoint (Meteobridge)’<br />
|
||||
host: 192.168.2.82<br />
|
||||
port: 5556<br />
|
||||
timeout: 6<br />
|
||||
payload: “Content-type: text/xml; charset=UTF-8\n\n”<br />
|
||||
value_template: “”<br />
|
||||
unit: C</li>
|
||||
<li>platform: tcp<br />
|
||||
name: ‘Wind Direction (Meteobridge)’<br />
|
||||
host: 192.168.2.82<br />
|
||||
port: 5556<br />
|
||||
timeout: 6<br />
|
||||
payload: “Content-type: text/xml; charset=UTF-8\n\n”<br />
|
||||
value_template: “”<br />
|
||||
unit: Degrees</li>
|
||||
<li>platform: tcp<br />
|
||||
name: ‘Wind Gust (Meteohub)’<br />
|
||||
host: 192.168.2.82<br />
|
||||
port: 5556<br />
|
||||
timeout: 6<br />
|
||||
payload: “Content-type: text/xml; charset=UTF-8\n\n”<br />
|
||||
value_template: “”<br />
|
||||
unit: m/s</li>
|
||||
<li>platform: tcp<br />
|
||||
name: ‘Wind Speed (Meteobridge)’<br />
|
||||
host: 192.168.2.82<br />
|
||||
port: 5556<br />
|
||||
timeout: 6<br />
|
||||
payload: “Content-type: text/xml; charset=UTF-8\n\n”<br />
|
||||
value_template: “”<br />
|
||||
unit: m/s</li>
|
||||
<li>platform: tcp<br />
|
||||
name: ‘Wind Chill (Meteobridge)’<br />
|
||||
host: 192.168.2.82<br />
|
||||
port: 5556<br />
|
||||
timeout: 6<br />
|
||||
payload: “Content-type: text/xml; charset=UTF-8\n\n”<br />
|
||||
value_template: “”<br />
|
||||
unit: C</li>
|
||||
<li>platform: tcp<br />
|
||||
name: ‘Precip Rate (Meteobridge)’<br />
|
||||
host: 192.168.2.82<br />
|
||||
port: 5556<br />
|
||||
timeout: 6<br />
|
||||
payload: “Content-type: text/xml; charset=UTF-8\n\n”<br />
|
||||
value_template: “”<br />
|
||||
unit: mm/hr</li>
|
||||
<li>platform: tcp<br />
|
||||
name: ‘Precip Total (Meteobridge)’<br />
|
||||
host: 192.168.2.82<br />
|
||||
port: 5556<br />
|
||||
timeout: 6<br />
|
||||
payload: “Content-type: text/xml; charaset=UTF-8\n\n”<br />
|
||||
value_template: “”<br />
|
||||
unit: mm</li>
|
||||
<li>platform: tcp<br />
|
||||
name: ‘Precip Change (Meteobridge)’<br />
|
||||
host: 192.168.2.82<br />
|
||||
port: 5556<br />
|
||||
timeout: 6<br />
|
||||
payload: “Content-type: text/xml; charaset=UTF-8\n\n”<br />
|
||||
value_template: “”<br />
|
||||
unit: mm</li>
|
||||
<li>platform: tcp<br />
|
||||
name: ‘Indoor Temp (Meteobridge)’<br />
|
||||
host: 192.168.2.82<br />
|
||||
port: 5556<br />
|
||||
timeout: 6<br />
|
||||
payload: “Content-type: text/xml; charaset=UTF-8\n\n”<br />
|
||||
value_template: “”<br />
|
||||
unit: C</li>
|
||||
<li>platform: tcp<br />
|
||||
name: ‘Indoor Humidity (Meteobridge)’<br />
|
||||
host: 192.168.2.82<br />
|
||||
port: 5556<br />
|
||||
timeout: 6<br />
|
||||
payload: “Content-type: text/xml; charaset=UTF-8\n\n”<br />
|
||||
value_template: “”<br />
|
||||
unit: percent</li>
|
||||
<li>platform: tcp<br />
|
||||
name: ‘Indoor Dewpoint (Meteobridge)’<br />
|
||||
host: 192.168.2.82<br />
|
||||
port: 5556<br />
|
||||
timeout: 6<br />
|
||||
payload: “Content-type: text/xml; charaset=UTF-8\n\n”<br />
|
||||
value_template: “”<br />
|
||||
unit: C</li>
|
||||
<li>platform: tcp<br />
|
||||
name: ‘Barometric Pressure (Meteobridge)’<br />
|
||||
host: 192.168.2.82<br />
|
||||
port: 5556<br />
|
||||
timeout: 6<br />
|
||||
payload: “Content-type: text/xml; charaset=UTF-8\n\n”<br />
|
||||
value_template: “”<br />
|
||||
unit: mb</li>
|
||||
<li>
|
||||
<p>platform: tcp<br />
|
||||
name: ‘Sea Level Pressure (Meteobridge)’<br />
|
||||
host: 192.168.2.82<br />
|
||||
port: 5556<br />
|
||||
timeout: 6<br />
|
||||
payload: “Content-type: text/xml; charaset=UTF-8\n\n”<br />
|
||||
value_template: “”<br />
|
||||
unit: mb<br />
|
||||
###################################<br />
|
||||
#### STEAM FRIENDS ####<br />
|
||||
##################################</p>
|
||||
</li>
|
||||
<li>platform: steam_online<br />
|
||||
api_key: [not telling]<br />
|
||||
accounts:<br />
|
||||
- 76561198012067051</li>
|
||||
</ul>
|
||||
|
||||
<p>##################################<br />
|
||||
#### TIME/DATE ####<br />
|
||||
##################################</p>
|
||||
|
||||
<ul>
|
||||
<li>platform: time_date<br />
|
||||
display_options:<br />
|
||||
- ‘time’<br />
|
||||
- ‘date’</li>
|
||||
<li>platform: worldclock<br />
|
||||
time_zone: Etc/UTC<br />
|
||||
name: ‘UTC’</li>
|
||||
<li>platform: worldclock<br />
|
||||
time_zone: America/New_York<br />
|
||||
name: ‘Ann Arbor’</li>
|
||||
<li>platform: worldclock<br />
|
||||
time_zone: Europe/Vienna<br />
|
||||
name: ‘Innsbruck’</li>
|
||||
<li>platform: worldclock<br />
|
||||
time_zone: America/New_York<br />
|
||||
name: ‘Ann Arbor’<br />
|
||||
```</li>
|
||||
</ul>
|
||||
|
||||
<p>You’ll notice that this example includes a secondary parameter section (under the steam section) as well as a better example of the way comments can be used to break down files into sections.</p>
|
||||
|
||||
<p>That about wraps it up.</p>
|
||||
|
||||
<p>If you have issues checkout <code>home-assistant.log</code> in the configuration directory as well as your indentations. If all else fails, head over to the gitter.im chat and ask away.</p>
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue