mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Do not notify config errors during logging (#104466)
This commit is contained in:
parent
4700ad7817
commit
9962301b42
@ -41,6 +41,7 @@ from .setup import (
|
|||||||
DATA_SETUP,
|
DATA_SETUP,
|
||||||
DATA_SETUP_STARTED,
|
DATA_SETUP_STARTED,
|
||||||
DATA_SETUP_TIME,
|
DATA_SETUP_TIME,
|
||||||
|
async_notify_setup_error,
|
||||||
async_set_domains_to_be_loaded,
|
async_set_domains_to_be_loaded,
|
||||||
async_setup_component,
|
async_setup_component,
|
||||||
)
|
)
|
||||||
@ -293,6 +294,7 @@ async def async_from_config_dict(
|
|||||||
await conf_util.async_process_ha_core_config(hass, core_config)
|
await conf_util.async_process_ha_core_config(hass, core_config)
|
||||||
except vol.Invalid as config_err:
|
except vol.Invalid as config_err:
|
||||||
conf_util.async_log_schema_error(config_err, core.DOMAIN, core_config, hass)
|
conf_util.async_log_schema_error(config_err, core.DOMAIN, core_config, hass)
|
||||||
|
async_notify_setup_error(hass, core.DOMAIN)
|
||||||
return None
|
return None
|
||||||
except HomeAssistantError:
|
except HomeAssistantError:
|
||||||
_LOGGER.error(
|
_LOGGER.error(
|
||||||
|
@ -44,7 +44,11 @@ from homeassistant.helpers.event import (
|
|||||||
)
|
)
|
||||||
from homeassistant.helpers.restore_state import RestoreEntity
|
from homeassistant.helpers.restore_state import RestoreEntity
|
||||||
from homeassistant.helpers.typing import ConfigType, GPSType, StateType
|
from homeassistant.helpers.typing import ConfigType, GPSType, StateType
|
||||||
from homeassistant.setup import async_prepare_setup_platform, async_start_setup
|
from homeassistant.setup import (
|
||||||
|
async_notify_setup_error,
|
||||||
|
async_prepare_setup_platform,
|
||||||
|
async_start_setup,
|
||||||
|
)
|
||||||
from homeassistant.util import dt as dt_util
|
from homeassistant.util import dt as dt_util
|
||||||
from homeassistant.util.yaml import dump
|
from homeassistant.util.yaml import dump
|
||||||
|
|
||||||
@ -1007,6 +1011,7 @@ async def async_load_config(
|
|||||||
device["dev_id"] = cv.slugify(dev_id)
|
device["dev_id"] = cv.slugify(dev_id)
|
||||||
except vol.Invalid as exp:
|
except vol.Invalid as exp:
|
||||||
async_log_schema_error(exp, dev_id, devices, hass)
|
async_log_schema_error(exp, dev_id, devices, hass)
|
||||||
|
async_notify_setup_error(hass, DOMAIN)
|
||||||
else:
|
else:
|
||||||
result.append(Device(hass, **device))
|
result.append(Device(hass, **device))
|
||||||
return result
|
return result
|
||||||
|
@ -12,8 +12,11 @@ from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN
|
|||||||
from homeassistant.components.weather import DOMAIN as WEATHER_DOMAIN
|
from homeassistant.components.weather import DOMAIN as WEATHER_DOMAIN
|
||||||
from homeassistant.config import async_log_schema_error, config_without_domain
|
from homeassistant.config import async_log_schema_error, config_without_domain
|
||||||
from homeassistant.const import CONF_BINARY_SENSORS, CONF_SENSORS, CONF_UNIQUE_ID
|
from homeassistant.const import CONF_BINARY_SENSORS, CONF_SENSORS, CONF_UNIQUE_ID
|
||||||
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers import config_validation as cv
|
from homeassistant.helpers import config_validation as cv
|
||||||
from homeassistant.helpers.trigger import async_validate_trigger_config
|
from homeassistant.helpers.trigger import async_validate_trigger_config
|
||||||
|
from homeassistant.helpers.typing import ConfigType
|
||||||
|
from homeassistant.setup import async_notify_setup_error
|
||||||
|
|
||||||
from . import (
|
from . import (
|
||||||
binary_sensor as binary_sensor_platform,
|
binary_sensor as binary_sensor_platform,
|
||||||
@ -64,7 +67,7 @@ CONFIG_SECTION_SCHEMA = vol.Schema(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
async def async_validate_config(hass, config):
|
async def async_validate_config(hass: HomeAssistant, config: ConfigType) -> ConfigType:
|
||||||
"""Validate config."""
|
"""Validate config."""
|
||||||
if DOMAIN not in config:
|
if DOMAIN not in config:
|
||||||
return config
|
return config
|
||||||
@ -81,6 +84,7 @@ async def async_validate_config(hass, config):
|
|||||||
)
|
)
|
||||||
except vol.Invalid as err:
|
except vol.Invalid as err:
|
||||||
async_log_schema_error(err, DOMAIN, cfg, hass)
|
async_log_schema_error(err, DOMAIN, cfg, hass)
|
||||||
|
async_notify_setup_error(hass, DOMAIN)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
legacy_warn_printed = False
|
legacy_warn_printed = False
|
||||||
|
@ -68,7 +68,6 @@ from .helpers.entity_values import EntityValues
|
|||||||
from .helpers.typing import ConfigType
|
from .helpers.typing import ConfigType
|
||||||
from .loader import ComponentProtocol, Integration, IntegrationNotFound
|
from .loader import ComponentProtocol, Integration, IntegrationNotFound
|
||||||
from .requirements import RequirementsNotFound, async_get_integration_with_requirements
|
from .requirements import RequirementsNotFound, async_get_integration_with_requirements
|
||||||
from .setup import async_notify_setup_error
|
|
||||||
from .util.package import is_docker_env
|
from .util.package import is_docker_env
|
||||||
from .util.unit_system import get_unit_system, validate_unit_system
|
from .util.unit_system import get_unit_system, validate_unit_system
|
||||||
from .util.yaml import SECRET_YAML, Secrets, load_yaml
|
from .util.yaml import SECRET_YAML, Secrets, load_yaml
|
||||||
@ -549,8 +548,6 @@ def async_log_schema_error(
|
|||||||
link: str | None = None,
|
link: str | None = None,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Log a schema validation error."""
|
"""Log a schema validation error."""
|
||||||
if hass is not None:
|
|
||||||
async_notify_setup_error(hass, domain, link)
|
|
||||||
message = format_schema_error(hass, ex, domain, config, link)
|
message = format_schema_error(hass, ex, domain, config, link)
|
||||||
_LOGGER.error(message)
|
_LOGGER.error(message)
|
||||||
|
|
||||||
@ -568,8 +565,6 @@ def async_log_config_validator_error(
|
|||||||
async_log_schema_error(ex, domain, config, hass, link)
|
async_log_schema_error(ex, domain, config, hass, link)
|
||||||
return
|
return
|
||||||
|
|
||||||
if hass is not None:
|
|
||||||
async_notify_setup_error(hass, domain, link)
|
|
||||||
message = format_homeassistant_error(hass, ex, domain, config, link)
|
message = format_homeassistant_error(hass, ex, domain, config, link)
|
||||||
_LOGGER.error(message, exc_info=ex)
|
_LOGGER.error(message, exc_info=ex)
|
||||||
|
|
||||||
|
@ -719,7 +719,7 @@ async def test_setup_hass_invalid_core_config(
|
|||||||
event_loop: asyncio.AbstractEventLoop,
|
event_loop: asyncio.AbstractEventLoop,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test it works."""
|
"""Test it works."""
|
||||||
with patch("homeassistant.config.async_notify_setup_error") as mock_notify:
|
with patch("homeassistant.bootstrap.async_notify_setup_error") as mock_notify:
|
||||||
hass = await bootstrap.async_setup_hass(
|
hass = await bootstrap.async_setup_hass(
|
||||||
runner.RuntimeConfig(
|
runner.RuntimeConfig(
|
||||||
config_dir=get_test_config_dir(),
|
config_dir=get_test_config_dir(),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user