Fix mysensors device tracker (#47536)
parent
b01a6367cc
commit
f542b360d5
|
@ -8,6 +8,7 @@ from mysensors import BaseAsyncGateway
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant import config_entries
|
from homeassistant import config_entries
|
||||||
|
from homeassistant.components.device_tracker import DOMAIN as DEVICE_TRACKER_DOMAIN
|
||||||
from homeassistant.components.mqtt import valid_publish_topic, valid_subscribe_topic
|
from homeassistant.components.mqtt import valid_publish_topic, valid_subscribe_topic
|
||||||
from homeassistant.components.notify import DOMAIN as NOTIFY_DOMAIN
|
from homeassistant.components.notify import DOMAIN as NOTIFY_DOMAIN
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
|
@ -195,24 +196,27 @@ async def async_setup_entry(hass: HomeAssistantType, entry: ConfigEntry) -> bool
|
||||||
hass.data[DOMAIN][MYSENSORS_GATEWAYS][entry.entry_id] = gateway
|
hass.data[DOMAIN][MYSENSORS_GATEWAYS][entry.entry_id] = gateway
|
||||||
|
|
||||||
# Connect notify discovery as that integration doesn't support entry forwarding.
|
# Connect notify discovery as that integration doesn't support entry forwarding.
|
||||||
|
# Allow loading device tracker platform via discovery
|
||||||
|
# until refactor to config entry is done.
|
||||||
|
|
||||||
load_notify_platform = partial(
|
for platform in (DEVICE_TRACKER_DOMAIN, NOTIFY_DOMAIN):
|
||||||
async_load_platform,
|
load_discovery_platform = partial(
|
||||||
hass,
|
async_load_platform,
|
||||||
NOTIFY_DOMAIN,
|
|
||||||
DOMAIN,
|
|
||||||
hass_config=hass.data[DOMAIN][DATA_HASS_CONFIG],
|
|
||||||
)
|
|
||||||
|
|
||||||
await on_unload(
|
|
||||||
hass,
|
|
||||||
entry.entry_id,
|
|
||||||
async_dispatcher_connect(
|
|
||||||
hass,
|
hass,
|
||||||
MYSENSORS_DISCOVERY.format(entry.entry_id, NOTIFY_DOMAIN),
|
platform,
|
||||||
load_notify_platform,
|
DOMAIN,
|
||||||
),
|
hass_config=hass.data[DOMAIN][DATA_HASS_CONFIG],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
await on_unload(
|
||||||
|
hass,
|
||||||
|
entry.entry_id,
|
||||||
|
async_dispatcher_connect(
|
||||||
|
hass,
|
||||||
|
MYSENSORS_DISCOVERY.format(entry.entry_id, platform),
|
||||||
|
load_discovery_platform,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
async def finish() -> None:
|
async def finish() -> None:
|
||||||
await asyncio.gather(
|
await asyncio.gather(
|
||||||
|
|
Loading…
Reference in New Issue