Update configuration_yaml_index.md (#644)

This commit is contained in:
Austin Mroczek 2020-10-13 04:28:44 -07:00 committed by GitHub
parent 7253f7ad6f
commit 1edeaf112a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,55 +1,62 @@
--- ---
title: "Integration Configuration via YAML" title: "Integration Configuration via YAML"
--- ---
`configuration.yaml` is a configuration file defined by the user. It is automatically created by Home Assistant on first launch. It defines which components to load. `configuration.yaml` is a configuration file defined by the user. It is automatically created by Home Assistant on first launch. It defines which components to load.
## Pre-processing :::info Note about YAML for devices and/or services
Home Assistant will do some pre-processing on the config based on the components that are specified to load. Integrations that communicate with devices and/or services are configured via a config flow. In rare cases, we can make an exception. Existing integrations that should not have a YAML configuration are allowed and encouraged to implement a configuration flow and remove YAML support. Changes to existing YAML configuration for these same existing integrations will no longer be accepted.
### CONFIG_SCHEMA For more detail read [ADR-0010](https://github.com/home-assistant/architecture/blob/master/adr/0010-integration-configuration.md#decision)
:::
If a component defines a variable `CONFIG_SCHEMA`, the config object that is passed in will be the result of running the config through `CONFIG_SCHEMA`. `CONFIG_SCHEMA` should be a voluptuous schema.
## Pre-processing
### PLATFORM_SCHEMA
Home Assistant will do some pre-processing on the config based on the components that are specified to load.
If a component defines a variable `PLATFORM_SCHEMA`, the component will be treated as an entity component. The configuration of entity components is a list of platform configurations.
### CONFIG_SCHEMA
Home Assistant will gather all platform configurations for this component. It will do so by looking for configuration entries under the domain of the component (ie `light`) but also under any entry of domain + extra text.
If a component defines a variable `CONFIG_SCHEMA`, the config object that is passed in will be the result of running the config through `CONFIG_SCHEMA`. `CONFIG_SCHEMA` should be a voluptuous schema.
While gathering the platform configs, Home Assistant will validate them. It will see if the platform exists and if the platform defines a PLATFORM_SCHEMA, validate against that schema. If not defined, it will validate the config against the PLATFORM_SCHEMA defined in the component. Any configuration that references non existing platforms or contains invalid config will be removed.
### PLATFORM_SCHEMA
The following `configuration.yaml`:
If a component defines a variable `PLATFORM_SCHEMA`, the component will be treated as an entity component. The configuration of entity components is a list of platform configurations.
```yaml
unrelated_component: Home Assistant will gather all platform configurations for this component. It will do so by looking for configuration entries under the domain of the component (ie `light`) but also under any entry of domain + extra text.
some_key: some_value
While gathering the platform configs, Home Assistant will validate them. It will see if the platform exists and if the platform defines a PLATFORM_SCHEMA, validate against that schema. If not defined, it will validate the config against the PLATFORM_SCHEMA defined in the component. Any configuration that references non existing platforms or contains invalid config will be removed.
switch:
platform: example1 The following `configuration.yaml`:
switch living room: ```yaml
- platform: example2 unrelated_component:
some_config: true some_key: some_value
- platform: invalid_platform
``` switch:
platform: example1
will be passed to the component as
switch living room:
```python - platform: example2
{ some_config: true
"unrelated_component": { - platform: invalid_platform
"some_key": "some_value" ```
},
"switch": [ will be passed to the component as
{
"platform": "example1" ```python
}, {
{ "unrelated_component": {
"platform": "example2", "some_key": "some_value"
"some_config": True },
} "switch": [
], {
} "platform": "example1"
``` },
{
"platform": "example2",
"some_config": True
}
],
}
```