From 4e765398cc6400598a275e816b258d5cc7498e54 Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Wed, 19 Feb 2020 06:56:46 -0800 Subject: [PATCH] =?UTF-8?q?Only=20check=20frontend=20for=20safe=20mode=20i?= =?UTF-8?q?f=20frontend=20wanted=20to=20be=20loa=E2=80=A6=20(#31969)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Only check frontend for safe mode if frontend wanted to be loaded * Update test --- homeassistant/bootstrap.py | 7 +++++-- tests/test_bootstrap.py | 3 ++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/homeassistant/bootstrap.py b/homeassistant/bootstrap.py index 723e3c512e2..7d4155257db 100644 --- a/homeassistant/bootstrap.py +++ b/homeassistant/bootstrap.py @@ -20,7 +20,7 @@ from homeassistant.const import ( REQUIRED_NEXT_PYTHON_VER, ) from homeassistant.exceptions import HomeAssistantError -from homeassistant.setup import async_setup_component +from homeassistant.setup import DATA_SETUP, async_setup_component from homeassistant.util.logging import AsyncHandler from homeassistant.util.package import async_get_user_site, is_virtual_env from homeassistant.util.yaml import clear_secret_cache @@ -102,7 +102,10 @@ async def async_setup_hass( _LOGGER.warning("Unable to set up core integrations. Activating safe mode") safe_mode = True - elif "frontend" not in hass.config.components: + elif ( + "frontend" in hass.data.get(DATA_SETUP, {}) + and "frontend" not in hass.config.components + ): _LOGGER.warning("Detected that frontend did not load. Activating safe mode") # Ask integrations to shut down. It's messy but we can't # do a clean stop without knowing what is broken diff --git a/tests/test_bootstrap.py b/tests/test_bootstrap.py index dac32b4728d..34704ddfb74 100644 --- a/tests/test_bootstrap.py +++ b/tests/test_bootstrap.py @@ -400,7 +400,8 @@ async def test_setup_safe_mode_if_no_frontend( log_no_color = Mock() with patch( - "homeassistant.config.async_hass_config_yaml", return_value={"browser": {}} + "homeassistant.config.async_hass_config_yaml", + return_value={"map": {}, "person": {"invalid": True}}, ): hass = await bootstrap.async_setup_hass( config_dir=get_test_config_dir(),