Combine recorder and frontend bootstrap step (#113985)

This commit is contained in:
J. Nick Koston 2024-03-22 13:50:39 -10:00 committed by GitHub
parent bf8d880e5f
commit 952f47ab18
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 34 additions and 21 deletions

View file

@ -194,16 +194,14 @@ CRITICAL_INTEGRATIONS = {
"frontend",
}
SETUP_ORDER = {
SETUP_ORDER = (
# Load logging as soon as possible
"logging": LOGGING_INTEGRATIONS,
# Setup frontend
"frontend": FRONTEND_INTEGRATIONS,
# Setup recorder
"recorder": RECORDER_INTEGRATIONS,
("logging", LOGGING_INTEGRATIONS),
# Setup frontend and recorder
("frontend, recorder", {*FRONTEND_INTEGRATIONS, *RECORDER_INTEGRATIONS}),
# Start up debuggers. Start these first in case they want to wait.
"debugger": DEBUGGER_INTEGRATIONS,
}
("debugger", DEBUGGER_INTEGRATIONS),
)
async def async_setup_hass(
@ -856,10 +854,9 @@ async def _async_set_up_integrations(
if "recorder" in domains_to_setup:
recorder.async_initialize_recorder(hass)
pre_stage_domains: dict[str, set[str]] = {
name: domains_to_setup & domain_group
for name, domain_group in SETUP_ORDER.items()
}
pre_stage_domains = [
(name, domains_to_setup & domain_group) for name, domain_group in SETUP_ORDER
]
# calculate what components to setup in what stage
stage_1_domains: set[str] = set()
@ -885,7 +882,7 @@ async def _async_set_up_integrations(
stage_2_domains = domains_to_setup - stage_1_domains
for name, domain_group in pre_stage_domains.items():
for name, domain_group in pre_stage_domains:
if domain_group:
stage_2_domains -= domain_group
_LOGGER.info("Setting up %s: %s", name, domain_group)

View file

@ -1,6 +1,7 @@
{
"domain": "recorder",
"name": "Recorder",
"after_dependencies": ["http"],
"codeowners": ["@home-assistant/core"],
"documentation": "https://www.home-assistant.io/integrations/recorder",
"integration_type": "system",

View file

@ -13,7 +13,7 @@ from homeassistant.components.humidifier import (
from homeassistant.components.recorder import Recorder
from homeassistant.components.recorder.history import get_significant_states
from homeassistant.const import ATTR_FRIENDLY_NAME
from homeassistant.core import HomeAssistant
from homeassistant.core import HomeAssistant, split_entity_id
from homeassistant.setup import async_setup_component
from homeassistant.util import dt as dt_util
@ -37,7 +37,10 @@ async def test_exclude_attributes(recorder_mock: Recorder, hass: HomeAssistant)
)
assert len(states) >= 1
for entity_states in states.values():
for state in entity_states:
for state in filter(
lambda state: split_entity_id(state.entity_id)[0] == humidifier.DOMAIN,
entity_states,
):
assert ATTR_MIN_HUMIDITY not in state.attributes
assert ATTR_MAX_HUMIDITY not in state.attributes
assert ATTR_AVAILABLE_MODES not in state.attributes

View file

@ -9,7 +9,7 @@ from homeassistant.components.recorder import Recorder
from homeassistant.components.recorder.history import get_significant_states
from homeassistant.components.siren import ATTR_AVAILABLE_TONES
from homeassistant.const import ATTR_FRIENDLY_NAME
from homeassistant.core import HomeAssistant
from homeassistant.core import HomeAssistant, split_entity_id
from homeassistant.setup import async_setup_component
from homeassistant.util import dt as dt_util
@ -33,6 +33,9 @@ async def test_exclude_attributes(recorder_mock: Recorder, hass: HomeAssistant)
)
assert len(states) >= 1
for entity_states in states.values():
for state in entity_states:
for state in filter(
lambda state: split_entity_id(state.entity_id)[0] == siren.DOMAIN,
entity_states,
):
assert ATTR_AVAILABLE_TONES not in state.attributes
assert ATTR_FRIENDLY_NAME in state.attributes

View file

@ -9,7 +9,7 @@ from homeassistant.components.recorder import Recorder
from homeassistant.components.recorder.history import get_significant_states
from homeassistant.components.vacuum import ATTR_FAN_SPEED_LIST
from homeassistant.const import ATTR_FRIENDLY_NAME
from homeassistant.core import HomeAssistant
from homeassistant.core import HomeAssistant, split_entity_id
from homeassistant.setup import async_setup_component
from homeassistant.util import dt as dt_util
@ -33,6 +33,9 @@ async def test_exclude_attributes(recorder_mock: Recorder, hass: HomeAssistant)
)
assert len(states) >= 1
for entity_states in states.values():
for state in entity_states:
for state in filter(
lambda state: split_entity_id(state.entity_id)[0] == vacuum.DOMAIN,
entity_states,
):
assert ATTR_FAN_SPEED_LIST not in state.attributes
assert ATTR_FRIENDLY_NAME in state.attributes

View file

@ -13,7 +13,7 @@ from homeassistant.components.water_heater import (
ATTR_OPERATION_LIST,
)
from homeassistant.const import ATTR_FRIENDLY_NAME
from homeassistant.core import HomeAssistant
from homeassistant.core import HomeAssistant, split_entity_id
from homeassistant.setup import async_setup_component
from homeassistant.util import dt as dt_util
@ -37,7 +37,10 @@ async def test_exclude_attributes(recorder_mock: Recorder, hass: HomeAssistant)
)
assert len(states) >= 1
for entity_states in states.values():
for state in entity_states:
for state in filter(
lambda state: split_entity_id(state.entity_id)[0] == water_heater.DOMAIN,
entity_states,
):
assert ATTR_OPERATION_LIST not in state.attributes
assert ATTR_MIN_TEMP not in state.attributes
assert ATTR_MAX_TEMP not in state.attributes

View file

@ -359,6 +359,9 @@ async def test_setup_frontend_before_recorder(hass: HomeAssistant) -> None:
MockModule(
domain="recorder",
async_setup=gen_domain_setup("recorder"),
partial_manifest={
"after_dependencies": ["http"],
},
),
)