Add suggested_area to MQTT discovery (#47903)
* Add suggested_area to MQTT Discovery This adds suggested_area to MQTT discovery, so that the discovered devices could be automatically added to the proper area. * Add abbreviation for MQTT suggested_area * Remove extra whitespace * Remove extra whitespace #2 * Added tests for MQTT Dicovery of suggested_area * Fix test for MQTT suggested_area * Better tests of MQTT suggested_area Changes made as per feedback from @emontnemery
This commit is contained in:
parent
07c197687f
commit
9f4c2f6260
4 changed files with 12 additions and 1 deletions
|
@ -203,4 +203,5 @@ DEVICE_ABBREVIATIONS = {
|
|||
"mf": "manufacturer",
|
||||
"mdl": "model",
|
||||
"sw": "sw_version",
|
||||
"sa": "suggested_area",
|
||||
}
|
||||
|
|
|
@ -63,6 +63,7 @@ CONF_MODEL = "model"
|
|||
CONF_SW_VERSION = "sw_version"
|
||||
CONF_VIA_DEVICE = "via_device"
|
||||
CONF_DEPRECATED_VIA_HUB = "via_hub"
|
||||
CONF_SUGGESTED_AREA = "suggested_area"
|
||||
|
||||
MQTT_AVAILABILITY_SINGLE_SCHEMA = vol.Schema(
|
||||
{
|
||||
|
@ -129,6 +130,7 @@ MQTT_ENTITY_DEVICE_INFO_SCHEMA = vol.All(
|
|||
vol.Optional(CONF_NAME): cv.string,
|
||||
vol.Optional(CONF_SW_VERSION): cv.string,
|
||||
vol.Optional(CONF_VIA_DEVICE): cv.string,
|
||||
vol.Optional(CONF_SUGGESTED_AREA): cv.string,
|
||||
}
|
||||
),
|
||||
validate_device_has_at_least_one_identifier,
|
||||
|
@ -491,6 +493,9 @@ def device_info_from_config(config):
|
|||
if CONF_VIA_DEVICE in config:
|
||||
info["via_device"] = (DOMAIN, config[CONF_VIA_DEVICE])
|
||||
|
||||
if CONF_SUGGESTED_AREA in config:
|
||||
info["suggested_area"] = config[CONF_SUGGESTED_AREA]
|
||||
|
||||
return info
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue