configuration.yaml file contains the configuration options for components and platforms. We use voluptuous to make sure that the configuration provided by the user is valid. Some entries are optional or could be required to set up a platform or a component. Others must be a defined type or from an already-defined list.
We test the configuration to ensure that users have a great experience and minimize notifications if something is wrong with a platform or component setup before Home Assistant runs.
- Entity ID:
To validate platforms using MQTT,
valid_publish_topic are available.
Some things to keep in mind:
- Use the constants defined in
PLATFORM_SCHEMAfrom the integration you are integrating with and extend it.
- Preferred order is
- Default values for optional configuration keys need to be valid values. Don't use a default which is
vol.Optional(CONF_SOMETHING, default=None): cv.string, set the default to
This section contains snippets for the validation we use.
It's common to set a default for a sensor if the user doesn't provide a name to use.
Limit the values
You might want to limit the user's input to a couple of options.
All port numbers are from a range of 1 to 65535.
If a sensor has a pre-defined list of available options, test to make sure the configuration entry matches the list.