mirror of
https://github.com/NixOS/nixpkgs.git
synced 2026-09-28 02:40:50 +00:00
60 lines
2.4 KiB
Diff
60 lines
2.4 KiB
Diff
diff --git a/custom_components/spook/__init__.py b/custom_components/spook/__init__.py
|
|
index 4223fac..6891ee9 100644
|
|
--- a/custom_components/spook/__init__.py
|
|
+++ b/custom_components/spook/__init__.py
|
|
@@ -33,49 +33,6 @@ if TYPE_CHECKING:
|
|
|
|
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|
"""Set up from a config entry."""
|
|
- # Symlink all sub integrations from Spook to the parent integrations folder
|
|
- # if one is missing, we have to restart Home Assistant.
|
|
- # This is a workaround for the fact that Home Assistant doesn't support
|
|
- # sub integrations.
|
|
- if await hass.async_add_executor_job(link_sub_integrations, hass):
|
|
- LOGGER.debug("Newly symlinked sub integrations, restarting Home Assistant")
|
|
-
|
|
- @callback
|
|
- def _restart(_: Event | None = None) -> None:
|
|
- """Restart Home Assistant."""
|
|
- hass.data["homeassistant_stop"] = asyncio.create_task(
|
|
- hass.async_stop(RESTART_EXIT_CODE),
|
|
- )
|
|
-
|
|
- # User asked to restart Home Assistant in the config flow.
|
|
- if hass.data.get(DOMAIN) == "Boo!":
|
|
- _restart()
|
|
- return False
|
|
-
|
|
- # Should be OK to restart. Better to do it before anything else started.
|
|
- if hass.state == CoreState.starting:
|
|
- _restart()
|
|
- return False
|
|
-
|
|
- # If all other fails, but we are not running yet... wait for it.
|
|
- if hass.state == CoreState.not_running:
|
|
- # Listen to both... just in case.
|
|
- hass.bus.async_listen_once(EVENT_HOMEASSISTANT_START, _restart)
|
|
- hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STARTED, _restart)
|
|
- return False
|
|
-
|
|
- LOGGER.info(
|
|
- "Home Assistant needs to be restarted in for Spook to complete setting up",
|
|
- )
|
|
- ir.async_create_issue(
|
|
- hass=hass,
|
|
- domain=DOMAIN,
|
|
- issue_id="restart_required",
|
|
- is_fixable=True,
|
|
- severity=ir.IssueSeverity.WARNING,
|
|
- translation_key="restart_required",
|
|
- )
|
|
-
|
|
# Forward async_setup_entry to ectoplasms
|
|
await async_forward_setup_entry(hass, entry)
|
|
|
|
@@ -117,4 +74,3 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|
|
|
async def async_remove_entry(hass: HomeAssistant, _: ConfigEntry) -> None:
|
|
"""Remove a config entry."""
|
|
- await hass.async_add_executor_job(unlink_sub_integrations, hass)
|