mirror of
https://github.com/home-assistant/core.git
synced 2025-04-23 08:47:57 +00:00
Cleanup config deprecation warning (#80251)
This commit is contained in:
parent
0715b87934
commit
8dc3ff72c6
@ -46,7 +46,6 @@ from .const import (
|
||||
CONF_UNIT_SYSTEM,
|
||||
CONF_UNIT_SYSTEM_IMPERIAL,
|
||||
LEGACY_CONF_WHITELIST_EXTERNAL_DIRS,
|
||||
TEMP_CELSIUS,
|
||||
__version__,
|
||||
)
|
||||
from .core import DOMAIN as CONF_CORE, ConfigSource, HomeAssistant, callback
|
||||
@ -204,7 +203,7 @@ CORE_CONFIG_SCHEMA = vol.All(
|
||||
CONF_LATITUDE: cv.latitude,
|
||||
CONF_LONGITUDE: cv.longitude,
|
||||
CONF_ELEVATION: vol.Coerce(int),
|
||||
vol.Optional(CONF_TEMPERATURE_UNIT): cv.temperature_unit,
|
||||
vol.Remove(CONF_TEMPERATURE_UNIT): cv.temperature_unit,
|
||||
CONF_UNIT_SYSTEM: cv.unit_system,
|
||||
CONF_TIME_ZONE: cv.time_zone,
|
||||
vol.Optional(CONF_INTERNAL_URL): cv.url,
|
||||
@ -607,18 +606,6 @@ async def async_process_ha_core_config(hass: HomeAssistant, config: dict) -> Non
|
||||
hac.units = IMPERIAL_SYSTEM
|
||||
else:
|
||||
hac.units = METRIC_SYSTEM
|
||||
elif CONF_TEMPERATURE_UNIT in config:
|
||||
unit = config[CONF_TEMPERATURE_UNIT]
|
||||
hac.units = METRIC_SYSTEM if unit == TEMP_CELSIUS else IMPERIAL_SYSTEM
|
||||
_LOGGER.warning(
|
||||
"Found deprecated temperature unit in core "
|
||||
"configuration expected unit system. Replace '%s: %s' "
|
||||
"with '%s: %s'",
|
||||
CONF_TEMPERATURE_UNIT,
|
||||
unit,
|
||||
CONF_UNIT_SYSTEM,
|
||||
hac.units.name,
|
||||
)
|
||||
|
||||
|
||||
def _log_pkg_error(package: str, component: str, config: dict, message: str) -> None:
|
||||
|
@ -22,7 +22,6 @@ from homeassistant.const import (
|
||||
CONF_LATITUDE,
|
||||
CONF_LONGITUDE,
|
||||
CONF_NAME,
|
||||
CONF_TEMPERATURE_UNIT,
|
||||
CONF_UNIT_SYSTEM,
|
||||
CONF_UNIT_SYSTEM_IMPERIAL,
|
||||
CONF_UNIT_SYSTEM_METRIC,
|
||||
@ -538,34 +537,6 @@ async def test_loading_configuration(hass):
|
||||
assert hass.config.currency == "EUR"
|
||||
|
||||
|
||||
async def test_loading_configuration_temperature_unit(hass):
|
||||
"""Test backward compatibility when loading core config."""
|
||||
await config_util.async_process_ha_core_config(
|
||||
hass,
|
||||
{
|
||||
"latitude": 60,
|
||||
"longitude": 50,
|
||||
"elevation": 25,
|
||||
"name": "Huis",
|
||||
CONF_TEMPERATURE_UNIT: "C",
|
||||
"time_zone": "America/New_York",
|
||||
"external_url": "https://www.example.com",
|
||||
"internal_url": "http://example.local",
|
||||
},
|
||||
)
|
||||
|
||||
assert hass.config.latitude == 60
|
||||
assert hass.config.longitude == 50
|
||||
assert hass.config.elevation == 25
|
||||
assert hass.config.location_name == "Huis"
|
||||
assert hass.config.units.name == CONF_UNIT_SYSTEM_METRIC
|
||||
assert hass.config.time_zone == "America/New_York"
|
||||
assert hass.config.external_url == "https://www.example.com"
|
||||
assert hass.config.internal_url == "http://example.local"
|
||||
assert hass.config.config_source is ConfigSource.YAML
|
||||
assert hass.config.currency == "EUR"
|
||||
|
||||
|
||||
async def test_loading_configuration_default_media_dirs_docker(hass):
|
||||
"""Test loading core config onto hass object."""
|
||||
with patch("homeassistant.config.is_docker_env", return_value=True):
|
||||
@ -591,7 +562,7 @@ async def test_loading_configuration_from_packages(hass):
|
||||
"longitude": -1,
|
||||
"elevation": 500,
|
||||
"name": "Huis",
|
||||
CONF_TEMPERATURE_UNIT: "C",
|
||||
CONF_UNIT_SYSTEM: CONF_UNIT_SYSTEM_METRIC,
|
||||
"time_zone": "Europe/Madrid",
|
||||
"external_url": "https://www.example.com",
|
||||
"internal_url": "http://example.local",
|
||||
@ -615,7 +586,7 @@ async def test_loading_configuration_from_packages(hass):
|
||||
"longitude": -1,
|
||||
"elevation": 500,
|
||||
"name": "Huis",
|
||||
CONF_TEMPERATURE_UNIT: "C",
|
||||
CONF_UNIT_SYSTEM: CONF_UNIT_SYSTEM_METRIC,
|
||||
"time_zone": "Europe/Madrid",
|
||||
"packages": {"empty_package": None},
|
||||
},
|
||||
|
Loading…
x
Reference in New Issue
Block a user