nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1diff --git a/custom_components/spook/__init__.py b/custom_components/spook/__init__.py
2index 213fb2c..c7dc299 100644
3--- a/custom_components/spook/__init__.py
4+++ b/custom_components/spook/__init__.py
5@@ -23,8 +23,6 @@ from .templating import SpookTemplateFunctionManager
6 from .util import (
7 async_ensure_template_environments_exists,
8 async_forward_setup_entry,
9- link_sub_integrations,
10- unlink_sub_integrations,
11 )
12
13 if TYPE_CHECKING:
14@@ -34,48 +32,6 @@ if TYPE_CHECKING:
15
16 async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
17 """Set up from a config entry."""
18- # Symlink all sub integrations from Spook to the parent integrations folder
19- # if one is missing, we have to restart Home Assistant.
20- # This is a workaround for the fact that Home Assistant doesn't support
21- # sub integrations.
22- if await hass.async_add_executor_job(link_sub_integrations, hass):
23- LOGGER.debug("Newly symlinked sub integrations, restarting Home Assistant")
24-
25- @callback
26- def _restart(_: Event | None = None) -> None:
27- """Restart Home Assistant."""
28- hass.data["homeassistant_stop"] = asyncio.create_task(
29- hass.async_stop(RESTART_EXIT_CODE),
30- )
31-
32- # User asked to restart Home Assistant in the config flow.
33- if hass.data.get(DOMAIN) == "Boo!":
34- _restart()
35- return False
36-
37- # Should be OK to restart. Better to do it before anything else started.
38- if hass.state == CoreState.starting:
39- _restart()
40- return False
41-
42- # If all other fails, but we are not running yet... wait for it.
43- if hass.state == CoreState.not_running:
44- # Listen to both... just in case.
45- hass.bus.async_listen_once(EVENT_HOMEASSISTANT_START, _restart)
46- hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STARTED, _restart)
47- return False
48-
49- LOGGER.info(
50- "Home Assistant needs to be restarted in for Spook to complete setting up",
51- )
52- ir.async_create_issue(
53- hass=hass,
54- domain=DOMAIN,
55- issue_id="restart_required",
56- is_fixable=True,
57- severity=ir.IssueSeverity.WARNING,
58- translation_key="restart_required",
59- )
60
61 # Ensure template environments exists
62 async_ensure_template_environments_exists(hass)
63@@ -120,4 +76,3 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
64
65 async def async_remove_entry(hass: HomeAssistant, _: ConfigEntry) -> None:
66 """Remove a config entry."""
67- await hass.async_add_executor_job(unlink_sub_integrations, hass)
68diff --git a/custom_components/spook/util.py b/custom_components/spook/util.py
69index 32e9bd2..845d463 100644
70--- a/custom_components/spook/util.py
71+++ b/custom_components/spook/util.py
72@@ -104,37 +104,6 @@ async def async_forward_platform_entry_setups_to_ectoplasm(
73 )
74
75
76-def link_sub_integrations(hass: HomeAssistant) -> bool:
77- """Link Spook sub integrations."""
78- LOGGER.debug("Linking up Spook sub integrations")
79-
80- changes = False
81- for manifest in Path(__file__).parent.rglob("integrations/*/manifest.json"):
82- LOGGER.debug("Linking Spook sub integration: %s", manifest.parent.name)
83- dest = Path(hass.config.config_dir) / "custom_components" / manifest.parent.name
84- if not dest.exists():
85- src = (
86- Path(hass.config.config_dir)
87- / "custom_components"
88- / DOMAIN
89- / "integrations"
90- / manifest.parent.name
91- )
92- dest.symlink_to(src)
93- changes = True
94- return changes
95-
96-
97-def unlink_sub_integrations(hass: HomeAssistant) -> None:
98- """Unlink Spook sub integrations."""
99- LOGGER.debug("Unlinking Spook sub integrations")
100- for manifest in Path(__file__).parent.rglob("integrations/*/manifest.json"):
101- LOGGER.debug("Unlinking Spook sub integration: %s", manifest.parent.name)
102- dest = Path(hass.config.config_dir) / "custom_components" / manifest.parent.name
103- if dest.exists():
104- dest.unlink()
105-
106-
107 @callback
108 def async_ensure_template_environments_exists(hass: HomeAssistant) -> None:
109 """Ensure default template environments exist.