Mqtt add object_id (#20217)

* Add MQTT object_id option

* add object_id doc each entities type

* Spelling

* Update source/_docs/mqtt/discovery.markdown

Co-authored-by: Erik Montnemery <erik@montnemery.com>

* add object_id doc each entities type

* add object_id doc each entities type

Co-authored-by: Erik Montnemery <erik@montnemery.com>
This commit is contained in:
Damien Duboeuf 2021-11-08 19:36:18 +01:00 committed by GitHub
parent 4979b7ee76
commit 2b18d0232e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 96 additions and 0 deletions

View File

@ -164,6 +164,7 @@ Supported abbreviations:
'mode_stat_t': 'mode_state_topic',
'modes': 'modes',
'name': 'name',
'obj_id': 'object_id',
'off_dly': 'off_delay',
'on_cmd_type': 'on_command_type',
'opt': 'optimistic',
@ -481,3 +482,22 @@ If the device supports gps coordinates then they can be sent to Home Assistant b
"gps_accuracy": 1.2
}
```
### Use object_id to influence the entity id
The entity id is automatically generated from the entity's name. All MQTT entity components optionally support providing an `object_id` which will be used instead if provided.
- Configuration topic: `homeassistant/sensor/device1/config`
- Example configuration payload:
```json
{
"name":"My Super Device",
"object_id":"device1",
"state_topic": "homeassistant/sensor/device1/state",
}
```
In the example above, the the entity_id will be `sensor.device1` instead of `sensor.my_super_device`.

View File

@ -157,6 +157,10 @@ name:
required: false
type: string
default: MQTT Alarm
object_id:
description: Used instead of `name` for automatic generation of `entity_id`
required: false
type: string
payload_arm_away:
description: The payload to set armed-away mode on your Alarm Panel.
required: false

View File

@ -140,6 +140,10 @@ name:
required: false
type: string
default: MQTT Binary Sensor
object_id:
description: Used instead of `name` for automatic generation of `entity_id`
required: false
type: string
off_delay:
description: "For sensors that only send `on` state updates (like PIRs), this variable sets a delay in seconds after which the sensor's state will be updated back to `off`."
required: false

View File

@ -119,6 +119,10 @@ name:
description: The name of the camera.
required: false
type: string
object_id:
description: Used instead of `name` for automatic generation of `entity_id`
required: false
type: string
topic:
description: The MQTT topic to subscribe to.
required: true

View File

@ -234,6 +234,10 @@ name:
required: false
type: string
default: MQTT HVAC
object_id:
description: Used instead of `name` for automatic generation of `entity_id`
required: false
type: string
payload_available:
description: The payload that represents the available state.
required: false

View File

@ -141,6 +141,10 @@ name:
required: false
type: string
default: MQTT Cover
object_id:
description: Used instead of `name` for automatic generation of `entity_id`
required: false
type: string
optimistic:
description: Flag that defines if switch works in optimistic mode.
required: false

View File

@ -165,6 +165,10 @@ name:
description: The name of the MQTT device_tracker.
required: false
type: string
object_id:
description: Used instead of `name` for automatic generation of `entity_id`
required: false
type: string
payload_available:
description: The payload that represents the available state.
required: false

View File

@ -132,6 +132,10 @@ name:
required: false
type: string
default: MQTT Fan
object_id:
description: Used instead of `name` for automatic generation of `entity_id`
required: false
type: string
optimistic:
description: Flag that defines if fan works in optimistic mode
required: false

View File

@ -148,6 +148,10 @@ name:
required: false
type: string
default: MQTT humidifier
object_id:
description: Used instead of `name` for automatic generation of `entity_id`
required: false
type: string
optimistic:
description: Flag that defines if humidifier works in optimistic mode
required: false

View File

@ -230,6 +230,10 @@ name:
required: false
type: string
default: MQTT Light
object_id:
description: Used instead of `name` for automatic generation of `entity_id`
required: false
type: string
on_command_type:
description: "Defines when on the payload_on is sent. Using `last` (the default) will send any style (brightness, color, etc) topics first and then a `payload_on` to the `command_topic`. Using `first` will send the `payload_on` and then any style topics. Using `brightness` will only send brightness commands instead of the `payload_on` to turn the light on."
required: false
@ -588,6 +592,10 @@ name:
required: false
type: string
default: MQTT JSON Light
object_id:
description: Used instead of `name` for automatic generation of `entity_id`
required: false
type: string
optimistic:
description: Flag that defines if the light works in optimistic mode.
required: false
@ -928,6 +936,10 @@ name:
required: false
type: string
default: MQTT Template Light
object_id:
description: Used instead of `name` for automatic generation of `entity_id`
required: false
type: string
optimistic:
description: Flag that defines if the light works in optimistic mode.
required: false

View File

@ -128,6 +128,10 @@ name:
required: false
type: string
default: MQTT Lock
object_id:
description: Used instead of `name` for automatic generation of `entity_id`
required: false
type: string
optimistic:
description: Flag that defines if lock works in optimistic mode.
required: false

View File

@ -131,6 +131,10 @@ name:
description: The name of the Number.
required: false
type: string
object_id:
description: Used instead of `name` for automatic generation of `entity_id`
required: false
type: string
optimistic:
description: Flag that defines if number works in optimistic mode.
required: false

View File

@ -73,6 +73,10 @@ name:
required: false
type: string
default: MQTT Scene
object_id:
description: Used instead of `name` for automatic generation of `entity_id`
required: false
type: string
payload_available:
description: The payload that represents the available state.
required: false

View File

@ -125,6 +125,10 @@ name:
description: The name of the Select.
required: false
type: string
object_id:
description: Used instead of `name` for automatic generation of `entity_id`
required: false
type: string
optimistic:
description: Flag that defines if the select works in optimistic mode.
required: false

View File

@ -137,6 +137,10 @@ name:
required: false
type: string
default: MQTT Sensor
object_id:
description: Used instead of `name` for automatic generation of `entity_id`
required: false
type: string
payload_available:
description: The payload that represents the available state.
required: false

View File

@ -128,6 +128,10 @@ name:
required: false
type: string
default: MQTT Switch
object_id:
description: Used instead of `name` for automatic generation of `entity_id`
required: false
type: string
optimistic:
description: Flag that defines if switch works in optimistic mode.
required: false

View File

@ -140,6 +140,10 @@ name:
required: false
type: string
default: MQTT Vacuum
object_id:
description: Used instead of `name` for automatic generation of `entity_id`
required: false
type: string
payload_available:
description: The payload that represents the available state.
required: false
@ -395,6 +399,10 @@ name:
required: false
type: string
default: MQTT Vacuum
object_id:
description: Used instead of `name` for automatic generation of `entity_id`
required: false
type: string
payload_available:
description: The payload that represents the available state.
required: false