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 binary sensors."""
|
||||
from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
from datetime import timedelta
|
||||
import functools
|
||||
import logging
|
||||
|
@ -42,8 +41,8 @@ from .mixins import (
|
|||
MQTT_ENTITY_COMMON_SCHEMA,
|
||||
MqttAvailability,
|
||||
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 binary sensor configured under the fan platform key (deprecated)."""
|
||||
# Deprecated in HA Core 2022.6
|
||||
await async_setup_platform_helper(
|
||||
hass, binary_sensor.DOMAIN, config, async_add_entities, _async_setup_entity
|
||||
hass,
|
||||
binary_sensor.DOMAIN,
|
||||
discovery_info or config,
|
||||
async_add_entities,
|
||||
_async_setup_entity,
|
||||
)
|
||||
|
||||
|
||||
|
@ -99,12 +102,9 @@ async def async_setup_entry(
|
|||
) -> None:
|
||||
"""Set up MQTT binary sensor 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, binary_sensor.DOMAIN, PLATFORM_SCHEMA_MODERN
|
||||
)
|
||||
config_entry.async_on_unload(
|
||||
await async_setup_platform_discovery(
|
||||
hass, binary_sensor.DOMAIN, PLATFORM_SCHEMA_MODERN
|
||||
)
|
||||
)
|
||||
# setup for discovery
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue