mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Reduce config entry setup/unload boilerplate Q-S (#49778)
This commit is contained in:
parent
d2fd504442
commit
87420627a8
@ -1,5 +1,4 @@
|
|||||||
"""Integration with the Rachio Iro sprinkler system controller."""
|
"""Integration with the Rachio Iro sprinkler system controller."""
|
||||||
import asyncio
|
|
||||||
import logging
|
import logging
|
||||||
import secrets
|
import secrets
|
||||||
|
|
||||||
@ -28,18 +27,9 @@ CONFIG_SCHEMA = cv.deprecated(DOMAIN)
|
|||||||
|
|
||||||
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
|
||||||
|
|
||||||
|
|
||||||
@ -96,9 +86,6 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
|
|||||||
hass.data[DOMAIN][entry.entry_id] = person
|
hass.data[DOMAIN][entry.entry_id] = person
|
||||||
async_register_webhook(hass, webhook_id, entry.entry_id)
|
async_register_webhook(hass, webhook_id, entry.entry_id)
|
||||||
|
|
||||||
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
|
||||||
|
@ -155,10 +155,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||||||
|
|
||||||
await asyncio.gather(*controller_init_tasks)
|
await asyncio.gather(*controller_init_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)
|
|
||||||
)
|
|
||||||
|
|
||||||
hass.data[DOMAIN][DATA_LISTENER] = entry.add_update_listener(async_reload_entry)
|
hass.data[DOMAIN][DATA_LISTENER] = entry.add_update_listener(async_reload_entry)
|
||||||
|
|
||||||
@ -167,14 +164,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 an RainMachine config entry."""
|
"""Unload an RainMachine 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)
|
||||||
cancel_listener = hass.data[DOMAIN][DATA_LISTENER].pop(entry.entry_id)
|
cancel_listener = hass.data[DOMAIN][DATA_LISTENER].pop(entry.entry_id)
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
"""The ReCollect Waste integration."""
|
"""The ReCollect Waste integration."""
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import asyncio
|
|
||||||
from datetime import date, timedelta
|
from datetime import date, timedelta
|
||||||
|
|
||||||
from aiorecollect.client import Client, PickupEvent
|
from aiorecollect.client import Client, PickupEvent
|
||||||
@ -58,10 +57,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||||||
|
|
||||||
hass.data[DOMAIN][DATA_COORDINATOR][entry.entry_id] = coordinator
|
hass.data[DOMAIN][DATA_COORDINATOR][entry.entry_id] = 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)
|
|
||||||
)
|
|
||||||
|
|
||||||
hass.data[DOMAIN][DATA_LISTENER][entry.entry_id] = entry.add_update_listener(
|
hass.data[DOMAIN][DATA_LISTENER][entry.entry_id] = entry.add_update_listener(
|
||||||
async_reload_entry
|
async_reload_entry
|
||||||
@ -77,14 +73,7 @@ async def async_reload_entry(hass: HomeAssistant, entry: ConfigEntry):
|
|||||||
|
|
||||||
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||||
"""Unload an RainMachine config entry."""
|
"""Unload an RainMachine 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)
|
||||||
cancel_listener = hass.data[DOMAIN][DATA_LISTENER].pop(entry.entry_id)
|
cancel_listener = hass.data[DOMAIN][DATA_LISTENER].pop(entry.entry_id)
|
||||||
|
@ -202,24 +202,14 @@ async def async_setup_entry(hass, entry: config_entries.ConfigEntry):
|
|||||||
)
|
)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
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: config_entries.ConfigEntry):
|
async def async_unload_entry(hass, entry: config_entries.ConfigEntry):
|
||||||
"""Unload RFXtrx component."""
|
"""Unload RFXtrx component."""
|
||||||
if not all(
|
if not 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 False
|
return False
|
||||||
|
|
||||||
hass.services.async_remove(DOMAIN, SERVICE_SEND)
|
hass.services.async_remove(DOMAIN, SERVICE_SEND)
|
||||||
|
@ -100,10 +100,7 @@ async def async_setup_entry(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)
|
|
||||||
)
|
|
||||||
|
|
||||||
if hass.services.has_service(DOMAIN, "update"):
|
if hass.services.has_service(DOMAIN, "update"):
|
||||||
return True
|
return True
|
||||||
@ -124,15 +121,7 @@ async def async_setup_entry(hass, entry):
|
|||||||
|
|
||||||
async def async_unload_entry(hass, entry):
|
async def async_unload_entry(hass, entry):
|
||||||
"""Unload Ring entry."""
|
"""Unload Ring entry."""
|
||||||
unload_ok = all(
|
if not 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:
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
hass.data[DOMAIN].pop(entry.entry_id)
|
hass.data[DOMAIN].pop(entry.entry_id)
|
||||||
|
@ -71,15 +71,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
|
|
||||||
]
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
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 Rituals Perfume Genie integration."""
|
"""The Rituals Perfume Genie integration."""
|
||||||
import asyncio
|
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
@ -48,24 +47,14 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
|
|||||||
hass.data[DOMAIN][entry.entry_id][DEVICES][hublot] = device
|
hass.data[DOMAIN][entry.entry_id][DEVICES][hublot] = device
|
||||||
hass.data[DOMAIN][entry.entry_id][COORDINATORS][hublot] = coordinator
|
hass.data[DOMAIN][entry.entry_id][COORDINATORS][hublot] = 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)
|
||||||
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
"""Support for Roku."""
|
"""Support for Roku."""
|
||||||
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
|
||||||
@ -49,28 +48,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
|
||||||
|
|
||||||
|
|
||||||
|
@ -68,10 +68,7 @@ async def async_setup_entry(hass, config_entry):
|
|||||||
CANCEL_STOP: cancel_stop,
|
CANCEL_STOP: cancel_stop,
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
|
||||||
)
|
|
||||||
|
|
||||||
if not config_entry.update_listeners:
|
if not config_entry.update_listeners:
|
||||||
config_entry.add_update_listener(async_update_options)
|
config_entry.add_update_listener(async_update_options)
|
||||||
@ -119,13 +116,8 @@ async def async_update_options(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."""
|
||||||
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:
|
||||||
domain_data = hass.data[DOMAIN][config_entry.entry_id]
|
domain_data = hass.data[DOMAIN][config_entry.entry_id]
|
||||||
|
@ -2,15 +2,15 @@
|
|||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
|
|
||||||
|
PLATFORMS = ["binary_sensor"]
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
|
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
|
||||||
"""Set up Raspberry Pi Power Supply Checker from a config entry."""
|
"""Set up Raspberry Pi Power Supply Checker from a config entry."""
|
||||||
hass.async_create_task(
|
hass.config_entries.async_setup_platforms(entry, PLATFORMS)
|
||||||
hass.config_entries.async_forward_entry_setup(entry, "binary_sensor")
|
|
||||||
)
|
|
||||||
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, "binary_sensor")
|
return await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
"""The Ruckus Unleashed integration."""
|
"""The Ruckus Unleashed integration."""
|
||||||
import asyncio
|
|
||||||
|
|
||||||
from pyruckus import Ruckus
|
from pyruckus import Ruckus
|
||||||
|
|
||||||
@ -64,24 +63,14 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||||||
UNDO_UPDATE_LISTENERS: [],
|
UNDO_UPDATE_LISTENERS: [],
|
||||||
}
|
}
|
||||||
|
|
||||||
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:
|
||||||
for listener in hass.data[DOMAIN][entry.entry_id][UNDO_UPDATE_LISTENERS]:
|
for listener in hass.data[DOMAIN][entry.entry_id][UNDO_UPDATE_LISTENERS]:
|
||||||
listener()
|
listener()
|
||||||
|
@ -77,24 +77,14 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
|
|||||||
"listener": entry.add_update_listener(async_update_listener),
|
"listener": entry.add_update_listener(async_update_listener),
|
||||||
}
|
}
|
||||||
|
|
||||||
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(
|
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
|
|
||||||
]
|
|
||||||
)
|
|
||||||
)
|
|
||||||
hass.data[DOMAIN][entry.entry_id]["listener"]()
|
hass.data[DOMAIN][entry.entry_id]["listener"]()
|
||||||
if unload_ok:
|
if unload_ok:
|
||||||
hass.data[DOMAIN].pop(entry.entry_id)
|
hass.data[DOMAIN].pop(entry.entry_id)
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
"""Support for monitoring a Sense energy sensor."""
|
"""Support for monitoring a Sense energy sensor."""
|
||||||
import asyncio
|
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
@ -146,10 +145,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
|
|||||||
SENSE_DISCOVERED_DEVICES_DATA: sense_discovered_devices,
|
SENSE_DISCOVERED_DEVICES_DATA: sense_discovered_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)
|
|
||||||
)
|
|
||||||
|
|
||||||
async def async_sense_update(_):
|
async def async_sense_update(_):
|
||||||
"""Retrieve latest state."""
|
"""Retrieve latest state."""
|
||||||
@ -181,14 +177,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
|
|
||||||
]
|
|
||||||
)
|
|
||||||
)
|
|
||||||
data = hass.data[DOMAIN][entry.entry_id]
|
data = hass.data[DOMAIN][entry.entry_id]
|
||||||
data[EVENT_STOP_REMOVE]()
|
data[EVENT_STOP_REMOVE]()
|
||||||
data[TRACK_TIME_REMOVE]()
|
data[TRACK_TIME_REMOVE]()
|
||||||
|
@ -63,10 +63,7 @@ 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
|
||||||
|
|
||||||
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
|
||||||
|
|
||||||
@ -87,13 +84,8 @@ async def async_update_options(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."""
|
||||||
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:
|
||||||
domain_data = hass.data[DOMAIN][config_entry.entry_id]
|
domain_data = hass.data[DOMAIN][config_entry.entry_id]
|
||||||
|
@ -137,10 +137,7 @@ async def async_device_setup(
|
|||||||
] = ShellyDeviceRestWrapper(hass, device)
|
] = ShellyDeviceRestWrapper(hass, device)
|
||||||
platforms = PLATFORMS
|
platforms = 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)
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class ShellyDeviceWrapper(update_coordinator.DataUpdateCoordinator):
|
class ShellyDeviceWrapper(update_coordinator.DataUpdateCoordinator):
|
||||||
@ -334,14 +331,7 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry):
|
|||||||
hass.data[DOMAIN][DATA_CONFIG_ENTRY][entry.entry_id][REST] = None
|
hass.data[DOMAIN][DATA_CONFIG_ENTRY][entry.entry_id][REST] = None
|
||||||
platforms = PLATFORMS
|
platforms = PLATFORMS
|
||||||
|
|
||||||
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_CONFIG_ENTRY][entry.entry_id][COAP].shutdown()
|
hass.data[DOMAIN][DATA_CONFIG_ENTRY][entry.entry_id][COAP].shutdown()
|
||||||
hass.data[DOMAIN][DATA_CONFIG_ENTRY].pop(entry.entry_id)
|
hass.data[DOMAIN][DATA_CONFIG_ENTRY].pop(entry.entry_id)
|
||||||
|
@ -224,10 +224,7 @@ async def async_setup_entry(hass, config_entry): # noqa: C901
|
|||||||
)
|
)
|
||||||
await simplisafe.async_init()
|
await simplisafe.async_init()
|
||||||
|
|
||||||
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)
|
|
||||||
)
|
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
def verify_system_exists(coro):
|
def verify_system_exists(coro):
|
||||||
@ -329,14 +326,7 @@ async def async_setup_entry(hass, config_entry): # noqa: C901
|
|||||||
|
|
||||||
async def async_unload_entry(hass, entry):
|
async def async_unload_entry(hass, entry):
|
||||||
"""Unload a SimpliSafe config entry."""
|
"""Unload a SimpliSafe 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)
|
||||||
for remove_listener in hass.data[DOMAIN][DATA_LISTENER].pop(entry.entry_id):
|
for remove_listener in hass.data[DOMAIN][DATA_LISTENER].pop(entry.entry_id):
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
"""The sma integration."""
|
"""The sma integration."""
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import asyncio
|
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
@ -187,24 +186,14 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||||||
PYSMA_REMOVE_LISTENER: remove_stop_listener,
|
PYSMA_REMOVE_LISTENER: remove_stop_listener,
|
||||||
}
|
}
|
||||||
|
|
||||||
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:
|
||||||
data = hass.data[DOMAIN].pop(entry.entry_id)
|
data = hass.data[DOMAIN].pop(entry.entry_id)
|
||||||
await data[PYSMA_OBJECT].close_session()
|
await data[PYSMA_OBJECT].close_session()
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
"""The Smappee integration."""
|
"""The Smappee integration."""
|
||||||
import asyncio
|
|
||||||
|
|
||||||
from pysmappee import Smappee, helper, mqtt
|
from pysmappee import Smappee, helper, mqtt
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
@ -105,28 +104,16 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
|
|||||||
|
|
||||||
hass.data[DOMAIN][entry.entry_id] = SmappeeBase(hass, smappee)
|
hass.data[DOMAIN][entry.entry_id] = SmappeeBase(hass, smappee)
|
||||||
|
|
||||||
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, None)
|
hass.data[DOMAIN].pop(entry.entry_id, None)
|
||||||
|
|
||||||
return unload_ok
|
return unload_ok
|
||||||
|
|
||||||
|
|
||||||
|
@ -78,10 +78,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
|
|||||||
|
|
||||||
asyncio.create_task(coordinator.async_refresh())
|
asyncio.create_task(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(entry, platform)
|
|
||||||
)
|
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@ -114,14 +111,7 @@ class SmartMeterTexasData:
|
|||||||
|
|
||||||
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 @@
|
|||||||
"""Support for SmartHab device integration."""
|
"""Support for SmartHab device integration."""
|
||||||
import asyncio
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
import pysmarthab
|
import pysmarthab
|
||||||
@ -69,27 +68,14 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
|
|||||||
# Pass hub object to child platforms
|
# Pass hub object to child platforms
|
||||||
hass.data[DOMAIN][entry.entry_id] = {DATA_HUB: hub}
|
hass.data[DOMAIN][entry.entry_id] = {DATA_HUB: 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 config entry from SmartHab integration."""
|
"""Unload config entry from SmartHab integration."""
|
||||||
|
unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
|
||||||
result = all(
|
if unload_ok:
|
||||||
await asyncio.gather(
|
|
||||||
*[
|
|
||||||
hass.config_entries.async_forward_entry_unload(entry, platform)
|
|
||||||
for platform in PLATFORMS
|
|
||||||
]
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
if result:
|
|
||||||
hass.data[DOMAIN].pop(entry.entry_id)
|
hass.data[DOMAIN].pop(entry.entry_id)
|
||||||
|
return unload_ok
|
||||||
return result
|
|
||||||
|
@ -189,10 +189,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
|
|||||||
)
|
)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
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
|
||||||
|
|
||||||
|
|
||||||
@ -217,11 +214,7 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry):
|
|||||||
if broker:
|
if broker:
|
||||||
broker.disconnect()
|
broker.disconnect()
|
||||||
|
|
||||||
tasks = [
|
return await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
|
||||||
hass.config_entries.async_forward_entry_unload(entry, platform)
|
|
||||||
for platform in PLATFORMS
|
|
||||||
]
|
|
||||||
return all(await asyncio.gather(*tasks))
|
|
||||||
|
|
||||||
|
|
||||||
async def async_remove_entry(hass: HomeAssistant, entry: ConfigEntry) -> None:
|
async def async_remove_entry(hass: HomeAssistant, entry: ConfigEntry) -> None:
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
"""SmartTub integration."""
|
"""SmartTub integration."""
|
||||||
import asyncio
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from .const import DOMAIN, SMARTTUB_CONTROLLER
|
from .const import DOMAIN, SMARTTUB_CONTROLLER
|
||||||
@ -22,26 +21,14 @@ async def async_setup_entry(hass, entry):
|
|||||||
if not await controller.async_setup_entry(entry):
|
if not await controller.async_setup_entry(entry):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
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):
|
||||||
"""Remove a smarttub config entry."""
|
"""Remove a smarttub config entry."""
|
||||||
if not all(
|
unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
|
||||||
await asyncio.gather(
|
if unload_ok:
|
||||||
*[
|
hass.data[DOMAIN].pop(entry.entry_id)
|
||||||
hass.config_entries.async_forward_entry_unload(entry, platform)
|
return unload_ok
|
||||||
for platform in PLATFORMS
|
|
||||||
]
|
|
||||||
)
|
|
||||||
):
|
|
||||||
return False
|
|
||||||
|
|
||||||
hass.data[DOMAIN].pop(entry.entry_id)
|
|
||||||
|
|
||||||
return True
|
|
||||||
|
@ -8,16 +8,15 @@ from .const import DOMAIN # noqa: F401
|
|||||||
|
|
||||||
DEFAULT_NAME = "smhi"
|
DEFAULT_NAME = "smhi"
|
||||||
|
|
||||||
|
PLATFORMS = ["weather"]
|
||||||
|
|
||||||
async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> bool:
|
|
||||||
|
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||||
"""Set up SMHI forecast as config entry."""
|
"""Set up SMHI forecast 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: HomeAssistant, config_entry: ConfigEntry) -> bool:
|
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||||
"""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,5 +1,4 @@
|
|||||||
"""The sms component."""
|
"""The sms component."""
|
||||||
import asyncio
|
|
||||||
|
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
@ -46,25 +45,14 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
|
|||||||
if not gateway:
|
if not gateway:
|
||||||
return False
|
return False
|
||||||
hass.data[DOMAIN][SMS_GATEWAY] = gateway
|
hass.data[DOMAIN][SMS_GATEWAY] = gateway
|
||||||
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:
|
||||||
gateway = hass.data[DOMAIN].pop(SMS_GATEWAY)
|
gateway = hass.data[DOMAIN].pop(SMS_GATEWAY)
|
||||||
await gateway.terminate_async()
|
await gateway.terminate_async()
|
||||||
|
@ -2,15 +2,15 @@
|
|||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
|
|
||||||
|
PLATFORMS = ["sensor"]
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
|
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
|
||||||
"""Set up a config entry for solarlog."""
|
"""Set up a config entry for solarlog."""
|
||||||
hass.async_create_task(
|
hass.config_entries.async_setup_platforms(entry, PLATFORMS)
|
||||||
hass.config_entries.async_forward_entry_setup(entry, "sensor")
|
|
||||||
)
|
|
||||||
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, "sensor")
|
return await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
"""Support for Soma Smartshades."""
|
"""Support for Soma Smartshades."""
|
||||||
import asyncio
|
|
||||||
|
|
||||||
from api.soma_api import SomaApi
|
from api.soma_api import SomaApi
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
@ -50,26 +49,14 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
|
|||||||
devices = await hass.async_add_executor_job(hass.data[DOMAIN][API].list_devices)
|
devices = await hass.async_add_executor_job(hass.data[DOMAIN][API].list_devices)
|
||||||
hass.data[DOMAIN][DEVICES] = devices["shades"]
|
hass.data[DOMAIN][DEVICES] = devices["shades"]
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
|
|
||||||
class SomaEntity(Entity):
|
class SomaEntity(Entity):
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
"""Support for Somfy hubs."""
|
"""Support for Somfy hubs."""
|
||||||
from abc import abstractmethod
|
from abc import abstractmethod
|
||||||
import asyncio
|
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
@ -135,10 +134,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
|
|||||||
model=hub.type,
|
model=hub.type,
|
||||||
)
|
)
|
||||||
|
|
||||||
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
|
||||||
|
|
||||||
@ -146,13 +142,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."""
|
||||||
hass.data[DOMAIN].pop(API, None)
|
hass.data[DOMAIN].pop(API, None)
|
||||||
await asyncio.gather(
|
return await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
|
||||||
*[
|
|
||||||
hass.config_entries.async_forward_entry_unload(entry, platform)
|
|
||||||
for platform in PLATFORMS
|
|
||||||
]
|
|
||||||
)
|
|
||||||
return True
|
|
||||||
|
|
||||||
|
|
||||||
class SomfyEntity(CoordinatorEntity, Entity):
|
class SomfyEntity(CoordinatorEntity, Entity):
|
||||||
|
@ -121,10 +121,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
|
|||||||
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
|
||||||
|
|
||||||
@ -179,14 +176,7 @@ def _async_migrate_entity_config(
|
|||||||
|
|
||||||
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,7 +1,6 @@
|
|||||||
"""The Sonarr component."""
|
"""The Sonarr component."""
|
||||||
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
|
||||||
@ -81,24 +80,14 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||||||
DATA_UNDO_UPDATE_LISTENER: undo_listener,
|
DATA_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
|
||||||
|
|
||||||
|
|
||||||
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
|
|
||||||
]
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
hass.data[DOMAIN][entry.entry_id][DATA_UNDO_UPDATE_LISTENER]()
|
hass.data[DOMAIN][entry.entry_id][DATA_UNDO_UPDATE_LISTENER]()
|
||||||
|
|
||||||
|
@ -19,6 +19,8 @@ CONFIG_SCHEMA = vol.Schema(
|
|||||||
extra=vol.ALLOW_EXTRA,
|
extra=vol.ALLOW_EXTRA,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
PLATFORMS = ["media_player"]
|
||||||
|
|
||||||
|
|
||||||
async def async_setup(hass: HomeAssistant, config: OrderedDict) -> bool:
|
async def async_setup(hass: HomeAssistant, config: OrderedDict) -> bool:
|
||||||
"""Set up songpal environment."""
|
"""Set up songpal environment."""
|
||||||
@ -38,12 +40,10 @@ async def async_setup(hass: HomeAssistant, config: OrderedDict) -> bool:
|
|||||||
|
|
||||||
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||||
"""Set up songpal media player."""
|
"""Set up songpal media player."""
|
||||||
hass.async_create_task(
|
hass.config_entries.async_setup_platforms(entry, PLATFORMS)
|
||||||
hass.config_entries.async_forward_entry_setup(entry, "media_player")
|
|
||||||
)
|
|
||||||
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 songpal media player."""
|
"""Unload songpal media player."""
|
||||||
return await hass.config_entries.async_forward_entry_unload(entry, "media_player")
|
return await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
|
||||||
|
@ -46,6 +46,8 @@ CONFIG_SCHEMA = vol.Schema(
|
|||||||
extra=vol.ALLOW_EXTRA,
|
extra=vol.ALLOW_EXTRA,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
PLATFORMS = ["sensor"]
|
||||||
|
|
||||||
|
|
||||||
def server_id_valid(server_id):
|
def server_id_valid(server_id):
|
||||||
"""Check if server_id is valid."""
|
"""Check if server_id is valid."""
|
||||||
@ -96,9 +98,7 @@ async def async_setup_entry(hass, config_entry):
|
|||||||
|
|
||||||
hass.data[DOMAIN] = coordinator
|
hass.data[DOMAIN] = coordinator
|
||||||
|
|
||||||
hass.async_create_task(
|
hass.config_entries.async_setup_platforms(config_entry, PLATFORMS)
|
||||||
hass.config_entries.async_forward_entry_setup(config_entry, "sensor")
|
|
||||||
)
|
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@ -109,11 +109,12 @@ async def async_unload_entry(hass, config_entry):
|
|||||||
|
|
||||||
hass.data[DOMAIN].async_unload()
|
hass.data[DOMAIN].async_unload()
|
||||||
|
|
||||||
await hass.config_entries.async_forward_entry_unload(config_entry, "sensor")
|
unload_ok = await hass.config_entries.async_unload_platforms(
|
||||||
|
config_entry, PLATFORMS
|
||||||
hass.data.pop(DOMAIN)
|
)
|
||||||
|
if unload_ok:
|
||||||
return True
|
hass.data.pop(DOMAIN)
|
||||||
|
return unload_ok
|
||||||
|
|
||||||
|
|
||||||
class SpeedTestDataCoordinator(DataUpdateCoordinator):
|
class SpeedTestDataCoordinator(DataUpdateCoordinator):
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
"""Support for Spider Smart devices."""
|
"""Support for Spider Smart devices."""
|
||||||
import asyncio
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from spiderpy.spiderapi import SpiderApi, SpiderApiException, UnauthorizedException
|
from spiderpy.spiderapi import SpiderApi, SpiderApiException, UnauthorizedException
|
||||||
@ -66,25 +65,14 @@ async def async_setup_entry(hass, entry):
|
|||||||
|
|
||||||
hass.data[DOMAIN][entry.entry_id] = api
|
hass.data[DOMAIN][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(entry, platform)
|
|
||||||
)
|
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
async def async_unload_entry(hass, entry):
|
async def async_unload_entry(hass, entry):
|
||||||
"""Unload Spider entry."""
|
"""Unload Spider 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
|
||||||
|
|
||||||
|
@ -37,6 +37,8 @@ CONFIG_SCHEMA = vol.Schema(
|
|||||||
extra=vol.ALLOW_EXTRA,
|
extra=vol.ALLOW_EXTRA,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
PLATFORMS = [MEDIA_PLAYER_DOMAIN]
|
||||||
|
|
||||||
|
|
||||||
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
||||||
"""Set up the Spotify integration."""
|
"""Set up the Spotify integration."""
|
||||||
@ -86,20 +88,18 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||||||
if not set(session.token["scope"].split(" ")).issuperset(SPOTIFY_SCOPES):
|
if not set(session.token["scope"].split(" ")).issuperset(SPOTIFY_SCOPES):
|
||||||
raise ConfigEntryAuthFailed
|
raise ConfigEntryAuthFailed
|
||||||
|
|
||||||
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
|
||||||
|
|
||||||
|
|
||||||
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||||
"""Unload Spotify config entry."""
|
"""Unload Spotify config entry."""
|
||||||
# Unload entities for this entry/device.
|
# Unload entities for this entry/device.
|
||||||
await hass.config_entries.async_forward_entry_unload(entry, MEDIA_PLAYER_DOMAIN)
|
unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
|
||||||
|
|
||||||
# Cleanup
|
# Cleanup
|
||||||
del hass.data[DOMAIN][entry.entry_id]
|
del hass.data[DOMAIN][entry.entry_id]
|
||||||
if not hass.data[DOMAIN]:
|
if not hass.data[DOMAIN]:
|
||||||
del hass.data[DOMAIN]
|
del hass.data[DOMAIN]
|
||||||
|
|
||||||
return True
|
return unload_ok
|
||||||
|
@ -10,12 +10,12 @@ from .const import DISCOVERY_TASK, DOMAIN, PLAYER_DISCOVERY_UNSUB
|
|||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
PLATFORMS = [MP_DOMAIN]
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
|
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
|
||||||
"""Set up Logitech Squeezebox from a config entry."""
|
"""Set up Logitech Squeezebox from a config entry."""
|
||||||
hass.async_create_task(
|
hass.config_entries.async_setup_platforms(entry, PLATFORMS)
|
||||||
hass.config_entries.async_forward_entry_setup(entry, MP_DOMAIN)
|
|
||||||
)
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
@ -34,4 +34,4 @@ async def async_unload_entry(hass, entry):
|
|||||||
hass.data[DOMAIN][DISCOVERY_TASK].cancel()
|
hass.data[DOMAIN][DISCOVERY_TASK].cancel()
|
||||||
hass.data[DOMAIN].pop(DISCOVERY_TASK)
|
hass.data[DOMAIN].pop(DISCOVERY_TASK)
|
||||||
|
|
||||||
return await hass.config_entries.async_forward_entry_unload(entry, MP_DOMAIN)
|
return await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
|
||||||
|
@ -30,9 +30,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
|
|||||||
_LOGGER.error("Unable to connect to Srp Energy: %s", str(ex))
|
_LOGGER.error("Unable to connect to Srp Energy: %s", str(ex))
|
||||||
raise ConfigEntryNotReady from ex
|
raise ConfigEntryNotReady from ex
|
||||||
|
|
||||||
hass.async_create_task(
|
hass.config_entries.async_setup_platforms(entry, PLATFORMS)
|
||||||
hass.config_entries.async_forward_entry_setup(entry, "sensor")
|
|
||||||
)
|
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@ -42,6 +40,4 @@ async def async_unload_entry(hass: HomeAssistant, config_entry: ConfigEntry):
|
|||||||
# unload srp client
|
# unload srp client
|
||||||
hass.data[SRP_ENERGY_DOMAIN] = None
|
hass.data[SRP_ENERGY_DOMAIN] = None
|
||||||
# Remove config entry
|
# Remove config entry
|
||||||
await hass.config_entries.async_forward_entry_unload(config_entry, "sensor")
|
return await hass.config_entries.async_unload_platforms(config_entry, PLATFORMS)
|
||||||
|
|
||||||
return True
|
|
||||||
|
@ -37,10 +37,7 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> b
|
|||||||
config_entry_id=config_entry.entry_id, **account.device_info(device)
|
config_entry_id=config_entry.entry_id, **account.device_info(device)
|
||||||
)
|
)
|
||||||
|
|
||||||
for domain in PLATFORMS:
|
hass.config_entries.async_setup_platforms(config_entry, PLATFORMS)
|
||||||
hass.async_create_task(
|
|
||||||
hass.config_entries.async_forward_entry_setup(config_entry, domain)
|
|
||||||
)
|
|
||||||
|
|
||||||
async def async_set_scan_interval(call):
|
async def async_set_scan_interval(call):
|
||||||
"""Set scan interval."""
|
"""Set scan interval."""
|
||||||
@ -85,7 +82,9 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> b
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
config_entry.add_update_listener(async_options_updated)
|
config_entry.async_on_unload(
|
||||||
|
config_entry.add_update_listener(async_options_updated)
|
||||||
|
)
|
||||||
await async_options_updated(hass, config_entry)
|
await async_options_updated(hass, config_entry)
|
||||||
|
|
||||||
return True
|
return True
|
||||||
@ -93,12 +92,13 @@ 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 a config entry."""
|
"""Unload a config entry."""
|
||||||
for domain in PLATFORMS:
|
unload_ok = await hass.config_entries.async_unload_platforms(
|
||||||
await hass.config_entries.async_forward_entry_unload(config_entry, domain)
|
config_entry, PLATFORMS
|
||||||
|
)
|
||||||
|
|
||||||
account: StarlineAccount = hass.data[DOMAIN][config_entry.entry_id]
|
account: StarlineAccount = hass.data[DOMAIN][config_entry.entry_id]
|
||||||
account.unload()
|
account.unload()
|
||||||
return True
|
return unload_ok
|
||||||
|
|
||||||
|
|
||||||
async def async_options_updated(hass: HomeAssistant, config_entry: ConfigEntry) -> None:
|
async def async_options_updated(hass: HomeAssistant, config_entry: ConfigEntry) -> None:
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
"""The Subaru integration."""
|
"""The Subaru integration."""
|
||||||
import asyncio
|
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
import logging
|
import logging
|
||||||
import time
|
import time
|
||||||
@ -89,24 +88,14 @@ async def async_setup_entry(hass, entry):
|
|||||||
ENTRY_VEHICLES: vehicle_info,
|
ENTRY_VEHICLES: vehicle_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
|
||||||
|
|
||||||
|
|
||||||
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
|
||||||
|
@ -16,6 +16,8 @@ from .const import DOMAIN
|
|||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
PLATFORMS = [SENSOR_DOMAIN]
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||||
"""Set up config entry."""
|
"""Set up config entry."""
|
||||||
@ -47,17 +49,15 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||||||
name=printer.hostname(),
|
name=printer.hostname(),
|
||||||
)
|
)
|
||||||
|
|
||||||
hass.async_create_task(
|
hass.config_entries.async_setup_platforms(entry, PLATFORMS)
|
||||||
hass.config_entries.async_forward_entry_setup(entry, SENSOR_DOMAIN)
|
|
||||||
)
|
|
||||||
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 the config entry."""
|
"""Unload the config entry."""
|
||||||
await hass.config_entries.async_forward_entry_unload(entry, SENSOR_DOMAIN)
|
unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
|
||||||
hass.data[DOMAIN].pop(entry.entry_id, None)
|
hass.data[DOMAIN].pop(entry.entry_id, None)
|
||||||
return True
|
return unload_ok
|
||||||
|
|
||||||
|
|
||||||
def device_identifiers(printer: SyncThru) -> set[tuple[str, str]]:
|
def device_identifiers(printer: SyncThru) -> set[tuple[str, str]]:
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
"""The Synology DSM component."""
|
"""The Synology DSM component."""
|
||||||
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
|
||||||
@ -119,7 +118,7 @@ async def async_setup(hass, config):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry): # noqa: C901
|
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
|
||||||
"""Set up Synology DSM sensors."""
|
"""Set up Synology DSM sensors."""
|
||||||
|
|
||||||
# Migrate old unique_id
|
# Migrate old unique_id
|
||||||
@ -286,25 +285,14 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry): # noqa: C
|
|||||||
update_interval=timedelta(seconds=30),
|
update_interval=timedelta(seconds=30),
|
||||||
)
|
)
|
||||||
|
|
||||||
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 Synology DSM sensors."""
|
"""Unload Synology DSM sensors."""
|
||||||
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:
|
||||||
entry_data = hass.data[DOMAIN][entry.unique_id]
|
entry_data = hass.data[DOMAIN][entry.unique_id]
|
||||||
entry_data[UNDO_UPDATE_LISTENER]()
|
entry_data[UNDO_UPDATE_LISTENER]()
|
||||||
|
@ -19,11 +19,12 @@ async def test_forward_async_setup_entry() -> None:
|
|||||||
hass = Mock()
|
hass = Mock()
|
||||||
|
|
||||||
assert await smhi.async_setup_entry(hass, {}) is True
|
assert await smhi.async_setup_entry(hass, {}) is True
|
||||||
assert len(hass.config_entries.async_forward_entry_setup.mock_calls) == 1
|
assert len(hass.config_entries.async_setup_platforms.mock_calls) == 1
|
||||||
|
|
||||||
|
|
||||||
async def test_forward_async_unload_entry() -> None:
|
async def test_forward_async_unload_entry() -> None:
|
||||||
"""Test that it will forward unload entry."""
|
"""Test that it will forward unload entry."""
|
||||||
hass = AsyncMock()
|
hass = AsyncMock()
|
||||||
|
hass.config_entries.async_unload_platforms = AsyncMock(return_value=True)
|
||||||
assert await smhi.async_unload_entry(hass, {}) is True
|
assert await smhi.async_unload_entry(hass, {}) is True
|
||||||
assert len(hass.config_entries.async_forward_entry_unload.mock_calls) == 1
|
assert len(hass.config_entries.async_unload_platforms.mock_calls) == 1
|
||||||
|
Loading…
x
Reference in New Issue
Block a user