Reduce config entry setup/unload boilerplate G-J (#49737)
This commit is contained in:
parent
157dd273da
commit
a1fdf84dba
43 changed files with 172 additions and 493 deletions
|
@ -1,5 +1,4 @@
|
||||||
"""The Garmin Connect integration."""
|
"""The Garmin Connect integration."""
|
||||||
import asyncio
|
|
||||||
from datetime import date, timedelta
|
from datetime import date, timedelta
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
@ -52,27 +51,16 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
|
||||||
hass.data.setdefault(DOMAIN, {})
|
hass.data.setdefault(DOMAIN, {})
|
||||||
hass.data[DOMAIN][entry.entry_id] = garmin_data
|
hass.data[DOMAIN][entry.entry_id] = garmin_data
|
||||||
|
|
||||||
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)
|
||||||
|
|
||||||
return unload_ok
|
return unload_ok
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
"""The Global Disaster Alert and Coordination System (GDACS) integration."""
|
"""The Global Disaster Alert and Coordination System (GDACS) integration."""
|
||||||
import asyncio
|
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
@ -97,17 +96,11 @@ async def async_setup_entry(hass, config_entry):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
async def async_unload_entry(hass, config_entry):
|
async def async_unload_entry(hass, entry):
|
||||||
"""Unload an GDACS component config entry."""
|
"""Unload an GDACS component config entry."""
|
||||||
manager = hass.data[DOMAIN][FEED].pop(config_entry.entry_id)
|
manager = hass.data[DOMAIN][FEED].pop(entry.entry_id)
|
||||||
await manager.async_stop()
|
await manager.async_stop()
|
||||||
await asyncio.wait(
|
return await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
|
||||||
[
|
|
||||||
hass.config_entries.async_forward_entry_unload(config_entry, domain)
|
|
||||||
for domain in PLATFORMS
|
|
||||||
]
|
|
||||||
)
|
|
||||||
return True
|
|
||||||
|
|
||||||
|
|
||||||
class GdacsFeedEntityManager:
|
class GdacsFeedEntityManager:
|
||||||
|
@ -142,12 +135,7 @@ class GdacsFeedEntityManager:
|
||||||
async def async_init(self):
|
async def async_init(self):
|
||||||
"""Schedule initial and regular updates based on configured time interval."""
|
"""Schedule initial and regular updates based on configured time interval."""
|
||||||
|
|
||||||
for domain in PLATFORMS:
|
self._hass.config_entries.async_setup_platforms(self._config_entry, PLATFORMS)
|
||||||
self._hass.async_create_task(
|
|
||||||
self._hass.config_entries.async_forward_entry_setup(
|
|
||||||
self._config_entry, domain
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
async def update(event_time):
|
async def update(event_time):
|
||||||
"""Update."""
|
"""Update."""
|
||||||
|
|
|
@ -19,6 +19,8 @@ from homeassistant.util import slugify
|
||||||
|
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
|
|
||||||
|
PLATFORMS = [DEVICE_TRACKER]
|
||||||
|
|
||||||
CONF_MOBILE_BEACONS = "mobile_beacons"
|
CONF_MOBILE_BEACONS = "mobile_beacons"
|
||||||
|
|
||||||
CONFIG_SCHEMA = vol.Schema(
|
CONFIG_SCHEMA = vol.Schema(
|
||||||
|
@ -136,9 +138,7 @@ async def async_setup_entry(hass, entry):
|
||||||
DOMAIN, "Geofency", entry.data[CONF_WEBHOOK_ID], handle_webhook
|
DOMAIN, "Geofency", 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
|
||||||
|
|
||||||
|
|
||||||
|
@ -146,8 +146,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)()
|
||||||
await hass.config_entries.async_forward_entry_unload(entry, DEVICE_TRACKER)
|
return await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
|
||||||
return True
|
|
||||||
|
|
||||||
|
|
||||||
async_remove_entry = config_entry_flow.webhook_async_remove_entry
|
async_remove_entry = config_entry_flow.webhook_async_remove_entry
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
"""The GeoNet NZ Quakes integration."""
|
"""The GeoNet NZ Quakes integration."""
|
||||||
import asyncio
|
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
@ -104,17 +103,11 @@ async def async_setup_entry(hass, config_entry):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
async def async_unload_entry(hass, config_entry):
|
async def async_unload_entry(hass, entry):
|
||||||
"""Unload an GeoNet NZ Quakes component config entry."""
|
"""Unload an GeoNet NZ Quakes component config entry."""
|
||||||
manager = hass.data[DOMAIN][FEED].pop(config_entry.entry_id)
|
manager = hass.data[DOMAIN][FEED].pop(entry.entry_id)
|
||||||
await manager.async_stop()
|
await manager.async_stop()
|
||||||
await asyncio.wait(
|
return await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
|
||||||
[
|
|
||||||
hass.config_entries.async_forward_entry_unload(config_entry, domain)
|
|
||||||
for domain in PLATFORMS
|
|
||||||
]
|
|
||||||
)
|
|
||||||
return True
|
|
||||||
|
|
||||||
|
|
||||||
class GeonetnzQuakesFeedEntityManager:
|
class GeonetnzQuakesFeedEntityManager:
|
||||||
|
@ -150,12 +143,7 @@ class GeonetnzQuakesFeedEntityManager:
|
||||||
async def async_init(self):
|
async def async_init(self):
|
||||||
"""Schedule initial and regular updates based on configured time interval."""
|
"""Schedule initial and regular updates based on configured time interval."""
|
||||||
|
|
||||||
for domain in PLATFORMS:
|
self._hass.config_entries.async_setup_platforms(self._config_entry, PLATFORMS)
|
||||||
self._hass.async_create_task(
|
|
||||||
self._hass.config_entries.async_forward_entry_setup(
|
|
||||||
self._config_entry, domain
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
async def update(event_time):
|
async def update(event_time):
|
||||||
"""Update."""
|
"""Update."""
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
"""The GeoNet NZ Volcano integration."""
|
"""The GeoNet NZ Volcano 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
|
||||||
|
|
||||||
|
@ -25,7 +24,7 @@ from homeassistant.helpers.event import async_track_time_interval
|
||||||
from homeassistant.util.unit_system import METRIC_SYSTEM
|
from homeassistant.util.unit_system import METRIC_SYSTEM
|
||||||
|
|
||||||
from .config_flow import configured_instances
|
from .config_flow import configured_instances
|
||||||
from .const import DEFAULT_RADIUS, DEFAULT_SCAN_INTERVAL, DOMAIN, FEED
|
from .const import DEFAULT_RADIUS, DEFAULT_SCAN_INTERVAL, DOMAIN, FEED, PLATFORMS
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -94,14 +93,11 @@ async def async_setup_entry(hass, config_entry):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
async def async_unload_entry(hass, config_entry):
|
async def async_unload_entry(hass, entry):
|
||||||
"""Unload an GeoNet NZ Volcano component config entry."""
|
"""Unload an GeoNet NZ Volcano component config entry."""
|
||||||
manager = hass.data[DOMAIN][FEED].pop(config_entry.entry_id)
|
manager = hass.data[DOMAIN][FEED].pop(entry.entry_id)
|
||||||
await manager.async_stop()
|
await manager.async_stop()
|
||||||
await asyncio.wait(
|
return await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
|
||||||
[hass.config_entries.async_forward_entry_unload(config_entry, "sensor")]
|
|
||||||
)
|
|
||||||
return True
|
|
||||||
|
|
||||||
|
|
||||||
class GeonetnzVolcanoFeedEntityManager:
|
class GeonetnzVolcanoFeedEntityManager:
|
||||||
|
@ -133,11 +129,7 @@ class GeonetnzVolcanoFeedEntityManager:
|
||||||
async def async_init(self):
|
async def async_init(self):
|
||||||
"""Schedule initial and regular updates based on configured time interval."""
|
"""Schedule initial and regular updates based on configured time interval."""
|
||||||
|
|
||||||
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, "sensor"
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
async def update(event_time):
|
async def update(event_time):
|
||||||
"""Update."""
|
"""Update."""
|
||||||
|
|
|
@ -14,3 +14,5 @@ ATTR_HAZARDS = "hazards"
|
||||||
DEFAULT_ICON = "mdi:image-filter-hdr"
|
DEFAULT_ICON = "mdi:image-filter-hdr"
|
||||||
DEFAULT_RADIUS = 50.0
|
DEFAULT_RADIUS = 50.0
|
||||||
DEFAULT_SCAN_INTERVAL = timedelta(minutes=5)
|
DEFAULT_SCAN_INTERVAL = timedelta(minutes=5)
|
||||||
|
|
||||||
|
PLATFORMS = ["sensor"]
|
||||||
|
|
|
@ -12,10 +12,12 @@ from .const import CONF_STATION_ID, DOMAIN, SCAN_INTERVAL
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
PLATFORMS = ["air_quality"]
|
||||||
|
|
||||||
async def async_setup_entry(hass, config_entry):
|
|
||||||
|
async def async_setup_entry(hass, entry):
|
||||||
"""Set up GIOS as config entry."""
|
"""Set up GIOS as config entry."""
|
||||||
station_id = config_entry.data[CONF_STATION_ID]
|
station_id = entry.data[CONF_STATION_ID]
|
||||||
_LOGGER.debug("Using station_id: %s", station_id)
|
_LOGGER.debug("Using station_id: %s", station_id)
|
||||||
|
|
||||||
websession = async_get_clientsession(hass)
|
websession = async_get_clientsession(hass)
|
||||||
|
@ -24,19 +26,17 @@ async def async_setup_entry(hass, config_entry):
|
||||||
await coordinator.async_config_entry_first_refresh()
|
await coordinator.async_config_entry_first_refresh()
|
||||||
|
|
||||||
hass.data.setdefault(DOMAIN, {})
|
hass.data.setdefault(DOMAIN, {})
|
||||||
hass.data[DOMAIN][config_entry.entry_id] = coordinator
|
hass.data[DOMAIN][entry.entry_id] = coordinator
|
||||||
|
|
||||||
|
hass.config_entries.async_setup_platforms(entry, PLATFORMS)
|
||||||
|
|
||||||
hass.async_create_task(
|
|
||||||
hass.config_entries.async_forward_entry_setup(config_entry, "air_quality")
|
|
||||||
)
|
|
||||||
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."""
|
||||||
hass.data[DOMAIN].pop(config_entry.entry_id)
|
hass.data[DOMAIN].pop(entry.entry_id)
|
||||||
await hass.config_entries.async_forward_entry_unload(config_entry, "air_quality")
|
return await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
|
||||||
return True
|
|
||||||
|
|
||||||
|
|
||||||
class GiosDataUpdateCoordinator(DataUpdateCoordinator):
|
class GiosDataUpdateCoordinator(DataUpdateCoordinator):
|
||||||
|
|
|
@ -36,6 +36,8 @@ from .const import (
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
PLATFORMS = ["sensor"]
|
||||||
|
|
||||||
GLANCES_SCHEMA = vol.All(
|
GLANCES_SCHEMA = vol.All(
|
||||||
vol.Schema(
|
vol.Schema(
|
||||||
{
|
{
|
||||||
|
@ -79,11 +81,12 @@ async def async_setup_entry(hass, config_entry):
|
||||||
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."""
|
||||||
await hass.config_entries.async_forward_entry_unload(config_entry, "sensor")
|
unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
|
||||||
hass.data[DOMAIN].pop(config_entry.entry_id)
|
if unload_ok:
|
||||||
return True
|
hass.data[DOMAIN].pop(entry.entry_id)
|
||||||
|
return unload_ok
|
||||||
|
|
||||||
|
|
||||||
class GlancesData:
|
class GlancesData:
|
||||||
|
@ -127,13 +130,12 @@ class GlancesData:
|
||||||
|
|
||||||
self.add_options()
|
self.add_options()
|
||||||
self.set_scan_interval(self.config_entry.options[CONF_SCAN_INTERVAL])
|
self.set_scan_interval(self.config_entry.options[CONF_SCAN_INTERVAL])
|
||||||
|
self.config_entry.async_on_unload(
|
||||||
self.config_entry.add_update_listener(self.async_options_updated)
|
self.config_entry.add_update_listener(self.async_options_updated)
|
||||||
|
)
|
||||||
|
|
||||||
|
self.hass.config_entries.async_setup_platforms(self.config_entry, PLATFORMS)
|
||||||
|
|
||||||
self.hass.async_create_task(
|
|
||||||
self.hass.config_entries.async_forward_entry_setup(
|
|
||||||
self.config_entry, "sensor"
|
|
||||||
)
|
|
||||||
)
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def add_options(self):
|
def add_options(self):
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
"""The Goal Zero Yeti integration."""
|
"""The Goal Zero Yeti integration."""
|
||||||
import asyncio
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from goalzero import Yeti, exceptions
|
from goalzero import Yeti, exceptions
|
||||||
|
@ -56,24 +55,14 @@ async def async_setup_entry(hass, entry):
|
||||||
DATA_KEY_COORDINATOR: coordinator,
|
DATA_KEY_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)
|
||||||
return unload_ok
|
return unload_ok
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
"""The gogogate2 component."""
|
"""The gogogate2 component."""
|
||||||
import asyncio
|
|
||||||
|
|
||||||
from homeassistant.components.cover import DOMAIN as COVER
|
from homeassistant.components.cover import DOMAIN as COVER
|
||||||
from homeassistant.components.sensor import DOMAIN as SENSOR
|
from homeassistant.components.sensor import DOMAIN as SENSOR
|
||||||
|
@ -13,40 +12,28 @@ from .const import DEVICE_TYPE_GOGOGATE2
|
||||||
PLATFORMS = [COVER, SENSOR]
|
PLATFORMS = [COVER, SENSOR]
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> bool:
|
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||||
"""Do setup of Gogogate2."""
|
"""Do setup of Gogogate2."""
|
||||||
|
|
||||||
# Update the config entry.
|
# Update the config entry.
|
||||||
config_updates = {}
|
config_updates = {}
|
||||||
if CONF_DEVICE not in config_entry.data:
|
if CONF_DEVICE not in entry.data:
|
||||||
config_updates["data"] = {
|
config_updates["data"] = {
|
||||||
**config_entry.data,
|
**entry.data,
|
||||||
**{CONF_DEVICE: DEVICE_TYPE_GOGOGATE2},
|
**{CONF_DEVICE: DEVICE_TYPE_GOGOGATE2},
|
||||||
}
|
}
|
||||||
|
|
||||||
if config_updates:
|
if config_updates:
|
||||||
hass.config_entries.async_update_entry(config_entry, **config_updates)
|
hass.config_entries.async_update_entry(entry, **config_updates)
|
||||||
|
|
||||||
data_update_coordinator = get_data_update_coordinator(hass, config_entry)
|
data_update_coordinator = get_data_update_coordinator(hass, entry)
|
||||||
await data_update_coordinator.async_config_entry_first_refresh()
|
await data_update_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(config_entry, platform)
|
|
||||||
)
|
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
async def async_unload_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> bool:
|
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||||
"""Unload Gogogate2 config entry."""
|
"""Unload Gogogate2 config entry."""
|
||||||
unload_ok = all(
|
return await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
|
||||||
await asyncio.gather(
|
|
||||||
*[
|
|
||||||
hass.config_entries.async_forward_entry_unload(config_entry, platform)
|
|
||||||
for platform in PLATFORMS
|
|
||||||
]
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
return unload_ok
|
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
"""The google_travel_time component."""
|
"""The google_travel_time component."""
|
||||||
import asyncio
|
|
||||||
|
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
|
@ -9,23 +8,10 @@ PLATFORMS = ["sensor"]
|
||||||
|
|
||||||
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
|
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
|
||||||
"""Set up Google Maps Travel Time from a config entry."""
|
"""Set up Google Maps Travel Time from a config entry."""
|
||||||
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):
|
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry):
|
||||||
"""Unload a config entry."""
|
"""Unload a config entry."""
|
||||||
unload_ok = all(
|
return 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
|
|
||||||
]
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
return unload_ok
|
|
||||||
|
|
|
@ -28,6 +28,8 @@ from .const import (
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
PLATFORMS = [DEVICE_TRACKER]
|
||||||
|
|
||||||
TRACKER_UPDATE = f"{DOMAIN}_tracker_update"
|
TRACKER_UPDATE = f"{DOMAIN}_tracker_update"
|
||||||
|
|
||||||
|
|
||||||
|
@ -98,9 +100,8 @@ async def async_setup_entry(hass, entry):
|
||||||
DOMAIN, "GPSLogger", entry.data[CONF_WEBHOOK_ID], handle_webhook
|
DOMAIN, "GPSLogger", 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
|
||||||
|
|
||||||
|
|
||||||
|
@ -108,8 +109,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)()
|
||||||
await hass.config_entries.async_forward_entry_unload(entry, DEVICE_TRACKER)
|
return await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
|
||||||
return True
|
|
||||||
|
|
||||||
|
|
||||||
async_remove_entry = config_entry_flow.webhook_async_remove_entry
|
async_remove_entry = config_entry_flow.webhook_async_remove_entry
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
"""The Gree Climate integration."""
|
"""The Gree Climate integration."""
|
||||||
import asyncio
|
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
@ -21,26 +20,17 @@ from .const import (
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
PLATFORMS = [CLIMATE_DOMAIN, SWITCH_DOMAIN]
|
||||||
async def async_setup(hass: HomeAssistant, config: dict):
|
|
||||||
"""Set up the Gree Climate component."""
|
|
||||||
hass.data[DOMAIN] = {}
|
|
||||||
return True
|
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
|
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
|
||||||
"""Set up Gree Climate from a config entry."""
|
"""Set up Gree Climate from a config entry."""
|
||||||
|
hass.data.setdefault(DOMAIN, {})
|
||||||
gree_discovery = DiscoveryService(hass)
|
gree_discovery = DiscoveryService(hass)
|
||||||
hass.data[DATA_DISCOVERY_SERVICE] = gree_discovery
|
hass.data[DATA_DISCOVERY_SERVICE] = gree_discovery
|
||||||
|
|
||||||
hass.data[DOMAIN].setdefault(DISPATCHERS, [])
|
hass.data[DOMAIN].setdefault(DISPATCHERS, [])
|
||||||
|
hass.config_entries.async_setup_platforms(entry, PLATFORMS)
|
||||||
hass.async_create_task(
|
|
||||||
hass.config_entries.async_forward_entry_setup(entry, CLIMATE_DOMAIN)
|
|
||||||
)
|
|
||||||
hass.async_create_task(
|
|
||||||
hass.config_entries.async_forward_entry_setup(entry, SWITCH_DOMAIN)
|
|
||||||
)
|
|
||||||
|
|
||||||
async def _async_scan_update(_=None):
|
async def _async_scan_update(_=None):
|
||||||
await gree_discovery.discovery.scan()
|
await gree_discovery.discovery.scan()
|
||||||
|
@ -67,12 +57,8 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry):
|
||||||
if hass.data.get(DATA_DISCOVERY_SERVICE) is not None:
|
if hass.data.get(DATA_DISCOVERY_SERVICE) is not None:
|
||||||
hass.data.pop(DATA_DISCOVERY_SERVICE)
|
hass.data.pop(DATA_DISCOVERY_SERVICE)
|
||||||
|
|
||||||
results = asyncio.gather(
|
unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
|
||||||
hass.config_entries.async_forward_entry_unload(entry, CLIMATE_DOMAIN),
|
|
||||||
hass.config_entries.async_forward_entry_unload(entry, SWITCH_DOMAIN),
|
|
||||||
)
|
|
||||||
|
|
||||||
unload_ok = all(await results)
|
|
||||||
if unload_ok:
|
if unload_ok:
|
||||||
hass.data[DOMAIN].pop(COORDINATORS, None)
|
hass.data[DOMAIN].pop(COORDINATORS, None)
|
||||||
hass.data[DOMAIN].pop(DISPATCHERS, None)
|
hass.data[DOMAIN].pop(DISPATCHERS, None)
|
||||||
|
|
|
@ -105,24 +105,14 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||||
].async_add_listener(async_process_paired_sensor_uids)
|
].async_add_listener(async_process_paired_sensor_uids)
|
||||||
|
|
||||||
# Set up all of the Guardian entity platforms:
|
# Set up all of the Guardian entity platforms:
|
||||||
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) -> 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:
|
||||||
hass.data[DOMAIN][DATA_CLIENT].pop(entry.entry_id)
|
hass.data[DOMAIN][DATA_CLIENT].pop(entry.entry_id)
|
||||||
hass.data[DOMAIN][DATA_COORDINATOR].pop(entry.entry_id)
|
hass.data[DOMAIN][DATA_COORDINATOR].pop(entry.entry_id)
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
"""The habitica integration."""
|
"""The habitica integration."""
|
||||||
import asyncio
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from habitipy.aio import HabitipyAsync
|
from habitipy.aio import HabitipyAsync
|
||||||
|
@ -100,7 +99,7 @@ async def async_setup(hass: HomeAssistant, config: dict) -> bool:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> bool:
|
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||||
"""Set up habitica from a config entry."""
|
"""Set up habitica from a config entry."""
|
||||||
|
|
||||||
class HAHabitipyAsync(HabitipyAsync):
|
class HAHabitipyAsync(HabitipyAsync):
|
||||||
|
@ -131,7 +130,7 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> b
|
||||||
)
|
)
|
||||||
|
|
||||||
data = hass.data.setdefault(DOMAIN, {})
|
data = hass.data.setdefault(DOMAIN, {})
|
||||||
config = config_entry.data
|
config = entry.data
|
||||||
websession = async_get_clientsession(hass)
|
websession = async_get_clientsession(hass)
|
||||||
url = config[CONF_URL]
|
url = config[CONF_URL]
|
||||||
username = config[CONF_API_USER]
|
username = config[CONF_API_USER]
|
||||||
|
@ -143,15 +142,12 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> b
|
||||||
if name is None:
|
if name is None:
|
||||||
name = user["profile"]["name"]
|
name = user["profile"]["name"]
|
||||||
hass.config_entries.async_update_entry(
|
hass.config_entries.async_update_entry(
|
||||||
config_entry,
|
entry,
|
||||||
data={**config_entry.data, CONF_NAME: name},
|
data={**entry.data, CONF_NAME: name},
|
||||||
)
|
)
|
||||||
data[config_entry.entry_id] = api
|
data[entry.entry_id] = api
|
||||||
|
|
||||||
for platform in PLATFORMS:
|
hass.config_entries.async_setup_platforms(entry, PLATFORMS)
|
||||||
hass.async_create_task(
|
|
||||||
hass.config_entries.async_forward_entry_setup(config_entry, platform)
|
|
||||||
)
|
|
||||||
|
|
||||||
if not hass.services.has_service(DOMAIN, SERVICE_API_CALL):
|
if not hass.services.has_service(DOMAIN, SERVICE_API_CALL):
|
||||||
hass.services.async_register(
|
hass.services.async_register(
|
||||||
|
@ -163,14 +159,7 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> b
|
||||||
|
|
||||||
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)
|
||||||
|
|
||||||
|
|
|
@ -58,10 +58,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
|
||||||
CANCEL_STOP: cancel_stop,
|
CANCEL_STOP: cancel_stop,
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
||||||
|
|
||||||
|
@ -115,14 +112,7 @@ async def _update_listener(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
|
|
||||||
]
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
# Shutdown a harmony remote for removal
|
# Shutdown a harmony remote for removal
|
||||||
entry_data = hass.data[DOMAIN][entry.entry_id]
|
entry_data = hass.data[DOMAIN][entry.entry_id]
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
"""Support for Hass.io."""
|
"""Support for Hass.io."""
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import asyncio
|
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
|
@ -518,31 +517,21 @@ async def async_setup(hass: HomeAssistant, config: Config) -> bool: # noqa: C90
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> bool:
|
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||||
"""Set up a config entry."""
|
"""Set up a config entry."""
|
||||||
dev_reg = await async_get_registry(hass)
|
dev_reg = await async_get_registry(hass)
|
||||||
coordinator = HassioDataUpdateCoordinator(hass, config_entry, dev_reg)
|
coordinator = HassioDataUpdateCoordinator(hass, entry, dev_reg)
|
||||||
hass.data[ADDONS_COORDINATOR] = coordinator
|
hass.data[ADDONS_COORDINATOR] = coordinator
|
||||||
await coordinator.async_refresh()
|
await coordinator.async_refresh()
|
||||||
|
|
||||||
for platform in PLATFORMS:
|
hass.config_entries.async_setup_platforms(entry, PLATFORMS)
|
||||||
hass.async_create_task(
|
|
||||||
hass.config_entries.async_forward_entry_setup(config_entry, platform)
|
|
||||||
)
|
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
async def async_unload_entry(hass: HomeAssistant, config_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(config_entry, platform)
|
|
||||||
for platform in PLATFORMS
|
|
||||||
]
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
# Pop add-on data
|
# Pop add-on data
|
||||||
hass.data.pop(ADDONS_COORDINATOR, None)
|
hass.data.pop(ADDONS_COORDINATOR, None)
|
||||||
|
|
|
@ -28,6 +28,8 @@ from .const import (
|
||||||
SIGNAL_HEOS_UPDATED,
|
SIGNAL_HEOS_UPDATED,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
PLATFORMS = [MEDIA_PLAYER_DOMAIN]
|
||||||
|
|
||||||
CONFIG_SCHEMA = vol.Schema(
|
CONFIG_SCHEMA = vol.Schema(
|
||||||
{DOMAIN: vol.Schema({vol.Required(CONF_HOST): cv.string})}, extra=vol.ALLOW_EXTRA
|
{DOMAIN: vol.Schema({vol.Required(CONF_HOST): cv.string})}, extra=vol.ALLOW_EXTRA
|
||||||
)
|
)
|
||||||
|
@ -119,9 +121,8 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
|
||||||
|
|
||||||
services.register(hass, controller)
|
services.register(hass, controller)
|
||||||
|
|
||||||
hass.async_create_task(
|
hass.config_entries.async_setup_platforms(entry, PLATFORMS)
|
||||||
hass.config_entries.async_forward_entry_setup(entry, MEDIA_PLAYER_DOMAIN)
|
|
||||||
)
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
@ -133,9 +134,7 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry):
|
||||||
|
|
||||||
services.remove(hass)
|
services.remove(hass)
|
||||||
|
|
||||||
return await hass.config_entries.async_forward_entry_unload(
|
return await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
|
||||||
entry, MEDIA_PLAYER_DOMAIN
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class ControllerManager:
|
class ControllerManager:
|
||||||
|
|
|
@ -15,6 +15,8 @@ from .const import DOMAIN
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
PLATFORMS = [CLIMATE_DOMAIN]
|
||||||
|
|
||||||
|
|
||||||
def coerce_ip(value):
|
def coerce_ip(value):
|
||||||
"""Validate that provided value is a valid IP address."""
|
"""Validate that provided value is a valid IP address."""
|
||||||
|
@ -70,13 +72,10 @@ async def async_setup(hass, config):
|
||||||
|
|
||||||
async def async_setup_entry(hass, entry):
|
async def async_setup_entry(hass, entry):
|
||||||
"""Set up a config entry for Hisense AEH-W4A1."""
|
"""Set up a config entry for Hisense AEH-W4A1."""
|
||||||
hass.async_create_task(
|
hass.config_entries.async_setup_platforms(entry, PLATFORMS)
|
||||||
hass.config_entries.async_forward_entry_setup(entry, CLIMATE_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."""
|
||||||
return await hass.config_entries.async_forward_entry_unload(entry, CLIMATE_DOMAIN)
|
return await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
"""Support for the Hive devices and services."""
|
"""Support for the Hive devices and services."""
|
||||||
import asyncio
|
|
||||||
from functools import wraps
|
from functools import wraps
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
@ -92,15 +91,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."""
|
||||||
|
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, component)
|
|
||||||
for component in PLATFORMS
|
|
||||||
]
|
|
||||||
)
|
|
||||||
)
|
|
||||||
if unload_ok:
|
if unload_ok:
|
||||||
hass.data[DOMAIN].pop(entry.entry_id)
|
hass.data[DOMAIN].pop(entry.entry_id)
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,8 @@ from .const import (
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
PLATFORMS = ["switch"]
|
||||||
|
|
||||||
DATA_DEVICE_REGISTER = "hlk_sw16_device_register"
|
DATA_DEVICE_REGISTER = "hlk_sw16_device_register"
|
||||||
DATA_DEVICE_LISTENER = "hlk_sw16_device_listener"
|
DATA_DEVICE_LISTENER = "hlk_sw16_device_listener"
|
||||||
|
|
||||||
|
@ -111,9 +113,7 @@ async def async_setup_entry(hass, entry):
|
||||||
hass.data[DOMAIN][entry.entry_id][DATA_DEVICE_REGISTER] = client
|
hass.data[DOMAIN][entry.entry_id][DATA_DEVICE_REGISTER] = client
|
||||||
|
|
||||||
# Load entities
|
# Load entities
|
||||||
hass.async_create_task(
|
hass.config_entries.async_setup_platforms(entry, PLATFORMS)
|
||||||
hass.config_entries.async_forward_entry_setup(entry, "switch")
|
|
||||||
)
|
|
||||||
|
|
||||||
_LOGGER.info("Connected to HLK-SW16 device: %s", address)
|
_LOGGER.info("Connected to HLK-SW16 device: %s", address)
|
||||||
|
|
||||||
|
@ -126,8 +126,7 @@ async def async_unload_entry(hass, entry):
|
||||||
"""Unload a config entry."""
|
"""Unload a config entry."""
|
||||||
client = hass.data[DOMAIN][entry.entry_id].pop(DATA_DEVICE_REGISTER)
|
client = hass.data[DOMAIN][entry.entry_id].pop(DATA_DEVICE_REGISTER)
|
||||||
client.stop()
|
client.stop()
|
||||||
unload_ok = await hass.config_entries.async_forward_entry_unload(entry, "switch")
|
unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
|
||||||
|
|
||||||
if unload_ok:
|
if unload_ok:
|
||||||
if hass.data[DOMAIN][entry.entry_id]:
|
if hass.data[DOMAIN][entry.entry_id]:
|
||||||
hass.data[DOMAIN].pop(entry.entry_id)
|
hass.data[DOMAIN].pop(entry.entry_id)
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
"""Support for BSH Home Connect appliances."""
|
"""Support for BSH Home Connect appliances."""
|
||||||
|
|
||||||
import asyncio
|
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
@ -71,24 +70,14 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||||
|
|
||||||
await update_all_devices(hass, entry)
|
await update_all_devices(hass, entry)
|
||||||
|
|
||||||
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) -> 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:
|
||||||
hass.data[DOMAIN].pop(entry.entry_id)
|
hass.data[DOMAIN].pop(entry.entry_id)
|
||||||
|
|
||||||
|
|
|
@ -157,13 +157,8 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> b
|
||||||
|
|
||||||
async def async_unload_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> bool:
|
async def async_unload_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> bool:
|
||||||
"""Unload the Legrand Home+ Control config entry."""
|
"""Unload the Legrand Home+ Control 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, component)
|
|
||||||
for component in PLATFORMS
|
|
||||||
]
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
if unload_ok:
|
if unload_ok:
|
||||||
# Unsubscribe the config_entry signal dispatcher connections
|
# Unsubscribe the config_entry signal dispatcher connections
|
||||||
|
|
|
@ -269,17 +269,9 @@ class HKDevice:
|
||||||
|
|
||||||
await self.pairing.unsubscribe(self.watchable_characteristics)
|
await self.pairing.unsubscribe(self.watchable_characteristics)
|
||||||
|
|
||||||
unloads = []
|
return await self.hass.config_entries.async_unload_platforms(
|
||||||
for platform in self.platforms:
|
self.config_entry, self.platforms
|
||||||
unloads.append(
|
|
||||||
self.hass.config_entries.async_forward_entry_unload(
|
|
||||||
self.config_entry, platform
|
|
||||||
)
|
)
|
||||||
)
|
|
||||||
|
|
||||||
results = await asyncio.gather(*unloads)
|
|
||||||
|
|
||||||
return False not in results
|
|
||||||
|
|
||||||
async def async_refresh_entity_map(self, config_num):
|
async def async_refresh_entity_map(self, config_num):
|
||||||
"""Handle setup of a HomeKit accessory."""
|
"""Handle setup of a HomeKit accessory."""
|
||||||
|
|
|
@ -101,12 +101,8 @@ class HomematicipHAP:
|
||||||
"Connected to HomematicIP with HAP %s", self.config_entry.unique_id
|
"Connected to HomematicIP with HAP %s", self.config_entry.unique_id
|
||||||
)
|
)
|
||||||
|
|
||||||
for platform in PLATFORMS:
|
self.hass.config_entries.async_setup_platforms(self.config_entry, PLATFORMS)
|
||||||
self.hass.async_create_task(
|
|
||||||
self.hass.config_entries.async_forward_entry_setup(
|
|
||||||
self.config_entry, platform
|
|
||||||
)
|
|
||||||
)
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
|
@ -214,9 +210,8 @@ class HomematicipHAP:
|
||||||
self._retry_task.cancel()
|
self._retry_task.cancel()
|
||||||
await self.home.disable_events()
|
await self.home.disable_events()
|
||||||
_LOGGER.info("Closed connection to HomematicIP cloud server")
|
_LOGGER.info("Closed connection to HomematicIP cloud server")
|
||||||
for platform in PLATFORMS:
|
await self.hass.config_entries.async_unload_platforms(
|
||||||
await self.hass.config_entries.async_forward_entry_unload(
|
self.config_entry, PLATFORMS
|
||||||
self.config_entry, platform
|
|
||||||
)
|
)
|
||||||
self.hmip_device_by_entity_id = {}
|
self.hmip_device_by_entity_id = {}
|
||||||
return True
|
return True
|
||||||
|
|
|
@ -420,10 +420,8 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> b
|
||||||
)
|
)
|
||||||
|
|
||||||
# Forward config entry setup to platforms
|
# Forward config entry setup to platforms
|
||||||
for domain in CONFIG_ENTRY_PLATFORMS:
|
hass.config_entries.async_setup_platforms(config_entry, CONFIG_ENTRY_PLATFORMS)
|
||||||
hass.async_create_task(
|
|
||||||
hass.config_entries.async_forward_entry_setup(config_entry, domain)
|
|
||||||
)
|
|
||||||
# Notify doesn't support config entry setup yet, load with discovery for now
|
# Notify doesn't support config entry setup yet, load with discovery for now
|
||||||
await discovery.async_load_platform(
|
await discovery.async_load_platform(
|
||||||
hass,
|
hass,
|
||||||
|
@ -462,8 +460,9 @@ async def async_unload_entry(hass: HomeAssistant, config_entry: ConfigEntry) ->
|
||||||
"""Unload config entry."""
|
"""Unload config entry."""
|
||||||
|
|
||||||
# Forward config entry unload to platforms
|
# Forward config entry unload to platforms
|
||||||
for domain in CONFIG_ENTRY_PLATFORMS:
|
await hass.config_entries.async_unload_platforms(
|
||||||
await hass.config_entries.async_forward_entry_unload(config_entry, domain)
|
config_entry, CONFIG_ENTRY_PLATFORMS
|
||||||
|
)
|
||||||
|
|
||||||
# Forget about the router and invoke its cleanup
|
# Forget about the router and invoke its cleanup
|
||||||
router = hass.data[DOMAIN].routers.pop(config_entry.data[CONF_URL])
|
router = hass.data[DOMAIN].routers.pop(config_entry.data[CONF_URL])
|
||||||
|
|
|
@ -29,6 +29,9 @@ from .sensor_base import SensorManager
|
||||||
|
|
||||||
# How long should we sleep if the hub is busy
|
# How long should we sleep if the hub is busy
|
||||||
HUB_BUSY_SLEEP = 0.5
|
HUB_BUSY_SLEEP = 0.5
|
||||||
|
|
||||||
|
PLATFORMS = ["light", "binary_sensor", "sensor"]
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
@ -101,17 +104,7 @@ class HueBridge:
|
||||||
self.api = bridge
|
self.api = bridge
|
||||||
self.sensor_manager = SensorManager(self)
|
self.sensor_manager = SensorManager(self)
|
||||||
|
|
||||||
hass.async_create_task(
|
hass.config_entries.async_setup_platforms(self.config_entry, PLATFORMS)
|
||||||
hass.config_entries.async_forward_entry_setup(self.config_entry, "light")
|
|
||||||
)
|
|
||||||
hass.async_create_task(
|
|
||||||
hass.config_entries.async_forward_entry_setup(
|
|
||||||
self.config_entry, "binary_sensor"
|
|
||||||
)
|
|
||||||
)
|
|
||||||
hass.async_create_task(
|
|
||||||
hass.config_entries.async_forward_entry_setup(self.config_entry, "sensor")
|
|
||||||
)
|
|
||||||
|
|
||||||
self.parallel_updates_semaphore = asyncio.Semaphore(
|
self.parallel_updates_semaphore = asyncio.Semaphore(
|
||||||
3 if self.api.config.modelid == "BSB001" else 10
|
3 if self.api.config.modelid == "BSB001" else 10
|
||||||
|
@ -179,21 +172,10 @@ class HueBridge:
|
||||||
|
|
||||||
# If setup was successful, we set api variable, forwarded entry and
|
# If setup was successful, we set api variable, forwarded entry and
|
||||||
# register service
|
# register service
|
||||||
results = await asyncio.gather(
|
return await self.hass.config_entries.async_unload_platforms(
|
||||||
self.hass.config_entries.async_forward_entry_unload(
|
self.config_entry, PLATFORMS
|
||||||
self.config_entry, "light"
|
|
||||||
),
|
|
||||||
self.hass.config_entries.async_forward_entry_unload(
|
|
||||||
self.config_entry, "binary_sensor"
|
|
||||||
),
|
|
||||||
self.hass.config_entries.async_forward_entry_unload(
|
|
||||||
self.config_entry, "sensor"
|
|
||||||
),
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# None and True are OK
|
|
||||||
return False not in results
|
|
||||||
|
|
||||||
async def hue_activate_scene(self, data, skip_reload=False, hide_warnings=False):
|
async def hue_activate_scene(self, data, skip_reload=False, hide_warnings=False):
|
||||||
"""Service to call directly into bridge to set scenes."""
|
"""Service to call directly into bridge to set scenes."""
|
||||||
group_name = data[ATTR_GROUP_NAME]
|
group_name = data[ATTR_GROUP_NAME]
|
||||||
|
|
|
@ -23,20 +23,17 @@ from .const import (
|
||||||
SOURCE_TYPES,
|
SOURCE_TYPES,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
PLATFORMS = ["sensor"]
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
async def async_setup(hass: HomeAssistant, config: dict):
|
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
|
||||||
"""Set up the Huisbaasje component."""
|
|
||||||
return True
|
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry):
|
|
||||||
"""Set up Huisbaasje from a config entry."""
|
"""Set up Huisbaasje from a config entry."""
|
||||||
# Create the Huisbaasje client
|
# Create the Huisbaasje client
|
||||||
huisbaasje = Huisbaasje(
|
huisbaasje = Huisbaasje(
|
||||||
username=config_entry.data[CONF_USERNAME],
|
username=entry.data[CONF_USERNAME],
|
||||||
password=config_entry.data[CONF_PASSWORD],
|
password=entry.data[CONF_PASSWORD],
|
||||||
source_types=SOURCE_TYPES,
|
source_types=SOURCE_TYPES,
|
||||||
request_timeout=FETCH_TIMEOUT,
|
request_timeout=FETCH_TIMEOUT,
|
||||||
)
|
)
|
||||||
|
@ -63,28 +60,22 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry):
|
||||||
await coordinator.async_config_entry_first_refresh()
|
await coordinator.async_config_entry_first_refresh()
|
||||||
|
|
||||||
# Load the client in the data of home assistant
|
# Load the client in the data of home assistant
|
||||||
hass.data.setdefault(DOMAIN, {})[config_entry.entry_id] = {
|
hass.data.setdefault(DOMAIN, {})[entry.entry_id] = {DATA_COORDINATOR: coordinator}
|
||||||
DATA_COORDINATOR: coordinator
|
|
||||||
}
|
|
||||||
|
|
||||||
# Offload the loading of entities to the platform
|
# Offload the loading of entities to the platform
|
||||||
hass.async_create_task(
|
hass.config_entries.async_setup_platforms(entry, PLATFORMS)
|
||||||
hass.config_entries.async_forward_entry_setup(config_entry, "sensor")
|
|
||||||
)
|
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
async def async_unload_entry(hass: HomeAssistant, config_entry: ConfigEntry):
|
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry):
|
||||||
"""Unload a config entry."""
|
"""Unload a config entry."""
|
||||||
# Forward the unloading of the entry to the platform
|
# Forward the unloading of the entry to the platform
|
||||||
unload_ok = await hass.config_entries.async_forward_entry_unload(
|
unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
|
||||||
config_entry, "sensor"
|
|
||||||
)
|
|
||||||
|
|
||||||
# If successful, unload the Huisbaasje client
|
# If successful, unload the Huisbaasje client
|
||||||
if unload_ok:
|
if unload_ok:
|
||||||
hass.data[DOMAIN].pop(config_entry.entry_id)
|
hass.data[DOMAIN].pop(entry.entry_id)
|
||||||
|
|
||||||
return unload_ok
|
return unload_ok
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
"""The Hunter Douglas PowerView integration."""
|
"""The Hunter Douglas PowerView integration."""
|
||||||
import asyncio
|
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
@ -127,10 +126,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
|
||||||
DEVICE_INFO: device_info,
|
DEVICE_INFO: device_info,
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
||||||
|
|
||||||
|
@ -172,15 +168,7 @@ def _async_map_data_by_id(data):
|
||||||
|
|
||||||
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)
|
||||||
|
|
||||||
return unload_ok
|
return unload_ok
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
"""The HVV integration."""
|
"""The HVV integration."""
|
||||||
import asyncio
|
|
||||||
|
|
||||||
from homeassistant.components.binary_sensor import DOMAIN as DOMAIN_BINARY_SENSOR
|
from homeassistant.components.binary_sensor import DOMAIN as DOMAIN_BINARY_SENSOR
|
||||||
from homeassistant.components.sensor import DOMAIN as DOMAIN_SENSOR
|
from homeassistant.components.sensor import DOMAIN as DOMAIN_SENSOR
|
||||||
|
@ -27,22 +26,11 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
|
||||||
hass.data.setdefault(DOMAIN, {})
|
hass.data.setdefault(DOMAIN, {})
|
||||||
hass.data[DOMAIN][entry.entry_id] = hub
|
hass.data[DOMAIN][entry.entry_id] = hub
|
||||||
|
|
||||||
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(
|
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
|
|
||||||
]
|
|
||||||
)
|
|
||||||
)
|
|
||||||
return unload_ok
|
|
||||||
|
|
|
@ -297,13 +297,8 @@ async def _async_entry_updated(hass: HomeAssistant, config_entry: ConfigEntry) -
|
||||||
|
|
||||||
async def async_unload_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> bool:
|
async def async_unload_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> bool:
|
||||||
"""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 and config_entry.entry_id in hass.data[DOMAIN]:
|
if unload_ok and config_entry.entry_id in hass.data[DOMAIN]:
|
||||||
config_data = hass.data[DOMAIN].pop(config_entry.entry_id)
|
config_data = hass.data[DOMAIN].pop(config_entry.entry_id)
|
||||||
|
|
|
@ -14,7 +14,7 @@ from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, Upda
|
||||||
|
|
||||||
from .const import DATA_COORDINATOR, DOMAIN, IALARM_TO_HASS
|
from .const import DATA_COORDINATOR, DOMAIN, IALARM_TO_HASS
|
||||||
|
|
||||||
PLATFORM = "alarm_control_panel"
|
PLATFORMS = ["alarm_control_panel"]
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
@ -39,20 +39,16 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
|
||||||
DATA_COORDINATOR: coordinator,
|
DATA_COORDINATOR: coordinator,
|
||||||
}
|
}
|
||||||
|
|
||||||
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 iAlarm config."""
|
"""Unload iAlarm config."""
|
||||||
unload_ok = await hass.config_entries.async_forward_entry_unload(entry, PLATFORM)
|
unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
|
||||||
|
|
||||||
if unload_ok:
|
if unload_ok:
|
||||||
hass.data[DOMAIN].pop(entry.entry_id)
|
hass.data[DOMAIN].pop(entry.entry_id)
|
||||||
|
|
||||||
return unload_ok
|
return unload_ok
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -46,6 +46,14 @@ _LOGGER = logging.getLogger(__name__)
|
||||||
ATTR_CONFIG = "config"
|
ATTR_CONFIG = "config"
|
||||||
PARALLEL_UPDATES = 0
|
PARALLEL_UPDATES = 0
|
||||||
|
|
||||||
|
PLATFORMS = [
|
||||||
|
BINARY_SENSOR_DOMAIN,
|
||||||
|
CLIMATE_DOMAIN,
|
||||||
|
LIGHT_DOMAIN,
|
||||||
|
SENSOR_DOMAIN,
|
||||||
|
SWITCH_DOMAIN,
|
||||||
|
]
|
||||||
|
|
||||||
CONFIG_SCHEMA = vol.Schema(
|
CONFIG_SCHEMA = vol.Schema(
|
||||||
{
|
{
|
||||||
DOMAIN: vol.Schema(
|
DOMAIN: vol.Schema(
|
||||||
|
@ -160,24 +168,13 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> None:
|
||||||
|
|
||||||
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."""
|
||||||
forward_unload = hass.config_entries.async_forward_entry_unload
|
platforms_to_unload = [
|
||||||
|
platform for platform in PLATFORMS if platform in hass.data[DOMAIN]
|
||||||
tasks = []
|
]
|
||||||
|
|
||||||
if hass.data[DOMAIN][BINARY_SENSOR_DOMAIN]:
|
|
||||||
tasks += [forward_unload(entry, BINARY_SENSOR_DOMAIN)]
|
|
||||||
if hass.data[DOMAIN][CLIMATE_DOMAIN]:
|
|
||||||
tasks += [forward_unload(entry, CLIMATE_DOMAIN)]
|
|
||||||
if hass.data[DOMAIN][LIGHT_DOMAIN]:
|
|
||||||
tasks += [forward_unload(entry, LIGHT_DOMAIN)]
|
|
||||||
if hass.data[DOMAIN][SENSOR_DOMAIN]:
|
|
||||||
tasks += [forward_unload(entry, SENSOR_DOMAIN)]
|
|
||||||
if hass.data[DOMAIN][SWITCH_DOMAIN]:
|
|
||||||
tasks += [forward_unload(entry, SWITCH_DOMAIN)]
|
|
||||||
|
|
||||||
hass.data[DOMAIN].clear()
|
hass.data[DOMAIN].clear()
|
||||||
|
|
||||||
return all(await asyncio.gather(*tasks))
|
return await hass.config_entries.async_unload_platforms(entry, platforms_to_unload)
|
||||||
|
|
||||||
|
|
||||||
def refresh_system(func):
|
def refresh_system(func):
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
"""The iCloud component."""
|
"""The iCloud component."""
|
||||||
import asyncio
|
|
||||||
|
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
|
@ -135,10 +134,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||||
|
|
||||||
hass.data[DOMAIN][entry.unique_id] = account
|
hass.data[DOMAIN][entry.unique_id] = account
|
||||||
|
|
||||||
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)
|
|
||||||
)
|
|
||||||
|
|
||||||
def play_sound(service: ServiceDataType) -> None:
|
def play_sound(service: ServiceDataType) -> None:
|
||||||
"""Play sound on the device."""
|
"""Play sound on the device."""
|
||||||
|
@ -224,15 +220,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||||
|
|
||||||
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.data[CONF_USERNAME])
|
hass.data[DOMAIN].pop(entry.data[CONF_USERNAME])
|
||||||
|
|
||||||
return unload_ok
|
return unload_ok
|
||||||
|
|
|
@ -4,16 +4,15 @@ from .const import DOMAIN # noqa: F401
|
||||||
|
|
||||||
DEFAULT_NAME = "ipma"
|
DEFAULT_NAME = "ipma"
|
||||||
|
|
||||||
|
PLATFORMS = ["weather"]
|
||||||
|
|
||||||
async def async_setup_entry(hass, config_entry):
|
|
||||||
|
async def async_setup_entry(hass, entry):
|
||||||
"""Set up IPMA station as config entry."""
|
"""Set up IPMA station as config entry."""
|
||||||
hass.async_create_task(
|
hass.config_entries.async_setup_platforms(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, entry):
|
||||||
"""Unload a config entry."""
|
"""Unload a config entry."""
|
||||||
await hass.config_entries.async_forward_entry_unload(config_entry, "weather")
|
return await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
|
||||||
return True
|
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
"""The Internet Printing Protocol (IPP) integration."""
|
"""The Internet Printing Protocol (IPP) 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
|
||||||
|
@ -58,28 +57,16 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||||
|
|
||||||
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) -> 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:
|
||||||
hass.data[DOMAIN].pop(entry.entry_id)
|
hass.data[DOMAIN].pop(entry.entry_id)
|
||||||
|
|
||||||
return unload_ok
|
return unload_ok
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -85,28 +85,16 @@ async def async_setup_entry(hass, entry):
|
||||||
|
|
||||||
await asyncio.gather(*init_data_update_tasks)
|
await asyncio.gather(*init_data_update_tasks)
|
||||||
|
|
||||||
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, entry):
|
async def async_unload_entry(hass, entry):
|
||||||
"""Unload an OpenUV config entry."""
|
"""Unload an OpenUV 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][DATA_COORDINATOR].pop(entry.entry_id)
|
hass.data[DOMAIN][DATA_COORDINATOR].pop(entry.entry_id)
|
||||||
|
|
||||||
return unload_ok
|
return unload_ok
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,7 @@ from .const import (
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
PLATFORMS = ["sensor"]
|
||||||
|
|
||||||
CONFIG_SCHEMA = vol.Schema(
|
CONFIG_SCHEMA = vol.Schema(
|
||||||
{
|
{
|
||||||
|
@ -63,9 +64,7 @@ async def async_unload_entry(hass, config_entry):
|
||||||
if hass.data[DOMAIN].event_unsub:
|
if hass.data[DOMAIN].event_unsub:
|
||||||
hass.data[DOMAIN].event_unsub()
|
hass.data[DOMAIN].event_unsub()
|
||||||
hass.data.pop(DOMAIN)
|
hass.data.pop(DOMAIN)
|
||||||
await hass.config_entries.async_forward_entry_unload(config_entry, "sensor")
|
return await hass.config_entries.async_unload_platforms(config_entry, PLATFORMS)
|
||||||
|
|
||||||
return True
|
|
||||||
|
|
||||||
|
|
||||||
class IslamicPrayerClient:
|
class IslamicPrayerClient:
|
||||||
|
@ -180,11 +179,7 @@ class IslamicPrayerClient:
|
||||||
await self.async_update()
|
await self.async_update()
|
||||||
self.config_entry.add_update_listener(self.async_options_updated)
|
self.config_entry.add_update_listener(self.async_options_updated)
|
||||||
|
|
||||||
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, "sensor"
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
"""Support the ISY-994 controllers."""
|
"""Support the ISY-994 controllers."""
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import asyncio
|
|
||||||
from functools import partial
|
from functools import partial
|
||||||
from urllib.parse import urlparse
|
from urllib.parse import urlparse
|
||||||
|
|
||||||
|
@ -177,10 +176,7 @@ async def async_setup_entry(
|
||||||
await _async_get_or_create_isy_device_in_registry(hass, entry, isy)
|
await _async_get_or_create_isy_device_in_registry(hass, entry, isy)
|
||||||
|
|
||||||
# Load platforms for the devices in the ISY controller that we support.
|
# Load platforms for the devices in the ISY controller that we support.
|
||||||
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)
|
|
||||||
)
|
|
||||||
|
|
||||||
def _start_auto_update() -> None:
|
def _start_auto_update() -> None:
|
||||||
"""Start isy auto update."""
|
"""Start isy auto update."""
|
||||||
|
@ -245,14 +241,7 @@ async def async_unload_entry(
|
||||||
hass: HomeAssistant, entry: config_entries.ConfigEntry
|
hass: HomeAssistant, entry: config_entries.ConfigEntry
|
||||||
) -> bool:
|
) -> 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
|
|
||||||
]
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
hass_isy_data = hass.data[DOMAIN][entry.entry_id]
|
hass_isy_data = hass.data[DOMAIN][entry.entry_id]
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,8 @@ from homeassistant.helpers.typing import ConfigType
|
||||||
from .const import DATA_CONFIG, IZONE
|
from .const import DATA_CONFIG, IZONE
|
||||||
from .discovery import async_start_discovery_service, async_stop_discovery_service
|
from .discovery import async_start_discovery_service, async_stop_discovery_service
|
||||||
|
|
||||||
|
PLATFORMS = ["climate"]
|
||||||
|
|
||||||
CONFIG_SCHEMA = vol.Schema(
|
CONFIG_SCHEMA = vol.Schema(
|
||||||
{
|
{
|
||||||
IZONE: vol.Schema(
|
IZONE: vol.Schema(
|
||||||
|
@ -45,15 +47,11 @@ async def async_setup(hass: HomeAssistant, config: ConfigType):
|
||||||
async def async_setup_entry(hass, entry):
|
async def async_setup_entry(hass, entry):
|
||||||
"""Set up from a config entry."""
|
"""Set up from a config entry."""
|
||||||
await async_start_discovery_service(hass)
|
await async_start_discovery_service(hass)
|
||||||
|
hass.config_entries.async_setup_platforms(entry, PLATFORMS)
|
||||||
hass.async_create_task(
|
|
||||||
hass.config_entries.async_forward_entry_setup(entry, "climate")
|
|
||||||
)
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
async def async_unload_entry(hass, entry):
|
async def async_unload_entry(hass, entry):
|
||||||
"""Unload the config entry and stop discovery process."""
|
"""Unload the config entry and stop discovery process."""
|
||||||
await async_stop_discovery_service(hass)
|
await async_stop_discovery_service(hass)
|
||||||
await hass.config_entries.async_forward_entry_unload(entry, "climate")
|
return await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
|
||||||
return True
|
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
"""The JuiceNet integration."""
|
"""The JuiceNet integration."""
|
||||||
import asyncio
|
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
@ -91,25 +90,14 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
|
||||||
|
|
||||||
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)
|
||||||
|
|
||||||
return unload_ok
|
return unload_ok
|
||||||
|
|
|
@ -82,15 +82,7 @@ async def test_hap_setup_works():
|
||||||
assert await hap.async_setup()
|
assert await hap.async_setup()
|
||||||
|
|
||||||
assert hap.home is home
|
assert hap.home is home
|
||||||
assert len(hass.config_entries.async_forward_entry_setup.mock_calls) == 8
|
assert len(hass.config_entries.async_setup_platforms.mock_calls) == 1
|
||||||
assert hass.config_entries.async_forward_entry_setup.mock_calls[0][1] == (
|
|
||||||
entry,
|
|
||||||
"alarm_control_panel",
|
|
||||||
)
|
|
||||||
assert hass.config_entries.async_forward_entry_setup.mock_calls[1][1] == (
|
|
||||||
entry,
|
|
||||||
"binary_sensor",
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
async def test_hap_setup_connection_error():
|
async def test_hap_setup_connection_error():
|
||||||
|
|
|
@ -26,8 +26,6 @@ async def test_form(hass):
|
||||||
"huisbaasje.Huisbaasje.get_user_id",
|
"huisbaasje.Huisbaasje.get_user_id",
|
||||||
return_value="test-id",
|
return_value="test-id",
|
||||||
) as mock_get_user_id, patch(
|
) as mock_get_user_id, patch(
|
||||||
"homeassistant.components.huisbaasje.async_setup", return_value=True
|
|
||||||
) as mock_setup, patch(
|
|
||||||
"homeassistant.components.huisbaasje.async_setup_entry",
|
"homeassistant.components.huisbaasje.async_setup_entry",
|
||||||
return_value=True,
|
return_value=True,
|
||||||
) as mock_setup_entry:
|
) as mock_setup_entry:
|
||||||
|
@ -49,7 +47,6 @@ async def test_form(hass):
|
||||||
}
|
}
|
||||||
assert len(mock_authenticate.mock_calls) == 1
|
assert len(mock_authenticate.mock_calls) == 1
|
||||||
assert len(mock_get_user_id.mock_calls) == 1
|
assert len(mock_get_user_id.mock_calls) == 1
|
||||||
assert len(mock_setup.mock_calls) == 1
|
|
||||||
assert len(mock_setup_entry.mock_calls) == 1
|
assert len(mock_setup_entry.mock_calls) == 1
|
||||||
|
|
||||||
|
|
||||||
|
@ -139,8 +136,6 @@ async def test_form_entry_exists(hass):
|
||||||
with patch("huisbaasje.Huisbaasje.authenticate", return_value=None), patch(
|
with patch("huisbaasje.Huisbaasje.authenticate", return_value=None), patch(
|
||||||
"huisbaasje.Huisbaasje.get_user_id",
|
"huisbaasje.Huisbaasje.get_user_id",
|
||||||
return_value="test-id",
|
return_value="test-id",
|
||||||
), patch(
|
|
||||||
"homeassistant.components.huisbaasje.async_setup", return_value=True
|
|
||||||
), patch(
|
), patch(
|
||||||
"homeassistant.components.huisbaasje.async_setup_entry",
|
"homeassistant.components.huisbaasje.async_setup_entry",
|
||||||
return_value=True,
|
return_value=True,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue