Merge pull request #838 from home-assistant/kellerza-check_config-1

Introduce the check_config script in 0.27
This commit is contained in:
Robbie Trencheny 2016-08-27 20:55:06 -07:00 committed by GitHub
commit 9f23d1d223
4 changed files with 53 additions and 26 deletions

View File

@ -9,11 +9,11 @@ sharing: true
footer: true
---
The `configuration.yaml` file a plain-text file thus it is readable for everyone who has access to the file. The file contains passwords and API tokens which need to be redacted if you want to share your configuration. This separation can also help you to keep easier track of your passwords and API keys (as they are all stored at one place and no longer spread across the `configuration.yaml` file) if you don't want to [split up your configuration](/topics/splitting_configuration/).
The `configuration.yaml` file is a plain-text file, thus it is readable by anyone who has access to the file. The file contains passwords and API tokens which need to be redacted if you want to share your configuration. By using `!secrets` you can remove any private information from you configuration files. This separation can also help you to keep easier track of your passwords and API keys. As they are all stored at one place and no longer spread across the `configuration.yaml` file or even multiple yaml files if you [split up your configuration](/topics/splitting_configuration/).
### {% linkable_title Using secrets.yaml %}
The workflow for the outsourcing in the `secrets.yaml` is very similar to the [splitting of the configuration](/topics/splitting_configuration/). Create a `secrets.yaml` file in your Home assistant configuration directory (The location of the folder differs between operating systems: on OS X and Linux it's `~/.homeassistant` and on Windows it's `%APPDATA%/.homeassistant`).
The workflow for moving private information to `secrets.yaml` is very similar to the [splitting of the configuration](/topics/splitting_configuration/). Create a `secrets.yaml` file in your Home assistant configuration directory (The location of the folder differs between operating systems: on OS X and Linux it's `~/.homeassistant` and on Windows it's `%APPDATA%/.homeassistant`).
The entries for password and API keys in the `configuration.yaml` file usually looks like the example below.
@ -32,10 +32,30 @@ http:
The `secrets.yaml` file contains the corresponding password assigned to the identifier.
```yaml
logger: debug
http_password: YOUR_PASSWORD
```
### {% linkable_title Debugging secrets %}
When you start splitting your configuration into multiple files, you might end up with configuration in sub folders. Secrets will be resolved in this order:
- A `secrets.yaml` located in the same folder as the yaml file referencing the secret,
- next, parent folders will be searched for a `secrets.yaml` file with the secret, stopping at the folder with the main `configuration.yaml`,
- lastly, `keyring` will be queried for the secret (more info below)
To see where secrets are being loaded from you can either add an option to your `secrets.yaml` file or use the `check_config` script.
*Option 1*: Print where secrets are retrieved from to the Home Assistant log by adding the following to `secrets.yaml`:
```yaml
logger: debug
```
This will not print the actual secret's value to the log.
*Option 2*: View where secrets are retrieved from and the contents of all `secrets.yaml` files used, you can use the `check_config` script from the command line:
```bash
hass --script check_config --secrets
```
This will print all your secrets
### {% linkable_title Storing passwords in a keyring managed by your OS %}
Using [Keyring](http://pythonhosted.org/keyring/) is an alternative way to `secrets.yaml`. They can be managed from the command line via the keyring script.
@ -57,7 +77,7 @@ Create an entry in your keyring.
$ hass --script keyring set http_password
```
If you launch home Assistant now, you will be prompted for the keyring password to unlock your keyring.
If you launch Home Assistant now, you will be prompted for the keyring password to unlock your keyring.
```bash
$ hass

View File

@ -15,7 +15,7 @@ First off, several community members have sanitized (read: without api keys/pass
As commenting code doesn't always happen, please read on for the details.
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.
Now despite the logical assumption that the `configuration.yaml` will be replaced by this process it will in fact remain, albeit in a much less cluttered form.
In this lighter version we will still need what could be called the core snippet:
@ -179,17 +179,23 @@ That about wraps it up.
If you have issues checkout `home-assistant.log` in the configuration directory as well as your indentations. If all else fails, head over to the [Gitter Chatroom](https://gitter.im/balloob/home-assistant) and ask away.
### {% linkable_title Debugging multiple configuration files %}
If you have many configuration files, the `check_config` script allows you to see how Home Assistant interprets them:
- Listing all loaded files: `hass --script --check_config --files`
- Viewing a component's config: `hass --script --check_config --info light`
- Or all components' config: `hass --script check_config --info all`
You can get help from the command line using: `hass --script check_config --help`
### {% linkable_title Advanced Usage %}
We offer four advanced options to include whole directories at once.
- `!include_dir_list` will return the content of a directory as a list with each file content being an entry in the list.
- `!include_dir_named` will return the content of a directory as a dictionary which maps filename => content of file.
- `!include_dir_merge_list` will return the content of a directory as a list by merging all files (which should contain a list) into 1 big list.
- `!include_dir_merge_named` will return the content of a directory as a dictionary by loading each file and merging it into 1 big dictionary.
`!include_dir_list` will return content of a directory as a list with each file content being an entry in the list.
`!include_dir_named` will return content of a directory as a dictionary which maps filename => content of file.
`!include_dir_merge_list` will return content of a directory as a list by merging all files (which should contain a list) into 1 big list.
`!include_dir_merge_named` will return content of a directory as a dictionary by loading each file and merging it into 1 big dictionary.
#### {% linkable_title Example: `!include_dir_list` %}

View File

@ -23,14 +23,14 @@ If you want to use a different folder for configuration, use the config command
Inside your configuration folder is the file `configuration.yaml`. This is the main file that contains which components will be loaded and what their configuration is. Throughout the documentation you will find snippets that you can add to your configuration file to enable that functionality.
If you run into trouble while configuring Home Assistant, have a look at [the configuration troubleshooting page](/getting-started/troubleshooting-configuration/) and at the [configuration.yaml examples](/cookbook/#example-configurationyaml).
<p class='note'>
You will have to restart Home Assistant for changes to `configuration.yaml` take effect.
You will have to restart Home Assistant for changes to `configuration.yaml` to take effect.
</p>
If you run into trouble while configuring Home Assistant, have a look at the [configuration troubleshooting page](/getting-started/troubleshooting-configuration/) and at the [configuration.yaml examples](/cookbook/#example-configurationyaml).
<p class='note tip'>
Install colorlog (`$ pip3 install colorlog`) to make the console output easier to read, hence also easier to catch errors and warnings.
Test any changes to your configuration files from the command line with `hass --script check_config`. This script allows you to test changes without the need to restart Home Assistant.
</p>
### [Next step: Get familiar with YAML &raquo;](/getting-started/yaml/)

View File

@ -19,26 +19,27 @@ Whenever a component or configuration option results in a warning, it will be st
When a component does not show up, many different things can be the case. Before you try any of these steps, make sure to look at the `home-assistant.log` file and see if there are any errors related to your component you are trying to set up.
If you have incorrect entries in your configuration files you can use the `check_config` script to assist in identifying them: `hass --script check_config`.
#### {% linkable_title Problems with the configuration %}
One of the most common problems with Home Assistant is an invalid `configuration.yaml` file.
- You can test your configuration using [this online YAML parser](http://yaml-online-parser.appspot.com/) or [YAML Lint](http://www.yamllint.com/).
- You can test your configuration using the command line with: `hass --script check_config`
- You can verify your configuration's yaml structure using [this online YAML parser](http://yaml-online-parser.appspot.com/) or [YAML Lint](http://www.yamllint.com/).
- To learn more about the quirks of YAML, read [YAML IDIOSYNCRASIES](https://docs.saltstack.com/en/latest/topics/troubleshooting/yaml_idiosyncrasies.html) by SaltStack (the examples there are specific to SaltStack, but do explain YAML issues well).
`configuration.yaml` does not allow multiple sections to have the same name. If you want a specific platform to be loaded twice, append a [number or string](/getting-started/devices/#style-2) to the name or nest them using [this style](/getting-started/devices/#style-1).
`configuration.yaml` does not allow multiple sections to have the same name. If you want to load multiplte platforms for one component, you can append a [number or string](/getting-started/devices/#style-2-list-each-device-separately) to the name or nest them using [this style](/getting-started/devices/#style-1-collect-every-entity-under-the-parent):
```yaml
sensor:
platform: forecast
...
sensor 2:
platform: bitcoin
...
- platform: forecast
...
- platform: bitcoin
...
```
Another common problem is that a required configuration setting is missing. If this is the case, the component will report this to `home-assistant.log`. You can have a look at [the component page](/components/) for instructions on how to setup the components.
Another common problem is that a required configuration setting is missing. If this is the case, the component will report this to `home-assistant.log`. You can have a look at [the various component pages](/components/) for instructions on how to setup the components.
If you find any errors or want to expand the documentation, please [let us know](https://github.com/home-assistant/home-assistant.io/issues).