diff --git a/homeassistant/helpers/check_config.py b/homeassistant/helpers/check_config.py index 21a54d64728..ba69a76fbdd 100644 --- a/homeassistant/helpers/check_config.py +++ b/homeassistant/helpers/check_config.py @@ -181,7 +181,9 @@ async def async_check_ha_config_file( # noqa: C901 if config_schema is not None: try: config = config_schema(config) - result[domain] = config[domain] + # Don't fail if the validator removed the domain from the config + if domain in config: + result[domain] = config[domain] except vol.Invalid as ex: _comp_error(ex, domain, config) continue diff --git a/tests/helpers/test_check_config.py b/tests/helpers/test_check_config.py index 91ef17d526d..3b9b3cf6558 100644 --- a/tests/helpers/test_check_config.py +++ b/tests/helpers/test_check_config.py @@ -8,9 +8,10 @@ from homeassistant.helpers.check_config import ( CheckConfigError, async_check_ha_config_file, ) +import homeassistant.helpers.config_validation as cv from homeassistant.requirements import RequirementsNotFound -from tests.common import mock_platform, patch_yaml_files +from tests.common import MockModule, mock_integration, mock_platform, patch_yaml_files _LOGGER = logging.getLogger(__name__) @@ -246,3 +247,20 @@ bla: assert err.domain == "bla" assert err.message == "Unexpected error calling config validator: Broken" assert err.config == {"value": 1} + + +async def test_removed_yaml_support(hass: HomeAssistant) -> None: + """Test config validation check with removed CONFIG_SCHEMA without raise if present.""" + mock_integration( + hass, + MockModule( + domain="bla", config_schema=cv.removed("bla", raise_if_present=False) + ), + False, + ) + files = {YAML_CONFIG_FILE: BASE_CONFIG + "bla:\n platform: demo"} + with patch("os.path.isfile", return_value=True), patch_yaml_files(files): + res = await async_check_ha_config_file(hass) + log_ha_config(res) + + assert res.keys() == {"homeassistant"}