mirror of
https://github.com/home-assistant/home-assistant.io.git
synced 2025-07-22 08:46:51 +00:00
Document MQTT discovery messages allow unknown configuration keys (#23303)
This commit is contained in:
parent
ed3a8fe920
commit
671d09d8d6
@ -44,6 +44,8 @@ discovery_prefix:
|
||||
type: string
|
||||
{% endconfiguration %}
|
||||
|
||||
## Discovery messages
|
||||
|
||||
## Discovery topic
|
||||
|
||||
The discovery topic need to follow a specific format:
|
||||
@ -56,14 +58,16 @@ The discovery topic need to follow a specific format:
|
||||
- `<node_id>` (*Optional*): ID of the node providing the topic, this is not used by Home Assistant but may be used to structure the MQTT topic. The ID of the node must only consist of characters from the character class `[a-zA-Z0-9_-]` (alphanumerics, underscore and hyphen).
|
||||
- `<object_id>`: The ID of the device. This is only to allow for separate topics for each device and is not used for the `entity_id`. The ID of the device must only consist of characters from the character class `[a-zA-Z0-9_-]` (alphanumerics, underscore and hyphen).
|
||||
|
||||
The `<node_id>` level can be used by clients to only subscribe to their own (command) topics by using one wildcard topic like `<discovery_prefix>/+/<node_id>/+/set`.
|
||||
|
||||
Best practice for entities with a `unique_id` is to set `<object_id>` to `unique_id` and omit the `<node_id>`.
|
||||
|
||||
The payload must be a JSON dictionary and will be checked like an entry in your `configuration.yaml` file if a new device is added. This means that missing variables will be filled with the platform's default values. All configuration variables which are *required* must be present in the initial payload send to `/config`.
|
||||
## Discovery payload
|
||||
|
||||
The payload must be a serialized JSON dictionary and will be checked like an entry in your `configuration.yaml` file if a new device is added, with the exception that unknown configuration keys are allowed but ignored. This means that missing variables will be filled with the platform's default values. All configuration variables which are *required* must be present in the payload. The reason for allowing unknown documentation keys is allow some backwards compatibility, software generating MQTT discovery messages can then be used with older Home Assistant versions which will simply ignore new features.
|
||||
|
||||
Subsequent messages on a topic where a valid payload has been received will be handled as a configuration update, and a configuration update with an empty payload will cause a previously discovered device to be deleted.
|
||||
|
||||
The `<node_id>` level can be used by clients to only subscribe to their own (command) topics by using one wildcard topic like `<discovery_prefix>/+/<node_id>/+/set`.
|
||||
|
||||
A base topic `~` may be defined in the payload to conserve memory when the same topic base is used multiple times.
|
||||
In the value of configuration variables ending with `_topic`, `~` will be replaced with the base topic, if the `~` occurs at the beginning or end of the value.
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user