mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 20:57:21 +00:00
Reduce config entry setup/unload boilerplate K-M (#49775)
This commit is contained in:
parent
b5cb9e4ade
commit
b10534359b
@ -38,10 +38,7 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> b
|
|||||||
UNDO_UPDATE_LISTENER: undo_listener,
|
UNDO_UPDATE_LISTENER: undo_listener,
|
||||||
}
|
}
|
||||||
|
|
||||||
for platform in PLATFORMS:
|
hass.config_entries.async_setup_platforms(config_entry, PLATFORMS)
|
||||||
hass.async_create_task(
|
|
||||||
hass.config_entries.async_forward_entry_setup(config_entry, platform)
|
|
||||||
)
|
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@ -50,8 +47,9 @@ async def async_unload_entry(hass: HomeAssistant, config_entry: ConfigEntry) ->
|
|||||||
"""Unload a config entry."""
|
"""Unload a config entry."""
|
||||||
hass.data[DOMAIN][config_entry.entry_id][UNDO_UPDATE_LISTENER]()
|
hass.data[DOMAIN][config_entry.entry_id][UNDO_UPDATE_LISTENER]()
|
||||||
|
|
||||||
for platform in PLATFORMS:
|
unload_ok = await hass.config_entries.async_unload_platforms(
|
||||||
await hass.config_entries.async_forward_entry_unload(config_entry, platform)
|
config_entry, PLATFORMS
|
||||||
|
)
|
||||||
|
|
||||||
router: KeeneticRouter = hass.data[DOMAIN][config_entry.entry_id][ROUTER]
|
router: KeeneticRouter = hass.data[DOMAIN][config_entry.entry_id][ROUTER]
|
||||||
|
|
||||||
@ -59,7 +57,7 @@ async def async_unload_entry(hass: HomeAssistant, config_entry: ConfigEntry) ->
|
|||||||
|
|
||||||
hass.data[DOMAIN].pop(config_entry.entry_id)
|
hass.data[DOMAIN].pop(config_entry.entry_id)
|
||||||
|
|
||||||
return True
|
return unload_ok
|
||||||
|
|
||||||
|
|
||||||
async def update_listener(hass, config_entry):
|
async def update_listener(hass, config_entry):
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
"""The kmtronic integration."""
|
"""The kmtronic integration."""
|
||||||
import asyncio
|
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
@ -59,10 +58,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
|
|||||||
DATA_COORDINATOR: coordinator,
|
DATA_COORDINATOR: coordinator,
|
||||||
}
|
}
|
||||||
|
|
||||||
for platform in PLATFORMS:
|
hass.config_entries.async_setup_platforms(entry, PLATFORMS)
|
||||||
hass.async_create_task(
|
|
||||||
hass.config_entries.async_forward_entry_setup(entry, platform)
|
|
||||||
)
|
|
||||||
|
|
||||||
update_listener = entry.add_update_listener(async_update_options)
|
update_listener = entry.add_update_listener(async_update_options)
|
||||||
hass.data[DOMAIN][entry.entry_id][UPDATE_LISTENER] = update_listener
|
hass.data[DOMAIN][entry.entry_id][UPDATE_LISTENER] = update_listener
|
||||||
@ -77,14 +73,7 @@ async def async_update_options(hass: HomeAssistant, config_entry: ConfigEntry) -
|
|||||||
|
|
||||||
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry):
|
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry):
|
||||||
"""Unload a config entry."""
|
"""Unload a config entry."""
|
||||||
unload_ok = all(
|
unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
|
||||||
await asyncio.gather(
|
|
||||||
*[
|
|
||||||
hass.config_entries.async_forward_entry_unload(entry, platform)
|
|
||||||
for platform in PLATFORMS
|
|
||||||
]
|
|
||||||
)
|
|
||||||
)
|
|
||||||
if unload_ok:
|
if unload_ok:
|
||||||
update_listener = hass.data[DOMAIN][entry.entry_id][UPDATE_LISTENER]
|
update_listener = hass.data[DOMAIN][entry.entry_id][UPDATE_LISTENER]
|
||||||
update_listener()
|
update_listener()
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
"""The kodi component."""
|
"""The kodi component."""
|
||||||
|
|
||||||
import asyncio
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from pykodi import CannotConnectError, InvalidAuthError, Kodi, get_kodi_connection
|
from pykodi import CannotConnectError, InvalidAuthError, Kodi, get_kodi_connection
|
||||||
@ -67,24 +66,14 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
|
|||||||
DATA_REMOVE_LISTENER: remove_stop_listener,
|
DATA_REMOVE_LISTENER: remove_stop_listener,
|
||||||
}
|
}
|
||||||
|
|
||||||
for platform in PLATFORMS:
|
hass.config_entries.async_setup_platforms(entry, PLATFORMS)
|
||||||
hass.async_create_task(
|
|
||||||
hass.config_entries.async_forward_entry_setup(entry, platform)
|
|
||||||
)
|
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry):
|
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry):
|
||||||
"""Unload a config entry."""
|
"""Unload a config entry."""
|
||||||
unload_ok = all(
|
unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
|
||||||
await asyncio.gather(
|
|
||||||
*[
|
|
||||||
hass.config_entries.async_forward_entry_unload(entry, platform)
|
|
||||||
for platform in PLATFORMS
|
|
||||||
]
|
|
||||||
)
|
|
||||||
)
|
|
||||||
if unload_ok:
|
if unload_ok:
|
||||||
data = hass.data[DOMAIN].pop(entry.entry_id)
|
data = hass.data[DOMAIN].pop(entry.entry_id)
|
||||||
await data[DATA_CONNECTION].close()
|
await data[DATA_CONNECTION].close()
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
"""Support for Konnected devices."""
|
"""Support for Konnected devices."""
|
||||||
import asyncio
|
|
||||||
import copy
|
import copy
|
||||||
import hmac
|
import hmac
|
||||||
import json
|
import json
|
||||||
@ -261,10 +260,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
|
|||||||
# async_connect will handle retries until it establishes a connection
|
# async_connect will handle retries until it establishes a connection
|
||||||
await client.async_connect()
|
await client.async_connect()
|
||||||
|
|
||||||
for platform in PLATFORMS:
|
hass.config_entries.async_setup_platforms(entry, PLATFORMS)
|
||||||
hass.async_create_task(
|
|
||||||
hass.config_entries.async_forward_entry_setup(entry, platform)
|
|
||||||
)
|
|
||||||
|
|
||||||
# config entry specific data to enable unload
|
# config entry specific data to enable unload
|
||||||
hass.data[DOMAIN][entry.entry_id] = {
|
hass.data[DOMAIN][entry.entry_id] = {
|
||||||
@ -275,14 +271,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
|
|||||||
|
|
||||||
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry):
|
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry):
|
||||||
"""Unload a config entry."""
|
"""Unload a config entry."""
|
||||||
unload_ok = all(
|
unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
|
||||||
await asyncio.gather(
|
|
||||||
*[
|
|
||||||
hass.config_entries.async_forward_entry_unload(entry, platform)
|
|
||||||
for platform in PLATFORMS
|
|
||||||
]
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
hass.data[DOMAIN][entry.entry_id][UNDO_UPDATE_LISTENER]()
|
hass.data[DOMAIN][entry.entry_id][UNDO_UPDATE_LISTENER]()
|
||||||
|
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
"""The Kostal Plenticore Solar Inverter integration."""
|
"""The Kostal Plenticore Solar Inverter integration."""
|
||||||
import asyncio
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from kostal.plenticore import PlenticoreApiException
|
from kostal.plenticore import PlenticoreApiException
|
||||||
@ -15,14 +14,9 @@ _LOGGER = logging.getLogger(__name__)
|
|||||||
PLATFORMS = ["sensor"]
|
PLATFORMS = ["sensor"]
|
||||||
|
|
||||||
|
|
||||||
async def async_setup(hass: HomeAssistant, config: dict) -> bool:
|
|
||||||
"""Set up the Kostal Plenticore Solar Inverter component."""
|
|
||||||
hass.data.setdefault(DOMAIN, {})
|
|
||||||
return True
|
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||||
"""Set up Kostal Plenticore Solar Inverter from a config entry."""
|
"""Set up Kostal Plenticore Solar Inverter from a config entry."""
|
||||||
|
hass.data.setdefault(DOMAIN, {})
|
||||||
|
|
||||||
plenticore = Plenticore(hass, entry)
|
plenticore = Plenticore(hass, entry)
|
||||||
|
|
||||||
@ -31,24 +25,14 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||||||
|
|
||||||
hass.data[DOMAIN][entry.entry_id] = plenticore
|
hass.data[DOMAIN][entry.entry_id] = plenticore
|
||||||
|
|
||||||
for component in PLATFORMS:
|
hass.config_entries.async_setup_platforms(entry, PLATFORMS)
|
||||||
hass.async_create_task(
|
|
||||||
hass.config_entries.async_forward_entry_setup(entry, component)
|
|
||||||
)
|
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||||
"""Unload a config entry."""
|
"""Unload a config entry."""
|
||||||
unload_ok = all(
|
unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
|
||||||
await asyncio.gather(
|
|
||||||
*[
|
|
||||||
hass.config_entries.async_forward_entry_unload(entry, component)
|
|
||||||
for component in PLATFORMS
|
|
||||||
]
|
|
||||||
)
|
|
||||||
)
|
|
||||||
if unload_ok:
|
if unload_ok:
|
||||||
# remove API object
|
# remove API object
|
||||||
plenticore = hass.data[DOMAIN].pop(entry.entry_id)
|
plenticore = hass.data[DOMAIN].pop(entry.entry_id)
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
"""Kuler Sky lights integration."""
|
"""Kuler Sky lights integration."""
|
||||||
import asyncio
|
|
||||||
|
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
@ -16,10 +15,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
|
|||||||
if DATA_ADDRESSES not in hass.data[DOMAIN]:
|
if DATA_ADDRESSES not in hass.data[DOMAIN]:
|
||||||
hass.data[DOMAIN][DATA_ADDRESSES] = set()
|
hass.data[DOMAIN][DATA_ADDRESSES] = set()
|
||||||
|
|
||||||
for platform in PLATFORMS:
|
hass.config_entries.async_setup_platforms(entry, PLATFORMS)
|
||||||
hass.async_create_task(
|
|
||||||
hass.config_entries.async_forward_entry_setup(entry, platform)
|
|
||||||
)
|
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@ -33,11 +29,4 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry):
|
|||||||
|
|
||||||
hass.data.pop(DOMAIN, None)
|
hass.data.pop(DOMAIN, None)
|
||||||
|
|
||||||
return all(
|
return await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
|
||||||
await asyncio.gather(
|
|
||||||
*[
|
|
||||||
hass.config_entries.async_forward_entry_unload(entry, platform)
|
|
||||||
for platform in PLATFORMS
|
|
||||||
]
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
"""Support for LCN devices."""
|
"""Support for LCN devices."""
|
||||||
import asyncio
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
import pypck
|
import pypck
|
||||||
@ -95,10 +94,7 @@ async def async_setup_entry(hass, config_entry):
|
|||||||
entity_registry.async_clear_config_entry(config_entry.entry_id)
|
entity_registry.async_clear_config_entry(config_entry.entry_id)
|
||||||
|
|
||||||
# forward config_entry to components
|
# forward config_entry to components
|
||||||
for component in PLATFORMS:
|
hass.config_entries.async_setup_platforms(config_entry, PLATFORMS)
|
||||||
hass.async_create_task(
|
|
||||||
hass.config_entries.async_forward_entry_setup(config_entry, component)
|
|
||||||
)
|
|
||||||
|
|
||||||
# register service calls
|
# register service calls
|
||||||
for service_name, service in SERVICES:
|
for service_name, service in SERVICES:
|
||||||
@ -113,13 +109,8 @@ async def async_setup_entry(hass, config_entry):
|
|||||||
async def async_unload_entry(hass, config_entry):
|
async def async_unload_entry(hass, config_entry):
|
||||||
"""Close connection to PCHK host represented by config_entry."""
|
"""Close connection to PCHK host represented by config_entry."""
|
||||||
# forward unloading to platforms
|
# forward unloading to platforms
|
||||||
unload_ok = all(
|
unload_ok = await hass.config_entries.async_unload_platforms(
|
||||||
await asyncio.gather(
|
config_entry, PLATFORMS
|
||||||
*[
|
|
||||||
hass.config_entries.async_forward_entry_unload(config_entry, component)
|
|
||||||
for component in PLATFORMS
|
|
||||||
]
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
if unload_ok and config_entry.entry_id in hass.data[DOMAIN]:
|
if unload_ok and config_entry.entry_id in hass.data[DOMAIN]:
|
||||||
|
@ -26,6 +26,8 @@ CONFIG_SCHEMA = vol.Schema(
|
|||||||
|
|
||||||
DATA_LIFX_MANAGER = "lifx_manager"
|
DATA_LIFX_MANAGER = "lifx_manager"
|
||||||
|
|
||||||
|
PLATFORMS = [LIGHT_DOMAIN]
|
||||||
|
|
||||||
|
|
||||||
async def async_setup(hass, config):
|
async def async_setup(hass, config):
|
||||||
"""Set up the LIFX component."""
|
"""Set up the LIFX component."""
|
||||||
@ -45,17 +47,11 @@ async def async_setup(hass, config):
|
|||||||
|
|
||||||
async def async_setup_entry(hass, entry):
|
async def async_setup_entry(hass, entry):
|
||||||
"""Set up LIFX from a config entry."""
|
"""Set up LIFX from a config entry."""
|
||||||
hass.async_create_task(
|
hass.config_entries.async_setup_platforms(entry, PLATFORMS)
|
||||||
hass.config_entries.async_forward_entry_setup(entry, LIGHT_DOMAIN)
|
|
||||||
)
|
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
async def async_unload_entry(hass, entry):
|
async def async_unload_entry(hass, entry):
|
||||||
"""Unload a config entry."""
|
"""Unload a config entry."""
|
||||||
hass.data.pop(DATA_LIFX_MANAGER).cleanup()
|
hass.data.pop(DATA_LIFX_MANAGER).cleanup()
|
||||||
|
return await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
|
||||||
await hass.config_entries.async_forward_entry_unload(entry, LIGHT_DOMAIN)
|
|
||||||
|
|
||||||
return True
|
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
"""Support for the LiteJet lighting system."""
|
"""Support for the LiteJet lighting system."""
|
||||||
import asyncio
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
import pylitejet
|
import pylitejet
|
||||||
@ -59,25 +58,14 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||||||
|
|
||||||
hass.data[DOMAIN] = system
|
hass.data[DOMAIN] = system
|
||||||
|
|
||||||
for platform in PLATFORMS:
|
hass.config_entries.async_setup_platforms(entry, PLATFORMS)
|
||||||
hass.async_create_task(
|
|
||||||
hass.config_entries.async_forward_entry_setup(entry, platform)
|
|
||||||
)
|
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry):
|
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry):
|
||||||
"""Unload a LiteJet config entry."""
|
"""Unload a LiteJet config entry."""
|
||||||
|
unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
|
||||||
unload_ok = all(
|
|
||||||
await asyncio.gather(
|
|
||||||
*[
|
|
||||||
hass.config_entries.async_forward_entry_unload(entry, platform)
|
|
||||||
for platform in PLATFORMS
|
|
||||||
]
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
if unload_ok:
|
if unload_ok:
|
||||||
hass.data[DOMAIN].close()
|
hass.data[DOMAIN].close()
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
"""The Litter-Robot integration."""
|
"""The Litter-Robot integration."""
|
||||||
import asyncio
|
|
||||||
|
|
||||||
from pylitterbot.exceptions import LitterRobotException, LitterRobotLoginException
|
from pylitterbot.exceptions import LitterRobotException, LitterRobotLoginException
|
||||||
|
|
||||||
@ -25,24 +24,14 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
|
|||||||
raise ConfigEntryNotReady from ex
|
raise ConfigEntryNotReady from ex
|
||||||
|
|
||||||
if hub.account.robots:
|
if hub.account.robots:
|
||||||
for platform in PLATFORMS:
|
hass.config_entries.async_setup_platforms(entry, PLATFORMS)
|
||||||
hass.async_create_task(
|
|
||||||
hass.config_entries.async_forward_entry_setup(entry, platform)
|
|
||||||
)
|
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry):
|
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry):
|
||||||
"""Unload a config entry."""
|
"""Unload a config entry."""
|
||||||
unload_ok = all(
|
unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
|
||||||
await asyncio.gather(
|
|
||||||
*[
|
|
||||||
hass.config_entries.async_forward_entry_unload(entry, platform)
|
|
||||||
for platform in PLATFORMS
|
|
||||||
]
|
|
||||||
)
|
|
||||||
)
|
|
||||||
if unload_ok:
|
if unload_ok:
|
||||||
hass.data[DOMAIN].pop(entry.entry_id)
|
hass.data[DOMAIN].pop(entry.entry_id)
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ from homeassistant.const import CONF_NAME
|
|||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
|
|
||||||
from .const import DOMAIN, PLATFORM
|
from .const import DOMAIN, PLATFORMS
|
||||||
|
|
||||||
CONFIG_SCHEMA = vol.Schema(
|
CONFIG_SCHEMA = vol.Schema(
|
||||||
{
|
{
|
||||||
@ -34,13 +34,10 @@ async def async_setup(hass: HomeAssistant, config: dict):
|
|||||||
|
|
||||||
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
|
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
|
||||||
"""Set up local_ip from a config entry."""
|
"""Set up local_ip from a config entry."""
|
||||||
hass.async_create_task(
|
hass.config_entries.async_setup_platforms(entry, PLATFORMS)
|
||||||
hass.config_entries.async_forward_entry_setup(entry, PLATFORM)
|
|
||||||
)
|
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry):
|
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry):
|
||||||
"""Unload a config entry."""
|
"""Unload a config entry."""
|
||||||
return await hass.config_entries.async_forward_entry_unload(entry, PLATFORM)
|
return await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
"""Local IP constants."""
|
"""Local IP constants."""
|
||||||
|
|
||||||
DOMAIN = "local_ip"
|
DOMAIN = "local_ip"
|
||||||
PLATFORM = "sensor"
|
PLATFORMS = ["sensor"]
|
||||||
|
|
||||||
SENSOR = "address"
|
SENSOR = "address"
|
||||||
|
@ -25,6 +25,7 @@ _LOGGER = logging.getLogger(__name__)
|
|||||||
DOMAIN = "locative"
|
DOMAIN = "locative"
|
||||||
TRACKER_UPDATE = f"{DOMAIN}_tracker_update"
|
TRACKER_UPDATE = f"{DOMAIN}_tracker_update"
|
||||||
|
|
||||||
|
PLATFORMS = [DEVICE_TRACKER]
|
||||||
|
|
||||||
ATTR_DEVICE_ID = "device"
|
ATTR_DEVICE_ID = "device"
|
||||||
ATTR_TRIGGER = "trigger"
|
ATTR_TRIGGER = "trigger"
|
||||||
@ -116,9 +117,7 @@ async def async_setup_entry(hass, entry):
|
|||||||
DOMAIN, "Locative", entry.data[CONF_WEBHOOK_ID], handle_webhook
|
DOMAIN, "Locative", entry.data[CONF_WEBHOOK_ID], handle_webhook
|
||||||
)
|
)
|
||||||
|
|
||||||
hass.async_create_task(
|
hass.config_entries.async_setup_platforms(entry, PLATFORMS)
|
||||||
hass.config_entries.async_forward_entry_setup(entry, DEVICE_TRACKER)
|
|
||||||
)
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
@ -126,7 +125,7 @@ async def async_unload_entry(hass, entry):
|
|||||||
"""Unload a config entry."""
|
"""Unload a config entry."""
|
||||||
hass.components.webhook.async_unregister(entry.data[CONF_WEBHOOK_ID])
|
hass.components.webhook.async_unregister(entry.data[CONF_WEBHOOK_ID])
|
||||||
hass.data[DOMAIN]["unsub_device_tracker"].pop(entry.entry_id)()
|
hass.data[DOMAIN]["unsub_device_tracker"].pop(entry.entry_id)()
|
||||||
return await hass.config_entries.async_forward_entry_unload(entry, DEVICE_TRACKER)
|
return await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
|
||||||
|
|
||||||
|
|
||||||
async_remove_entry = config_entry_flow.webhook_async_remove_entry
|
async_remove_entry = config_entry_flow.webhook_async_remove_entry
|
||||||
|
@ -179,10 +179,7 @@ async def async_setup_entry(hass, entry):
|
|||||||
|
|
||||||
hass.data[DATA_LOGI] = logi_circle
|
hass.data[DATA_LOGI] = logi_circle
|
||||||
|
|
||||||
for platform in PLATFORMS:
|
hass.config_entries.async_setup_platforms(entry, PLATFORMS)
|
||||||
hass.async_create_task(
|
|
||||||
hass.config_entries.async_forward_entry_setup(entry, platform)
|
|
||||||
)
|
|
||||||
|
|
||||||
async def service_handler(service):
|
async def service_handler(service):
|
||||||
"""Dispatch service calls to target entities."""
|
"""Dispatch service calls to target entities."""
|
||||||
@ -229,8 +226,7 @@ async def async_setup_entry(hass, entry):
|
|||||||
|
|
||||||
async def async_unload_entry(hass, entry):
|
async def async_unload_entry(hass, entry):
|
||||||
"""Unload a config entry."""
|
"""Unload a config entry."""
|
||||||
for platform in PLATFORMS:
|
unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
|
||||||
await hass.config_entries.async_forward_entry_unload(entry, platform)
|
|
||||||
|
|
||||||
logi_circle = hass.data.pop(DATA_LOGI)
|
logi_circle = hass.data.pop(DATA_LOGI)
|
||||||
|
|
||||||
@ -238,4 +234,4 @@ async def async_unload_entry(hass, entry):
|
|||||||
# and clear all locally cached tokens
|
# and clear all locally cached tokens
|
||||||
await logi_circle.auth_provider.clear_authorization()
|
await logi_circle.auth_provider.clear_authorization()
|
||||||
|
|
||||||
return True
|
return unload_ok
|
||||||
|
@ -33,6 +33,8 @@ DATA_LUFTDATEN_CLIENT = "data_luftdaten_client"
|
|||||||
DATA_LUFTDATEN_LISTENER = "data_luftdaten_listener"
|
DATA_LUFTDATEN_LISTENER = "data_luftdaten_listener"
|
||||||
DEFAULT_ATTRIBUTION = "Data provided by luftdaten.info"
|
DEFAULT_ATTRIBUTION = "Data provided by luftdaten.info"
|
||||||
|
|
||||||
|
PLATFORMS = ["sensor"]
|
||||||
|
|
||||||
SENSOR_HUMIDITY = "humidity"
|
SENSOR_HUMIDITY = "humidity"
|
||||||
SENSOR_PM10 = "P1"
|
SENSOR_PM10 = "P1"
|
||||||
SENSOR_PM2_5 = "P2"
|
SENSOR_PM2_5 = "P2"
|
||||||
@ -152,9 +154,7 @@ async def async_setup_entry(hass, config_entry):
|
|||||||
except LuftdatenError as err:
|
except LuftdatenError as err:
|
||||||
raise ConfigEntryNotReady from err
|
raise ConfigEntryNotReady from err
|
||||||
|
|
||||||
hass.async_create_task(
|
hass.config_entries.async_setup_platforms(config_entry, PLATFORMS)
|
||||||
hass.config_entries.async_forward_entry_setup(config_entry, "sensor")
|
|
||||||
)
|
|
||||||
|
|
||||||
async def refresh_sensors(event_time):
|
async def refresh_sensors(event_time):
|
||||||
"""Refresh Luftdaten data."""
|
"""Refresh Luftdaten data."""
|
||||||
@ -181,7 +181,7 @@ async def async_unload_entry(hass, config_entry):
|
|||||||
|
|
||||||
hass.data[DOMAIN][DATA_LUFTDATEN_CLIENT].pop(config_entry.entry_id)
|
hass.data[DOMAIN][DATA_LUFTDATEN_CLIENT].pop(config_entry.entry_id)
|
||||||
|
|
||||||
return await hass.config_entries.async_forward_entry_unload(config_entry, "sensor")
|
return await hass.config_entries.async_unload_platforms(config_entry, PLATFORMS)
|
||||||
|
|
||||||
|
|
||||||
class LuftDatenData:
|
class LuftDatenData:
|
||||||
|
@ -137,10 +137,7 @@ async def async_setup_entry(hass, config_entry):
|
|||||||
# pico remotes to control other devices.
|
# pico remotes to control other devices.
|
||||||
await async_setup_lip(hass, config_entry, bridge.lip_devices)
|
await async_setup_lip(hass, config_entry, bridge.lip_devices)
|
||||||
|
|
||||||
for platform in PLATFORMS:
|
hass.config_entries.async_setup_platforms(config_entry, PLATFORMS)
|
||||||
hass.async_create_task(
|
|
||||||
hass.config_entries.async_forward_entry_setup(config_entry, platform)
|
|
||||||
)
|
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@ -283,15 +280,9 @@ async def async_unload_entry(hass, config_entry):
|
|||||||
if data[BRIDGE_LIP]:
|
if data[BRIDGE_LIP]:
|
||||||
await data[BRIDGE_LIP].async_stop()
|
await data[BRIDGE_LIP].async_stop()
|
||||||
|
|
||||||
unload_ok = all(
|
unload_ok = await hass.config_entries.async_unload_platforms(
|
||||||
await asyncio.gather(
|
config_entry, PLATFORMS
|
||||||
*[
|
|
||||||
hass.config_entries.async_forward_entry_unload(config_entry, platform)
|
|
||||||
for platform in PLATFORMS
|
|
||||||
]
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
if unload_ok:
|
if unload_ok:
|
||||||
hass.data[DOMAIN].pop(config_entry.entry_id)
|
hass.data[DOMAIN].pop(config_entry.entry_id)
|
||||||
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
"""The Honeywell Lyric integration."""
|
"""The Honeywell Lyric integration."""
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import asyncio
|
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
import logging
|
import logging
|
||||||
from typing import Any
|
from typing import Any
|
||||||
@ -117,24 +116,14 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||||||
# Fetch initial data so we have data when entities subscribe
|
# Fetch initial data so we have data when entities subscribe
|
||||||
await coordinator.async_config_entry_first_refresh()
|
await coordinator.async_config_entry_first_refresh()
|
||||||
|
|
||||||
for platform in PLATFORMS:
|
hass.config_entries.async_setup_platforms(entry, PLATFORMS)
|
||||||
hass.async_create_task(
|
|
||||||
hass.config_entries.async_forward_entry_setup(entry, platform)
|
|
||||||
)
|
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry):
|
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry):
|
||||||
"""Unload a config entry."""
|
"""Unload a config entry."""
|
||||||
unload_ok = all(
|
unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
|
||||||
await asyncio.gather(
|
|
||||||
*[
|
|
||||||
hass.config_entries.async_forward_entry_unload(entry, platform)
|
|
||||||
for platform in PLATFORMS
|
|
||||||
]
|
|
||||||
)
|
|
||||||
)
|
|
||||||
if unload_ok:
|
if unload_ok:
|
||||||
hass.data[DOMAIN].pop(entry.entry_id)
|
hass.data[DOMAIN].pop(entry.entry_id)
|
||||||
|
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
"""The Mazda Connected Services integration."""
|
"""The Mazda Connected Services integration."""
|
||||||
import asyncio
|
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
@ -101,24 +100,14 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
|
|||||||
await coordinator.async_config_entry_first_refresh()
|
await coordinator.async_config_entry_first_refresh()
|
||||||
|
|
||||||
# Setup components
|
# Setup components
|
||||||
for platform in PLATFORMS:
|
hass.config_entries.async_setup_platforms(entry, PLATFORMS)
|
||||||
hass.async_create_task(
|
|
||||||
hass.config_entries.async_forward_entry_setup(entry, platform)
|
|
||||||
)
|
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry):
|
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry):
|
||||||
"""Unload a config entry."""
|
"""Unload a config entry."""
|
||||||
unload_ok = all(
|
unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
|
||||||
await asyncio.gather(
|
|
||||||
*[
|
|
||||||
hass.config_entries.async_forward_entry_unload(entry, platform)
|
|
||||||
for platform in PLATFORMS
|
|
||||||
]
|
|
||||||
)
|
|
||||||
)
|
|
||||||
if unload_ok:
|
if unload_ok:
|
||||||
hass.data[DOMAIN].pop(entry.entry_id)
|
hass.data[DOMAIN].pop(entry.entry_id)
|
||||||
|
|
||||||
|
@ -63,25 +63,19 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
|
|||||||
conf = entry.data
|
conf = entry.data
|
||||||
mel_devices = await mel_devices_setup(hass, conf[CONF_TOKEN])
|
mel_devices = await mel_devices_setup(hass, conf[CONF_TOKEN])
|
||||||
hass.data.setdefault(DOMAIN, {}).update({entry.entry_id: mel_devices})
|
hass.data.setdefault(DOMAIN, {}).update({entry.entry_id: mel_devices})
|
||||||
for platform in PLATFORMS:
|
hass.config_entries.async_setup_platforms(entry, PLATFORMS)
|
||||||
hass.async_create_task(
|
|
||||||
hass.config_entries.async_forward_entry_setup(entry, platform)
|
|
||||||
)
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
async def async_unload_entry(hass, config_entry):
|
async def async_unload_entry(hass, config_entry):
|
||||||
"""Unload a config entry."""
|
"""Unload a config entry."""
|
||||||
await asyncio.gather(
|
unload_ok = await hass.config_entries.async_unload_platforms(
|
||||||
*[
|
config_entry, PLATFORMS
|
||||||
hass.config_entries.async_forward_entry_unload(config_entry, platform)
|
|
||||||
for platform in PLATFORMS
|
|
||||||
]
|
|
||||||
)
|
)
|
||||||
hass.data[DOMAIN].pop(config_entry.entry_id)
|
hass.data[DOMAIN].pop(config_entry.entry_id)
|
||||||
if not hass.data[DOMAIN]:
|
if not hass.data[DOMAIN]:
|
||||||
hass.data.pop(DOMAIN)
|
hass.data.pop(DOMAIN)
|
||||||
return True
|
return unload_ok
|
||||||
|
|
||||||
|
|
||||||
class MelCloudDevice:
|
class MelCloudDevice:
|
||||||
|
@ -27,6 +27,7 @@ from .const import (
|
|||||||
|
|
||||||
URL = "https://aa015h6buqvih86i1.api.met.no/weatherapi/locationforecast/2.0/complete"
|
URL = "https://aa015h6buqvih86i1.api.met.no/weatherapi/locationforecast/2.0/complete"
|
||||||
|
|
||||||
|
PLATFORMS = ["weather"]
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -56,20 +57,21 @@ async def async_setup_entry(hass, config_entry):
|
|||||||
hass.data.setdefault(DOMAIN, {})
|
hass.data.setdefault(DOMAIN, {})
|
||||||
hass.data[DOMAIN][config_entry.entry_id] = coordinator
|
hass.data[DOMAIN][config_entry.entry_id] = coordinator
|
||||||
|
|
||||||
hass.async_create_task(
|
hass.config_entries.async_setup_platforms(config_entry, PLATFORMS)
|
||||||
hass.config_entries.async_forward_entry_setup(config_entry, "weather")
|
|
||||||
)
|
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
async def async_unload_entry(hass, config_entry):
|
async def async_unload_entry(hass, config_entry):
|
||||||
"""Unload a config entry."""
|
"""Unload a config entry."""
|
||||||
await hass.config_entries.async_forward_entry_unload(config_entry, "weather")
|
unload_ok = await hass.config_entries.async_unload_platforms(
|
||||||
|
config_entry, PLATFORMS
|
||||||
|
)
|
||||||
|
|
||||||
hass.data[DOMAIN][config_entry.entry_id].untrack_home()
|
hass.data[DOMAIN][config_entry.entry_id].untrack_home()
|
||||||
hass.data[DOMAIN].pop(config_entry.entry_id)
|
hass.data[DOMAIN].pop(config_entry.entry_id)
|
||||||
|
|
||||||
return True
|
return unload_ok
|
||||||
|
|
||||||
|
|
||||||
class MetDataUpdateCoordinator(DataUpdateCoordinator):
|
class MetDataUpdateCoordinator(DataUpdateCoordinator):
|
||||||
|
@ -15,6 +15,8 @@ _LOGGER = logging.getLogger(__name__)
|
|||||||
|
|
||||||
UPDATE_INTERVAL = timedelta(minutes=60)
|
UPDATE_INTERVAL = timedelta(minutes=60)
|
||||||
|
|
||||||
|
PLATFORMS = ["weather"]
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(hass, config_entry):
|
async def async_setup_entry(hass, config_entry):
|
||||||
"""Set up Met Éireann as config entry."""
|
"""Set up Met Éireann as config entry."""
|
||||||
@ -47,19 +49,19 @@ async def async_setup_entry(hass, config_entry):
|
|||||||
|
|
||||||
hass.data[DOMAIN][config_entry.entry_id] = coordinator
|
hass.data[DOMAIN][config_entry.entry_id] = coordinator
|
||||||
|
|
||||||
hass.async_create_task(
|
hass.config_entries.async_setup_platforms(config_entry, PLATFORMS)
|
||||||
hass.config_entries.async_forward_entry_setup(config_entry, "weather")
|
|
||||||
)
|
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
async def async_unload_entry(hass, config_entry):
|
async def async_unload_entry(hass, config_entry):
|
||||||
"""Unload a config entry."""
|
"""Unload a config entry."""
|
||||||
await hass.config_entries.async_forward_entry_unload(config_entry, "weather")
|
unload_ok = await hass.config_entries.async_unload_platforms(
|
||||||
|
config_entry, PLATFORMS
|
||||||
|
)
|
||||||
hass.data[DOMAIN].pop(config_entry.entry_id)
|
hass.data[DOMAIN].pop(config_entry.entry_id)
|
||||||
|
|
||||||
return True
|
return unload_ok
|
||||||
|
|
||||||
|
|
||||||
class MetEireannWeatherData:
|
class MetEireannWeatherData:
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
"""Support for Meteo-France weather data."""
|
"""Support for Meteo-France weather data."""
|
||||||
import asyncio
|
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
@ -173,10 +172,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||||||
UNDO_UPDATE_LISTENER: undo_listener,
|
UNDO_UPDATE_LISTENER: undo_listener,
|
||||||
}
|
}
|
||||||
|
|
||||||
for platform in PLATFORMS:
|
hass.config_entries.async_setup_platforms(entry, PLATFORMS)
|
||||||
hass.async_create_task(
|
|
||||||
hass.config_entries.async_forward_entry_setup(entry, platform)
|
|
||||||
)
|
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@ -194,14 +190,7 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry):
|
|||||||
department,
|
department,
|
||||||
)
|
)
|
||||||
|
|
||||||
unload_ok = all(
|
unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
|
||||||
await asyncio.gather(
|
|
||||||
*[
|
|
||||||
hass.config_entries.async_forward_entry_unload(entry, platform)
|
|
||||||
for platform in PLATFORMS
|
|
||||||
]
|
|
||||||
)
|
|
||||||
)
|
|
||||||
if unload_ok:
|
if unload_ok:
|
||||||
hass.data[DOMAIN][entry.entry_id][UNDO_UPDATE_LISTENER]()
|
hass.data[DOMAIN][entry.entry_id][UNDO_UPDATE_LISTENER]()
|
||||||
hass.data[DOMAIN].pop(entry.entry_id)
|
hass.data[DOMAIN].pop(entry.entry_id)
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
"""The Met Office integration."""
|
"""The Met Office integration."""
|
||||||
|
|
||||||
import asyncio
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
@ -56,24 +55,14 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
|
|||||||
if metoffice_data.now is None:
|
if metoffice_data.now is None:
|
||||||
raise ConfigEntryNotReady()
|
raise ConfigEntryNotReady()
|
||||||
|
|
||||||
for platform in PLATFORMS:
|
hass.config_entries.async_setup_platforms(entry, PLATFORMS)
|
||||||
hass.async_create_task(
|
|
||||||
hass.config_entries.async_forward_entry_setup(entry, platform)
|
|
||||||
)
|
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry):
|
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry):
|
||||||
"""Unload a config entry."""
|
"""Unload a config entry."""
|
||||||
unload_ok = all(
|
unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
|
||||||
await asyncio.gather(
|
|
||||||
*[
|
|
||||||
hass.config_entries.async_forward_entry_unload(entry, platform)
|
|
||||||
for platform in PLATFORMS
|
|
||||||
]
|
|
||||||
)
|
|
||||||
)
|
|
||||||
if unload_ok:
|
if unload_ok:
|
||||||
hass.data[DOMAIN].pop(entry.entry_id)
|
hass.data[DOMAIN].pop(entry.entry_id)
|
||||||
if not hass.data[DOMAIN]:
|
if not hass.data[DOMAIN]:
|
||||||
|
@ -21,6 +21,7 @@ from .const import (
|
|||||||
DEFAULT_DETECTION_TIME,
|
DEFAULT_DETECTION_TIME,
|
||||||
DEFAULT_NAME,
|
DEFAULT_NAME,
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
|
PLATFORMS,
|
||||||
)
|
)
|
||||||
from .hub import MikrotikHub
|
from .hub import MikrotikHub
|
||||||
|
|
||||||
@ -42,6 +43,7 @@ MIKROTIK_SCHEMA = vol.All(
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
CONFIG_SCHEMA = vol.Schema(
|
CONFIG_SCHEMA = vol.Schema(
|
||||||
{DOMAIN: vol.All(cv.ensure_list, [MIKROTIK_SCHEMA])}, extra=vol.ALLOW_EXTRA
|
{DOMAIN: vol.All(cv.ensure_list, [MIKROTIK_SCHEMA])}, extra=vol.ALLOW_EXTRA
|
||||||
)
|
)
|
||||||
@ -84,8 +86,10 @@ async def async_setup_entry(hass, config_entry):
|
|||||||
|
|
||||||
async def async_unload_entry(hass, config_entry):
|
async def async_unload_entry(hass, config_entry):
|
||||||
"""Unload a config entry."""
|
"""Unload a config entry."""
|
||||||
await hass.config_entries.async_forward_entry_unload(config_entry, "device_tracker")
|
unload_ok = await hass.config_entries.async_unload_platforms(
|
||||||
|
config_entry, PLATFORMS
|
||||||
|
)
|
||||||
|
|
||||||
hass.data[DOMAIN].pop(config_entry.entry_id)
|
hass.data[DOMAIN].pop(config_entry.entry_id)
|
||||||
|
|
||||||
return True
|
return unload_ok
|
||||||
|
@ -37,6 +37,8 @@ MIKROTIK_SERVICES = {
|
|||||||
IS_CAPSMAN: "/caps-man/interface/print",
|
IS_CAPSMAN: "/caps-man/interface/print",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PLATFORMS = ["device_tracker"]
|
||||||
|
|
||||||
ATTR_DEVICE_TRACKER = [
|
ATTR_DEVICE_TRACKER = [
|
||||||
"comment",
|
"comment",
|
||||||
"mac-address",
|
"mac-address",
|
||||||
|
@ -31,6 +31,7 @@ from .const import (
|
|||||||
IS_WIRELESS,
|
IS_WIRELESS,
|
||||||
MIKROTIK_SERVICES,
|
MIKROTIK_SERVICES,
|
||||||
NAME,
|
NAME,
|
||||||
|
PLATFORMS,
|
||||||
WIRELESS,
|
WIRELESS,
|
||||||
)
|
)
|
||||||
from .errors import CannotConnect, LoginError
|
from .errors import CannotConnect, LoginError
|
||||||
@ -385,11 +386,7 @@ class MikrotikHub:
|
|||||||
await self.hass.async_add_executor_job(self._mk_data.get_hub_details)
|
await self.hass.async_add_executor_job(self._mk_data.get_hub_details)
|
||||||
await self.hass.async_add_executor_job(self._mk_data.update)
|
await self.hass.async_add_executor_job(self._mk_data.update)
|
||||||
|
|
||||||
self.hass.async_create_task(
|
self.hass.config_entries.async_setup_platforms(self.config_entry, PLATFORMS)
|
||||||
self.hass.config_entries.async_forward_entry_setup(
|
|
||||||
self.config_entry, "device_tracker"
|
|
||||||
)
|
|
||||||
)
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,17 +1,14 @@
|
|||||||
"""The mill component."""
|
"""The mill component."""
|
||||||
|
|
||||||
|
PLATFORMS = ["climate"]
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(hass, entry):
|
async def async_setup_entry(hass, entry):
|
||||||
"""Set up the Mill heater."""
|
"""Set up the Mill heater."""
|
||||||
hass.async_create_task(
|
hass.config_entries.async_setup_platforms(entry, PLATFORMS)
|
||||||
hass.config_entries.async_forward_entry_setup(entry, "climate")
|
|
||||||
)
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
async def async_unload_entry(hass, config_entry):
|
async def async_unload_entry(hass, entry):
|
||||||
"""Unload a config entry."""
|
"""Unload a config entry."""
|
||||||
unload_ok = await hass.config_entries.async_forward_entry_unload(
|
return await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
|
||||||
config_entry, "climate"
|
|
||||||
)
|
|
||||||
return unload_ok
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
"""The Minecraft Server integration."""
|
"""The Minecraft Server integration."""
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import asyncio
|
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
import logging
|
import logging
|
||||||
from typing import Any
|
from typing import Any
|
||||||
@ -44,10 +43,7 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> b
|
|||||||
server.start_periodic_update()
|
server.start_periodic_update()
|
||||||
|
|
||||||
# Set up platforms.
|
# Set up platforms.
|
||||||
for platform in PLATFORMS:
|
hass.config_entries.async_setup_platforms(config_entry, PLATFORMS)
|
||||||
hass.async_create_task(
|
|
||||||
hass.config_entries.async_forward_entry_setup(config_entry, platform)
|
|
||||||
)
|
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@ -58,18 +54,15 @@ async def async_unload_entry(hass: HomeAssistant, config_entry: ConfigEntry) ->
|
|||||||
server = hass.data[DOMAIN][unique_id]
|
server = hass.data[DOMAIN][unique_id]
|
||||||
|
|
||||||
# Unload platforms.
|
# Unload platforms.
|
||||||
await asyncio.gather(
|
unload_ok = await hass.config_entries.async_unload_platforms(
|
||||||
*[
|
config_entry, PLATFORMS
|
||||||
hass.config_entries.async_forward_entry_unload(config_entry, platform)
|
|
||||||
for platform in PLATFORMS
|
|
||||||
]
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# Clean up.
|
# Clean up.
|
||||||
server.stop_periodic_update()
|
server.stop_periodic_update()
|
||||||
hass.data[DOMAIN].pop(unique_id)
|
hass.data[DOMAIN].pop(unique_id)
|
||||||
|
|
||||||
return True
|
return unload_ok
|
||||||
|
|
||||||
|
|
||||||
class MinecraftServer:
|
class MinecraftServer:
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
"""Integrates Native Apps to Home Assistant."""
|
"""Integrates Native Apps to Home Assistant."""
|
||||||
import asyncio
|
|
||||||
from contextlib import suppress
|
from contextlib import suppress
|
||||||
|
|
||||||
from homeassistant.components import cloud, notify as hass_notify
|
from homeassistant.components import cloud, notify as hass_notify
|
||||||
@ -89,10 +88,7 @@ async def async_setup_entry(hass, entry):
|
|||||||
registration_name = f"Mobile App: {registration[ATTR_DEVICE_NAME]}"
|
registration_name = f"Mobile App: {registration[ATTR_DEVICE_NAME]}"
|
||||||
webhook_register(hass, DOMAIN, registration_name, webhook_id, handle_webhook)
|
webhook_register(hass, DOMAIN, registration_name, webhook_id, handle_webhook)
|
||||||
|
|
||||||
for domain in PLATFORMS:
|
hass.config_entries.async_setup_platforms(entry, PLATFORMS)
|
||||||
hass.async_create_task(
|
|
||||||
hass.config_entries.async_forward_entry_setup(entry, domain)
|
|
||||||
)
|
|
||||||
|
|
||||||
await hass_notify.async_reload(hass, DOMAIN)
|
await hass_notify.async_reload(hass, DOMAIN)
|
||||||
|
|
||||||
@ -101,14 +97,7 @@ async def async_setup_entry(hass, entry):
|
|||||||
|
|
||||||
async def async_unload_entry(hass, entry):
|
async def async_unload_entry(hass, entry):
|
||||||
"""Unload a mobile app entry."""
|
"""Unload a mobile app entry."""
|
||||||
unload_ok = all(
|
unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
|
||||||
await asyncio.gather(
|
|
||||||
*[
|
|
||||||
hass.config_entries.async_forward_entry_unload(entry, platform)
|
|
||||||
for platform in PLATFORMS
|
|
||||||
]
|
|
||||||
)
|
|
||||||
)
|
|
||||||
if not unload_ok:
|
if not unload_ok:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
"""The Monoprice 6-Zone Amplifier integration."""
|
"""The Monoprice 6-Zone Amplifier integration."""
|
||||||
import asyncio
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from pymonoprice import get_monoprice
|
from pymonoprice import get_monoprice
|
||||||
@ -49,25 +48,14 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
|
|||||||
FIRST_RUN: first_run,
|
FIRST_RUN: first_run,
|
||||||
}
|
}
|
||||||
|
|
||||||
for platform in PLATFORMS:
|
hass.config_entries.async_setup_platforms(entry, PLATFORMS)
|
||||||
hass.async_create_task(
|
|
||||||
hass.config_entries.async_forward_entry_setup(entry, platform)
|
|
||||||
)
|
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry):
|
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry):
|
||||||
"""Unload a config entry."""
|
"""Unload a config entry."""
|
||||||
unload_ok = all(
|
unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
|
||||||
await asyncio.gather(
|
|
||||||
*[
|
|
||||||
hass.config_entries.async_forward_entry_unload(entry, platform)
|
|
||||||
for platform in PLATFORMS
|
|
||||||
]
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
if unload_ok:
|
if unload_ok:
|
||||||
hass.data[DOMAIN][entry.entry_id][UNDO_UPDATE_LISTENER]()
|
hass.data[DOMAIN][entry.entry_id][UNDO_UPDATE_LISTENER]()
|
||||||
hass.data[DOMAIN].pop(entry.entry_id)
|
hass.data[DOMAIN].pop(entry.entry_id)
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
"""The motion_blinds component."""
|
"""The motion_blinds component."""
|
||||||
import asyncio
|
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
import logging
|
import logging
|
||||||
from socket import timeout
|
from socket import timeout
|
||||||
@ -159,10 +158,7 @@ async def async_setup_entry(
|
|||||||
sw_version=motion_gateway.protocol,
|
sw_version=motion_gateway.protocol,
|
||||||
)
|
)
|
||||||
|
|
||||||
for platform in PLATFORMS:
|
hass.config_entries.async_setup_platforms(entry, PLATFORMS)
|
||||||
hass.async_create_task(
|
|
||||||
hass.config_entries.async_forward_entry_setup(entry, platform)
|
|
||||||
)
|
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@ -171,13 +167,8 @@ async def async_unload_entry(
|
|||||||
hass: core.HomeAssistant, config_entry: config_entries.ConfigEntry
|
hass: core.HomeAssistant, config_entry: config_entries.ConfigEntry
|
||||||
):
|
):
|
||||||
"""Unload a config entry."""
|
"""Unload a config entry."""
|
||||||
unload_ok = all(
|
unload_ok = await hass.config_entries.async_unload_platforms(
|
||||||
await asyncio.gather(
|
config_entry, PLATFORMS
|
||||||
*[
|
|
||||||
hass.config_entries.async_forward_entry_unload(config_entry, platform)
|
|
||||||
for platform in PLATFORMS
|
|
||||||
]
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
if unload_ok:
|
if unload_ok:
|
||||||
|
@ -225,14 +225,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||||||
|
|
||||||
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||||
"""Unload a config entry."""
|
"""Unload a config entry."""
|
||||||
unload_ok = all(
|
unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
|
||||||
await asyncio.gather(
|
|
||||||
*[
|
|
||||||
hass.config_entries.async_forward_entry_unload(entry, platform)
|
|
||||||
for platform in PLATFORMS
|
|
||||||
]
|
|
||||||
)
|
|
||||||
)
|
|
||||||
if unload_ok:
|
if unload_ok:
|
||||||
config_data = hass.data[DOMAIN].pop(entry.entry_id)
|
config_data = hass.data[DOMAIN].pop(entry.entry_id)
|
||||||
await config_data[CONF_CLIENT].async_client_close()
|
await config_data[CONF_CLIENT].async_client_close()
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
"""The Mullvad VPN integration."""
|
"""The Mullvad VPN integration."""
|
||||||
import asyncio
|
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
@ -34,25 +33,14 @@ async def async_setup_entry(hass: HomeAssistant, entry: dict):
|
|||||||
|
|
||||||
hass.data[DOMAIN] = coordinator
|
hass.data[DOMAIN] = coordinator
|
||||||
|
|
||||||
for platform in PLATFORMS:
|
hass.config_entries.async_setup_platforms(entry, PLATFORMS)
|
||||||
hass.async_create_task(
|
|
||||||
hass.config_entries.async_forward_entry_setup(entry, platform)
|
|
||||||
)
|
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry):
|
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry):
|
||||||
"""Unload a config entry."""
|
"""Unload a config entry."""
|
||||||
unload_ok = all(
|
unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
|
||||||
await asyncio.gather(
|
|
||||||
*[
|
|
||||||
hass.config_entries.async_forward_entry_unload(entry, platform)
|
|
||||||
for platform in PLATFORMS
|
|
||||||
]
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
if unload_ok:
|
if unload_ok:
|
||||||
del hass.data[DOMAIN]
|
del hass.data[DOMAIN]
|
||||||
|
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
"""The MyQ integration."""
|
"""The MyQ integration."""
|
||||||
import asyncio
|
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
@ -18,17 +17,10 @@ from .const import DOMAIN, MYQ_COORDINATOR, MYQ_GATEWAY, PLATFORMS, UPDATE_INTER
|
|||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
async def async_setup(hass: HomeAssistant, config: dict):
|
|
||||||
"""Set up the MyQ component."""
|
|
||||||
|
|
||||||
hass.data.setdefault(DOMAIN, {})
|
|
||||||
|
|
||||||
return True
|
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
|
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
|
||||||
"""Set up MyQ from a config entry."""
|
"""Set up MyQ from a config entry."""
|
||||||
|
|
||||||
|
hass.data.setdefault(DOMAIN, {})
|
||||||
websession = aiohttp_client.async_get_clientsession(hass)
|
websession = aiohttp_client.async_get_clientsession(hass)
|
||||||
conf = entry.data
|
conf = entry.data
|
||||||
|
|
||||||
@ -58,24 +50,14 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
|
|||||||
|
|
||||||
hass.data[DOMAIN][entry.entry_id] = {MYQ_GATEWAY: myq, MYQ_COORDINATOR: coordinator}
|
hass.data[DOMAIN][entry.entry_id] = {MYQ_GATEWAY: myq, MYQ_COORDINATOR: coordinator}
|
||||||
|
|
||||||
for platform in PLATFORMS:
|
hass.config_entries.async_setup_platforms(entry, PLATFORMS)
|
||||||
hass.async_create_task(
|
|
||||||
hass.config_entries.async_forward_entry_setup(entry, platform)
|
|
||||||
)
|
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry):
|
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry):
|
||||||
"""Unload a config entry."""
|
"""Unload a config entry."""
|
||||||
unload_ok = all(
|
unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
|
||||||
await asyncio.gather(
|
|
||||||
*[
|
|
||||||
hass.config_entries.async_forward_entry_unload(entry, platform)
|
|
||||||
for platform in PLATFORMS
|
|
||||||
]
|
|
||||||
)
|
|
||||||
)
|
|
||||||
if unload_ok:
|
if unload_ok:
|
||||||
hass.data[DOMAIN].pop(entry.entry_id)
|
hass.data[DOMAIN].pop(entry.entry_id)
|
||||||
|
|
||||||
|
@ -239,13 +239,8 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||||||
|
|
||||||
gateway = get_mysensors_gateway(hass, entry.entry_id)
|
gateway = get_mysensors_gateway(hass, entry.entry_id)
|
||||||
|
|
||||||
unload_ok = all(
|
unload_ok = await hass.config_entries.async_unload_platforms(
|
||||||
await asyncio.gather(
|
entry, PLATFORMS_WITH_ENTRY_SUPPORT
|
||||||
*[
|
|
||||||
hass.config_entries.async_forward_entry_unload(entry, platform)
|
|
||||||
for platform in PLATFORMS_WITH_ENTRY_SUPPORT
|
|
||||||
]
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
if not unload_ok:
|
if not unload_ok:
|
||||||
return False
|
return False
|
||||||
|
@ -23,8 +23,6 @@ async def test_formx(hass):
|
|||||||
with patch(
|
with patch(
|
||||||
"homeassistant.components.kostal_plenticore.config_flow.PlenticoreApiClient"
|
"homeassistant.components.kostal_plenticore.config_flow.PlenticoreApiClient"
|
||||||
) as mock_api_class, patch(
|
) as mock_api_class, patch(
|
||||||
"homeassistant.components.kostal_plenticore.async_setup", return_value=True
|
|
||||||
) as mock_setup, patch(
|
|
||||||
"homeassistant.components.kostal_plenticore.async_setup_entry",
|
"homeassistant.components.kostal_plenticore.async_setup_entry",
|
||||||
return_value=True,
|
return_value=True,
|
||||||
) as mock_setup_entry:
|
) as mock_setup_entry:
|
||||||
@ -63,7 +61,6 @@ async def test_formx(hass):
|
|||||||
"password": "test-password",
|
"password": "test-password",
|
||||||
}
|
}
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
assert len(mock_setup.mock_calls) == 1
|
|
||||||
assert len(mock_setup_entry.mock_calls) == 1
|
assert len(mock_setup_entry.mock_calls) == 1
|
||||||
|
|
||||||
|
|
||||||
|
@ -23,8 +23,6 @@ async def test_form_user(hass):
|
|||||||
"homeassistant.components.myq.config_flow.pymyq.login",
|
"homeassistant.components.myq.config_flow.pymyq.login",
|
||||||
return_value=True,
|
return_value=True,
|
||||||
), patch(
|
), patch(
|
||||||
"homeassistant.components.myq.async_setup", return_value=True
|
|
||||||
) as mock_setup, patch(
|
|
||||||
"homeassistant.components.myq.async_setup_entry",
|
"homeassistant.components.myq.async_setup_entry",
|
||||||
return_value=True,
|
return_value=True,
|
||||||
) as mock_setup_entry:
|
) as mock_setup_entry:
|
||||||
@ -40,7 +38,6 @@ async def test_form_user(hass):
|
|||||||
"username": "test-username",
|
"username": "test-username",
|
||||||
"password": "test-password",
|
"password": "test-password",
|
||||||
}
|
}
|
||||||
assert len(mock_setup.mock_calls) == 1
|
|
||||||
assert len(mock_setup_entry.mock_calls) == 1
|
assert len(mock_setup_entry.mock_calls) == 1
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user