Skip to content

Commit

Permalink
Feature/yaml doc (#3534)
Browse files Browse the repository at this point in the history
* Add text on similarities between yaml and dicts

- Linewrapped the respective text to a with of 80 chars as well

* Adds reference to dicts/Hashtables when expl. YAML

- A comparison between dictionary/hastables and YAML is drawn
- Linewraps the paragraph to 80 characters

* Adds reference to python, indentation is mentioned

* Minor changes
  • Loading branch information
jhoepken authored and fabaff committed Oct 6, 2017
1 parent f9e3f7e commit d596888
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions source/_docs/configuration/yaml.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,17 @@ notify:
name: pushbullet
```
- A **component** provides the core logic for some functionality (like `notify` provides sending notifications).
- A **component** provides the core logic for some functionality (like `notify` provides sending notifications).
- A **platform** makes the connection to a specific software or hardware platform (like `pushbullet` works with the service from pushbullet.com).

The basics of YAML syntax are block collections and mappings containing key-value pairs. Each item in a collection starts with a `-` while mappings have the format `key: value`. If you specify duplicate keys, the last value for a key is used.
The basics of YAML syntax are block collections and mappings containing key-value pairs. Each item in a collection starts with a `-` while mappings have the format `key: value`. If you specify duplicate keys, the last value for a key is used. This is somewhat similar to a Hashtable or more specifically a dictionary in Python. These can be nested as well.

Note that indentation is an important part of specifying relationships using YAML. Things that are indented are nested "inside" things that are one level higher. So in the above example, `platform: pushbullet` is a property of (nested inside) the `notify` component.
Note that indentation (just like in Python) is an important part of specifying relationships using YAML. Things that are indented are nested "inside" things that are one level higher. So in the above example, `platform: pushbullet` is a property of (nested inside) the `notify` component.
Getting the right indentation can be tricky if you're not using an editor with a fixed width font. Tabs are not allowed to be used for indentation. Convention is to use 2 spaces for each level of indentation.
You can use [YAMLLint](http://www.yamllint.com/) to check if your YAML-syntax is correct before loading it into Home Assistant which will save you some time.
You can use [YAMLLint](http://www.yamllint.com/) to check if your YAML-syntax is correct before loading it into Home Assistant which will save you some time.
*Please pay attention on not putting in private data, as it is a 3rd-party website not maintained by Home Assistant.*

Text following a **#** are comments and are ignored by the system.
Text following a `#` are comments and are ignored by the system.

The next example shows an [input_select](/components/input_select) component that uses a block collection for the options values.
The other properties (like name) are specified using mappings. Note that the second line just has `threat:` with no value on the same line. Here threat is the name of the input_select and the values for it are everything nested below it.
Expand All @@ -51,7 +51,7 @@ input_select:
initial: 0
```

The following example shows nesting a collection of mappings in a mapping. In Home Assistant, this would create two sensors that each use the MQTT platform but have different values for their `state_topic` (one of the properties used for MQTT sensors).
The following example shows nesting a collection of mappings in a mapping. In Home Assistant, this would create two sensors that each use the MQTT platform but have different values for their `state_topic` (one of the properties used for MQTT sensors).

```yaml
sensor:
Expand Down

0 comments on commit d596888

Please sign in to comment.