Fix reload of MQTT yaml config (#72901)
This commit is contained in:
parent
8e4321af59
commit
b97d346df7
21 changed files with 241 additions and 183 deletions
|
@ -1,7 +1,6 @@
|
|||
"""Support for MQTT locks."""
|
||||
from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
import functools
|
||||
|
||||
import voluptuous as vol
|
||||
|
@ -28,8 +27,8 @@ from .debug_info import log_messages
|
|||
from .mixins import (
|
||||
MQTT_ENTITY_COMMON_SCHEMA,
|
||||
MqttEntity,
|
||||
async_get_platform_config_from_yaml,
|
||||
async_setup_entry_helper,
|
||||
async_setup_platform_discovery,
|
||||
async_setup_platform_helper,
|
||||
warn_for_legacy_schema,
|
||||
)
|
||||
|
@ -88,7 +87,11 @@ async def async_setup_platform(
|
|||
"""Set up MQTT locks configured under the lock platform key (deprecated)."""
|
||||
# Deprecated in HA Core 2022.6
|
||||
await async_setup_platform_helper(
|
||||
hass, lock.DOMAIN, config, async_add_entities, _async_setup_entity
|
||||
hass,
|
||||
lock.DOMAIN,
|
||||
discovery_info or config,
|
||||
async_add_entities,
|
||||
_async_setup_entity,
|
||||
)
|
||||
|
||||
|
||||
|
@ -99,13 +102,8 @@ async def async_setup_entry(
|
|||
) -> None:
|
||||
"""Set up MQTT lock through configuration.yaml and dynamically through MQTT discovery."""
|
||||
# load and initialize platform config from configuration.yaml
|
||||
await asyncio.gather(
|
||||
*(
|
||||
_async_setup_entity(hass, async_add_entities, config, config_entry)
|
||||
for config in await async_get_platform_config_from_yaml(
|
||||
hass, lock.DOMAIN, PLATFORM_SCHEMA_MODERN
|
||||
)
|
||||
)
|
||||
config_entry.async_on_unload(
|
||||
await async_setup_platform_discovery(hass, lock.DOMAIN, PLATFORM_SCHEMA_MODERN)
|
||||
)
|
||||
# setup for discovery
|
||||
setup = functools.partial(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue