mirror of
https://github.com/home-assistant/core.git
synced 2026-12-02 19:57:03 -04:00
Remove subscribe_bootstrap_integrations websocket command (#194785)
This commit is contained in:
@@ -69,7 +69,6 @@ from .const import (
|
||||
EVENT_HOMEASSISTANT_STARTED,
|
||||
KEY_DATA_LOGGING as DATA_LOGGING,
|
||||
KEY_DATA_LOGGING_DISABLED_REASON as DATA_LOGGING_DISABLED_REASON,
|
||||
SIGNAL_BOOTSTRAP_INTEGRATIONS,
|
||||
)
|
||||
from .core_config import async_process_ha_core_config
|
||||
from .exceptions import HomeAssistantError, UnsupportedStorageVersionError
|
||||
@@ -91,7 +90,6 @@ from .helpers import (
|
||||
translation,
|
||||
trigger,
|
||||
)
|
||||
from .helpers.dispatcher import async_dispatcher_send_internal
|
||||
from .helpers.storage import get_internal_store_manager
|
||||
from .helpers.system_info import async_get_system_info
|
||||
from .helpers.typing import ConfigType
|
||||
@@ -1059,7 +1057,6 @@ class _WatchPendingSetups:
|
||||
self._setup_started = setup_started
|
||||
self._duration_count = 0
|
||||
self._handle: asyncio.TimerHandle | None = None
|
||||
self._previous_was_empty = True
|
||||
self._loop = hass.loop
|
||||
self._started = started
|
||||
self._phase = BootstrapPhase.PREPARING
|
||||
@@ -1081,7 +1078,6 @@ class _WatchPendingSetups:
|
||||
_LOGGER.debug("Integration remaining: %s", remaining_with_setup_started)
|
||||
elif waiting_tasks := self._hass._active_tasks: # noqa: SLF001
|
||||
_LOGGER.debug("Waiting on tasks: %s", waiting_tasks)
|
||||
self._async_dispatch(remaining_with_setup_started)
|
||||
_async_dispatch_bootstrap_progress(self._hass)
|
||||
if (
|
||||
self._setup_started
|
||||
@@ -1097,14 +1093,6 @@ class _WatchPendingSetups:
|
||||
_LOGGER.debug("Running timeout Zones: %s", self._hass.timeout.zones)
|
||||
self._async_schedule_next()
|
||||
|
||||
def _async_dispatch(self, remaining_with_setup_started: dict[str, float]) -> None:
|
||||
"""Dispatch the signal."""
|
||||
if remaining_with_setup_started or not self._previous_was_empty:
|
||||
async_dispatcher_send_internal(
|
||||
self._hass, SIGNAL_BOOTSTRAP_INTEGRATIONS, remaining_with_setup_started
|
||||
)
|
||||
self._previous_was_empty = not remaining_with_setup_started
|
||||
|
||||
@core.callback
|
||||
def async_set_planned_domains(self, domains: set[str]) -> None:
|
||||
"""Set the domains bootstrap will set up, including dependencies."""
|
||||
@@ -1202,7 +1190,6 @@ class _WatchPendingSetups:
|
||||
|
||||
The progress is still dispatched on the start and started events.
|
||||
"""
|
||||
self._async_dispatch({})
|
||||
_async_dispatch_bootstrap_progress(self._hass)
|
||||
# Progress keeps the wrap up phase until the core state changes.
|
||||
for event_type, phase in (
|
||||
|
||||
@@ -16,7 +16,6 @@ from homeassistant.const import (
|
||||
CONF_EXTERNAL_URL,
|
||||
EVENT_STATE_CHANGED,
|
||||
MATCH_ALL,
|
||||
SIGNAL_BOOTSTRAP_INTEGRATIONS,
|
||||
TargetKey,
|
||||
)
|
||||
from homeassistant.core import (
|
||||
@@ -50,7 +49,6 @@ from homeassistant.helpers.condition import (
|
||||
async_subscribe_platform_events as async_subscribe_condition_platform_events,
|
||||
async_validate_condition_config,
|
||||
)
|
||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||
from homeassistant.helpers.entityfilter import (
|
||||
INCLUDE_EXCLUDE_BASE_FILTER_SCHEMA,
|
||||
convert_include_exclude_filter,
|
||||
@@ -137,7 +135,6 @@ def async_register_commands(
|
||||
async_reg(hass, handle_ping)
|
||||
async_reg(hass, handle_render_template)
|
||||
async_reg(hass, handle_slugify)
|
||||
async_reg(hass, handle_subscribe_bootstrap_integrations)
|
||||
async_reg(hass, handle_subscribe_bootstrap_progress)
|
||||
async_reg(hass, handle_subscribe_condition)
|
||||
async_reg(hass, handle_subscribe_condition_platforms)
|
||||
@@ -232,29 +229,6 @@ def handle_subscribe_events(
|
||||
connection.send_result(msg["id"])
|
||||
|
||||
|
||||
@callback
|
||||
@decorators.websocket_command(
|
||||
{
|
||||
probatio.Required("type"): "subscribe_bootstrap_integrations",
|
||||
}
|
||||
)
|
||||
def handle_subscribe_bootstrap_integrations(
|
||||
hass: HomeAssistant, connection: ActiveConnection, msg: dict[str, Any]
|
||||
) -> None:
|
||||
"""Handle subscribe bootstrap integrations command."""
|
||||
|
||||
@callback
|
||||
def forward_bootstrap_integrations(message: dict[str, Any]) -> None:
|
||||
"""Forward bootstrap integrations to websocket."""
|
||||
connection.send_message(messages.event_message(msg["id"], message))
|
||||
|
||||
connection.subscriptions[msg["id"]] = async_dispatcher_connect(
|
||||
hass, SIGNAL_BOOTSTRAP_INTEGRATIONS, forward_bootstrap_integrations
|
||||
)
|
||||
|
||||
connection.send_result(msg["id"])
|
||||
|
||||
|
||||
@callback
|
||||
@decorators.websocket_command(
|
||||
{
|
||||
|
||||
@@ -14,7 +14,6 @@ from .helpers.deprecation import (
|
||||
)
|
||||
from .util.event_type import EventType
|
||||
from .util.hass_dict import HassKey
|
||||
from .util.signal_type import SignalType
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from .core import EventStateChangedData, EventStateReportedData
|
||||
@@ -1070,10 +1069,6 @@ CAST_APP_ID_HOMEASSISTANT_LOVELACE: Final = "A078F6B0"
|
||||
# User used by Supervisor
|
||||
HASSIO_USER_NAME = "Supervisor"
|
||||
|
||||
SIGNAL_BOOTSTRAP_INTEGRATIONS: SignalType[dict[str, float]] = SignalType(
|
||||
"bootstrap_integrations"
|
||||
)
|
||||
|
||||
|
||||
# hass.data keys for logging information.
|
||||
KEY_DATA_LOGGING: HassKey[str] = HassKey("logging")
|
||||
|
||||
@@ -51,11 +51,7 @@ from homeassistant.components.websocket_api.commands import (
|
||||
)
|
||||
from homeassistant.components.websocket_api.const import FEATURE_COALESCE_MESSAGES, URL
|
||||
from homeassistant.config_entries import ConfigEntryState
|
||||
from homeassistant.const import (
|
||||
CONF_EXTERNAL_URL,
|
||||
SIGNAL_BOOTSTRAP_INTEGRATIONS,
|
||||
EntityCategory,
|
||||
)
|
||||
from homeassistant.const import CONF_EXTERNAL_URL, EntityCategory
|
||||
from homeassistant.core import (
|
||||
Context,
|
||||
HomeAssistant,
|
||||
@@ -73,7 +69,6 @@ from homeassistant.helpers import (
|
||||
system_state,
|
||||
trace,
|
||||
)
|
||||
from homeassistant.helpers.dispatcher import async_dispatcher_send
|
||||
from homeassistant.helpers.event import (
|
||||
async_track_state_change_event,
|
||||
async_track_time_interval,
|
||||
@@ -3931,30 +3926,6 @@ async def test_execute_script_config_error(
|
||||
assert msg["error"] == expected_error
|
||||
|
||||
|
||||
async def test_subscribe_unsubscribe_bootstrap_integrations(
|
||||
hass: HomeAssistant,
|
||||
websocket_client: MockHAClientWebSocket,
|
||||
hass_admin_user: MockUser,
|
||||
) -> None:
|
||||
"""Test subscribe/unsubscribe bootstrap_integrations."""
|
||||
await websocket_client.send_json_auto_id(
|
||||
{"type": "subscribe_bootstrap_integrations"}
|
||||
)
|
||||
|
||||
msg = await websocket_client.receive_json()
|
||||
subscription = msg["id"]
|
||||
assert msg["type"] == const.TYPE_RESULT
|
||||
assert msg["success"]
|
||||
|
||||
message = {"august": 12.5, "isy994": 12.8}
|
||||
|
||||
async_dispatcher_send(hass, SIGNAL_BOOTSTRAP_INTEGRATIONS, message)
|
||||
msg = await websocket_client.receive_json()
|
||||
assert msg["id"] == subscription
|
||||
assert msg["type"] == "event"
|
||||
assert msg["event"] == message
|
||||
|
||||
|
||||
async def test_subscribe_bootstrap_progress(
|
||||
hass: HomeAssistant,
|
||||
websocket_client: MockHAClientWebSocket,
|
||||
@@ -4088,7 +4059,7 @@ async def test_integration_setup_info(
|
||||
websocket_client: MockHAClientWebSocket,
|
||||
hass_admin_user: MockUser,
|
||||
) -> None:
|
||||
"""Test subscribe/unsubscribe bootstrap_integrations."""
|
||||
"""Test integration setup info."""
|
||||
with patch(
|
||||
"homeassistant.components.websocket_api.commands.async_get_setup_timings",
|
||||
return_value={
|
||||
|
||||
+1
-71
@@ -33,15 +33,9 @@ from homeassistant import (
|
||||
runner,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import (
|
||||
BASE_PLATFORMS,
|
||||
CONF_DEBUG,
|
||||
EVENT_HOMEASSISTANT_START,
|
||||
SIGNAL_BOOTSTRAP_INTEGRATIONS,
|
||||
)
|
||||
from homeassistant.const import BASE_PLATFORMS, CONF_DEBUG, EVENT_HOMEASSISTANT_START
|
||||
from homeassistant.core import CoreState, Event, HomeAssistant, async_get_hass, callback
|
||||
from homeassistant.exceptions import ConfigEntryNotReady, HomeAssistantError
|
||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||
from homeassistant.helpers.translation import async_translations_loaded
|
||||
from homeassistant.helpers.typing import ConfigType
|
||||
from homeassistant.loader import Integration
|
||||
@@ -1211,70 +1205,6 @@ async def test_setup_recovery_mode_if_no_frontend(
|
||||
assert hass.config.external_url == "https://abcdef.ui.nabu.casa"
|
||||
|
||||
|
||||
@pytest.mark.parametrize("load_registries", [False])
|
||||
@patch("homeassistant.bootstrap.DEFAULT_INTEGRATIONS", set())
|
||||
async def test_empty_integrations_list_is_only_sent_at_the_end_of_bootstrap(
|
||||
hass: HomeAssistant,
|
||||
) -> None:
|
||||
"""Test empty integrations list is only sent at the end of bootstrap."""
|
||||
# setup times only tracked when not running
|
||||
hass.set_state(CoreState.not_running)
|
||||
|
||||
order = []
|
||||
|
||||
def gen_domain_setup(domain):
|
||||
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
||||
order.append(domain)
|
||||
await asyncio.sleep(0.05)
|
||||
|
||||
async def _background_task():
|
||||
await asyncio.sleep(0.1)
|
||||
|
||||
await hass.async_create_task(_background_task())
|
||||
return True
|
||||
|
||||
return async_setup
|
||||
|
||||
mock_integration(
|
||||
hass,
|
||||
MockModule(
|
||||
domain="normal_integration",
|
||||
async_setup=gen_domain_setup("normal_integration"),
|
||||
partial_manifest={"after_dependencies": ["an_after_dep"]},
|
||||
),
|
||||
)
|
||||
mock_integration(
|
||||
hass,
|
||||
MockModule(
|
||||
domain="an_after_dep",
|
||||
async_setup=gen_domain_setup("an_after_dep"),
|
||||
),
|
||||
)
|
||||
|
||||
integrations = []
|
||||
|
||||
@callback
|
||||
def _bootstrap_integrations(data):
|
||||
integrations.append(data)
|
||||
|
||||
async_dispatcher_connect(
|
||||
hass, SIGNAL_BOOTSTRAP_INTEGRATIONS, _bootstrap_integrations
|
||||
)
|
||||
with patch.object(bootstrap, "SLOW_STARTUP_CHECK_INTERVAL", 0.025):
|
||||
await bootstrap._async_set_up_integrations(
|
||||
hass, {"normal_integration": {}, "an_after_dep": {}}, monotonic()
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert integrations[0] != {}
|
||||
assert "an_after_dep" in integrations[0]
|
||||
assert integrations[-2] != {}
|
||||
assert integrations[-1] == {}
|
||||
|
||||
assert "normal_integration" in hass.config.components
|
||||
assert order == ["an_after_dep", "normal_integration"]
|
||||
|
||||
|
||||
@pytest.mark.parametrize("load_registries", [False])
|
||||
async def test_warning_logged_on_wrap_up_timeout(
|
||||
hass: HomeAssistant, caplog: pytest.LogCaptureFixture
|
||||
|
||||
Reference in New Issue
Block a user