mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Use HOMEASSISTANT_DOMAIN alias for core DOMAIN (#122760)
This commit is contained in:
parent
9ce7779bde
commit
07c7bb8b2a
@ -21,7 +21,7 @@ from homeassistant.const import (
|
|||||||
CONF_PATH,
|
CONF_PATH,
|
||||||
__version__,
|
__version__,
|
||||||
)
|
)
|
||||||
from homeassistant.core import DOMAIN as HA_DOMAIN, HomeAssistant, callback
|
from homeassistant.core import DOMAIN as HOMEASSISTANT_DOMAIN, HomeAssistant, callback
|
||||||
from homeassistant.exceptions import HomeAssistantError
|
from homeassistant.exceptions import HomeAssistantError
|
||||||
from homeassistant.util import yaml
|
from homeassistant.util import yaml
|
||||||
|
|
||||||
@ -372,7 +372,7 @@ class DomainBlueprints:
|
|||||||
|
|
||||||
shutil.copytree(
|
shutil.copytree(
|
||||||
integration.file_path / BLUEPRINT_FOLDER,
|
integration.file_path / BLUEPRINT_FOLDER,
|
||||||
self.blueprint_folder / HA_DOMAIN,
|
self.blueprint_folder / HOMEASSISTANT_DOMAIN,
|
||||||
)
|
)
|
||||||
|
|
||||||
await self.hass.async_add_executor_job(populate)
|
await self.hass.async_add_executor_job(populate)
|
||||||
|
@ -11,7 +11,7 @@ from homeassistant.components.scene import (
|
|||||||
)
|
)
|
||||||
from homeassistant.config import SCENE_CONFIG_PATH
|
from homeassistant.config import SCENE_CONFIG_PATH
|
||||||
from homeassistant.const import CONF_ID, SERVICE_RELOAD
|
from homeassistant.const import CONF_ID, SERVICE_RELOAD
|
||||||
from homeassistant.core import DOMAIN as HA_DOMAIN, HomeAssistant, callback
|
from homeassistant.core import DOMAIN as HOMEASSISTANT_DOMAIN, HomeAssistant, callback
|
||||||
from homeassistant.helpers import config_validation as cv, entity_registry as er
|
from homeassistant.helpers import config_validation as cv, entity_registry as er
|
||||||
|
|
||||||
from .const import ACTION_DELETE
|
from .const import ACTION_DELETE
|
||||||
@ -32,7 +32,9 @@ def async_setup(hass: HomeAssistant) -> bool:
|
|||||||
|
|
||||||
ent_reg = er.async_get(hass)
|
ent_reg = er.async_get(hass)
|
||||||
|
|
||||||
entity_id = ent_reg.async_get_entity_id(DOMAIN, HA_DOMAIN, config_key)
|
entity_id = ent_reg.async_get_entity_id(
|
||||||
|
DOMAIN, HOMEASSISTANT_DOMAIN, config_key
|
||||||
|
)
|
||||||
|
|
||||||
if entity_id is None:
|
if entity_id is None:
|
||||||
return
|
return
|
||||||
|
@ -33,7 +33,7 @@ from homeassistant.const import (
|
|||||||
STATE_UNKNOWN,
|
STATE_UNKNOWN,
|
||||||
)
|
)
|
||||||
from homeassistant.core import (
|
from homeassistant.core import (
|
||||||
DOMAIN as HA_DOMAIN,
|
DOMAIN as HOMEASSISTANT_DOMAIN,
|
||||||
Event,
|
Event,
|
||||||
EventStateChangedData,
|
EventStateChangedData,
|
||||||
HomeAssistant,
|
HomeAssistant,
|
||||||
@ -554,12 +554,14 @@ class GenericHygrostat(HumidifierEntity, RestoreEntity):
|
|||||||
async def _async_device_turn_on(self) -> None:
|
async def _async_device_turn_on(self) -> None:
|
||||||
"""Turn humidifier toggleable device on."""
|
"""Turn humidifier toggleable device on."""
|
||||||
data = {ATTR_ENTITY_ID: self._switch_entity_id}
|
data = {ATTR_ENTITY_ID: self._switch_entity_id}
|
||||||
await self.hass.services.async_call(HA_DOMAIN, SERVICE_TURN_ON, data)
|
await self.hass.services.async_call(HOMEASSISTANT_DOMAIN, SERVICE_TURN_ON, data)
|
||||||
|
|
||||||
async def _async_device_turn_off(self) -> None:
|
async def _async_device_turn_off(self) -> None:
|
||||||
"""Turn humidifier toggleable device off."""
|
"""Turn humidifier toggleable device off."""
|
||||||
data = {ATTR_ENTITY_ID: self._switch_entity_id}
|
data = {ATTR_ENTITY_ID: self._switch_entity_id}
|
||||||
await self.hass.services.async_call(HA_DOMAIN, SERVICE_TURN_OFF, data)
|
await self.hass.services.async_call(
|
||||||
|
HOMEASSISTANT_DOMAIN, SERVICE_TURN_OFF, data
|
||||||
|
)
|
||||||
|
|
||||||
async def async_set_mode(self, mode: str) -> None:
|
async def async_set_mode(self, mode: str) -> None:
|
||||||
"""Set new mode.
|
"""Set new mode.
|
||||||
|
@ -38,7 +38,7 @@ from homeassistant.const import (
|
|||||||
UnitOfTemperature,
|
UnitOfTemperature,
|
||||||
)
|
)
|
||||||
from homeassistant.core import (
|
from homeassistant.core import (
|
||||||
DOMAIN as HA_DOMAIN,
|
DOMAIN as HOMEASSISTANT_DOMAIN,
|
||||||
CoreState,
|
CoreState,
|
||||||
Event,
|
Event,
|
||||||
EventStateChangedData,
|
EventStateChangedData,
|
||||||
@ -570,14 +570,14 @@ class GenericThermostat(ClimateEntity, RestoreEntity):
|
|||||||
"""Turn heater toggleable device on."""
|
"""Turn heater toggleable device on."""
|
||||||
data = {ATTR_ENTITY_ID: self.heater_entity_id}
|
data = {ATTR_ENTITY_ID: self.heater_entity_id}
|
||||||
await self.hass.services.async_call(
|
await self.hass.services.async_call(
|
||||||
HA_DOMAIN, SERVICE_TURN_ON, data, context=self._context
|
HOMEASSISTANT_DOMAIN, SERVICE_TURN_ON, data, context=self._context
|
||||||
)
|
)
|
||||||
|
|
||||||
async def _async_heater_turn_off(self) -> None:
|
async def _async_heater_turn_off(self) -> None:
|
||||||
"""Turn heater toggleable device off."""
|
"""Turn heater toggleable device off."""
|
||||||
data = {ATTR_ENTITY_ID: self.heater_entity_id}
|
data = {ATTR_ENTITY_ID: self.heater_entity_id}
|
||||||
await self.hass.services.async_call(
|
await self.hass.services.async_call(
|
||||||
HA_DOMAIN, SERVICE_TURN_OFF, data, context=self._context
|
HOMEASSISTANT_DOMAIN, SERVICE_TURN_OFF, data, context=self._context
|
||||||
)
|
)
|
||||||
|
|
||||||
async def async_set_preset_mode(self, preset_mode: str) -> None:
|
async def async_set_preset_mode(self, preset_mode: str) -> None:
|
||||||
|
@ -81,7 +81,7 @@ from homeassistant.const import (
|
|||||||
STATE_UNKNOWN,
|
STATE_UNKNOWN,
|
||||||
UnitOfTemperature,
|
UnitOfTemperature,
|
||||||
)
|
)
|
||||||
from homeassistant.core import DOMAIN as HA_DOMAIN, HomeAssistant
|
from homeassistant.core import DOMAIN as HOMEASSISTANT_DOMAIN, HomeAssistant
|
||||||
from homeassistant.helpers.network import get_url
|
from homeassistant.helpers.network import get_url
|
||||||
from homeassistant.util import color as color_util, dt as dt_util
|
from homeassistant.util import color as color_util, dt as dt_util
|
||||||
from homeassistant.util.dt import utcnow
|
from homeassistant.util.dt import utcnow
|
||||||
@ -511,7 +511,7 @@ class OnOffTrait(_Trait):
|
|||||||
async def execute(self, command, data, params, challenge):
|
async def execute(self, command, data, params, challenge):
|
||||||
"""Execute an OnOff command."""
|
"""Execute an OnOff command."""
|
||||||
if (domain := self.state.domain) == group.DOMAIN:
|
if (domain := self.state.domain) == group.DOMAIN:
|
||||||
service_domain = HA_DOMAIN
|
service_domain = HOMEASSISTANT_DOMAIN
|
||||||
service = SERVICE_TURN_ON if params["on"] else SERVICE_TURN_OFF
|
service = SERVICE_TURN_ON if params["on"] else SERVICE_TURN_OFF
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
@ -24,7 +24,7 @@ from homeassistant.const import (
|
|||||||
STATE_ON,
|
STATE_ON,
|
||||||
)
|
)
|
||||||
from homeassistant.core import (
|
from homeassistant.core import (
|
||||||
DOMAIN as HA_DOMAIN,
|
DOMAIN as HOMEASSISTANT_DOMAIN,
|
||||||
HomeAssistant,
|
HomeAssistant,
|
||||||
ServiceCall,
|
ServiceCall,
|
||||||
State,
|
State,
|
||||||
@ -92,7 +92,7 @@ STATES_SCHEMA = vol.All(dict, _convert_states)
|
|||||||
|
|
||||||
PLATFORM_SCHEMA = vol.Schema(
|
PLATFORM_SCHEMA = vol.Schema(
|
||||||
{
|
{
|
||||||
vol.Required(CONF_PLATFORM): HA_DOMAIN,
|
vol.Required(CONF_PLATFORM): HOMEASSISTANT_DOMAIN,
|
||||||
vol.Required(STATES): vol.All(
|
vol.Required(STATES): vol.All(
|
||||||
cv.ensure_list,
|
cv.ensure_list,
|
||||||
[
|
[
|
||||||
@ -206,7 +206,7 @@ async def async_setup_platform(
|
|||||||
|
|
||||||
# Extract only the config for the Home Assistant platform, ignore the rest.
|
# Extract only the config for the Home Assistant platform, ignore the rest.
|
||||||
for p_type, p_config in conf_util.config_per_platform(conf, SCENE_DOMAIN):
|
for p_type, p_config in conf_util.config_per_platform(conf, SCENE_DOMAIN):
|
||||||
if p_type != HA_DOMAIN:
|
if p_type != HOMEASSISTANT_DOMAIN:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
_process_scenes_config(hass, async_add_entities, p_config)
|
_process_scenes_config(hass, async_add_entities, p_config)
|
||||||
|
@ -1,32 +1,32 @@
|
|||||||
"""Exceptions raised by Intergas InComfort integration."""
|
"""Exceptions raised by Intergas InComfort integration."""
|
||||||
|
|
||||||
from homeassistant.core import DOMAIN
|
from homeassistant.core import DOMAIN as HOMEASSISTANT_DOMAIN
|
||||||
from homeassistant.exceptions import ConfigEntryNotReady, HomeAssistantError
|
from homeassistant.exceptions import ConfigEntryNotReady, HomeAssistantError
|
||||||
|
|
||||||
|
|
||||||
class NotFound(HomeAssistantError):
|
class NotFound(HomeAssistantError):
|
||||||
"""Raise exception if no Lan2RF Gateway was found."""
|
"""Raise exception if no Lan2RF Gateway was found."""
|
||||||
|
|
||||||
translation_domain = DOMAIN
|
translation_domain = HOMEASSISTANT_DOMAIN
|
||||||
translation_key = "not_found"
|
translation_key = "not_found"
|
||||||
|
|
||||||
|
|
||||||
class NoHeaters(ConfigEntryNotReady):
|
class NoHeaters(ConfigEntryNotReady):
|
||||||
"""Raise exception if no heaters are found."""
|
"""Raise exception if no heaters are found."""
|
||||||
|
|
||||||
translation_domain = DOMAIN
|
translation_domain = HOMEASSISTANT_DOMAIN
|
||||||
translation_key = "no_heaters"
|
translation_key = "no_heaters"
|
||||||
|
|
||||||
|
|
||||||
class InConfortTimeout(ConfigEntryNotReady):
|
class InConfortTimeout(ConfigEntryNotReady):
|
||||||
"""Raise exception if no heaters are found."""
|
"""Raise exception if no heaters are found."""
|
||||||
|
|
||||||
translation_domain = DOMAIN
|
translation_domain = HOMEASSISTANT_DOMAIN
|
||||||
translation_key = "timeout_error"
|
translation_key = "timeout_error"
|
||||||
|
|
||||||
|
|
||||||
class InConfortUnknownError(ConfigEntryNotReady):
|
class InConfortUnknownError(ConfigEntryNotReady):
|
||||||
"""Raise exception if no heaters are found."""
|
"""Raise exception if no heaters are found."""
|
||||||
|
|
||||||
translation_domain = DOMAIN
|
translation_domain = HOMEASSISTANT_DOMAIN
|
||||||
translation_key = "unknown"
|
translation_key = "unknown"
|
||||||
|
@ -35,7 +35,7 @@ from homeassistant.const import (
|
|||||||
SERVICE_TURN_OFF,
|
SERVICE_TURN_OFF,
|
||||||
SERVICE_TURN_ON,
|
SERVICE_TURN_ON,
|
||||||
)
|
)
|
||||||
from homeassistant.core import DOMAIN as HA_DOMAIN, HomeAssistant, State
|
from homeassistant.core import DOMAIN as HOMEASSISTANT_DOMAIN, HomeAssistant, State
|
||||||
from homeassistant.helpers import config_validation as cv, integration_platform, intent
|
from homeassistant.helpers import config_validation as cv, integration_platform, intent
|
||||||
from homeassistant.helpers.typing import ConfigType
|
from homeassistant.helpers.typing import ConfigType
|
||||||
|
|
||||||
@ -82,7 +82,7 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
|||||||
hass,
|
hass,
|
||||||
OnOffIntentHandler(
|
OnOffIntentHandler(
|
||||||
intent.INTENT_TURN_ON,
|
intent.INTENT_TURN_ON,
|
||||||
HA_DOMAIN,
|
HOMEASSISTANT_DOMAIN,
|
||||||
SERVICE_TURN_ON,
|
SERVICE_TURN_ON,
|
||||||
description="Turns on/opens a device or entity",
|
description="Turns on/opens a device or entity",
|
||||||
),
|
),
|
||||||
@ -91,7 +91,7 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
|||||||
hass,
|
hass,
|
||||||
OnOffIntentHandler(
|
OnOffIntentHandler(
|
||||||
intent.INTENT_TURN_OFF,
|
intent.INTENT_TURN_OFF,
|
||||||
HA_DOMAIN,
|
HOMEASSISTANT_DOMAIN,
|
||||||
SERVICE_TURN_OFF,
|
SERVICE_TURN_OFF,
|
||||||
description="Turns off/closes a device or entity",
|
description="Turns off/closes a device or entity",
|
||||||
),
|
),
|
||||||
@ -100,7 +100,7 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
|||||||
hass,
|
hass,
|
||||||
intent.ServiceIntentHandler(
|
intent.ServiceIntentHandler(
|
||||||
intent.INTENT_TOGGLE,
|
intent.INTENT_TOGGLE,
|
||||||
HA_DOMAIN,
|
HOMEASSISTANT_DOMAIN,
|
||||||
SERVICE_TOGGLE,
|
SERVICE_TOGGLE,
|
||||||
description="Toggles a device or entity",
|
description="Toggles a device or entity",
|
||||||
),
|
),
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
"""Base entity for the Ping component."""
|
"""Base entity for the Ping component."""
|
||||||
|
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.core import DOMAIN
|
from homeassistant.core import DOMAIN as HOMEASSISTANT_DOMAIN
|
||||||
from homeassistant.helpers.device_registry import DeviceInfo
|
from homeassistant.helpers.device_registry import DeviceInfo
|
||||||
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
||||||
|
|
||||||
@ -24,6 +24,6 @@ class PingEntity(CoordinatorEntity[PingUpdateCoordinator]):
|
|||||||
|
|
||||||
self._attr_unique_id = unique_id
|
self._attr_unique_id = unique_id
|
||||||
self._attr_device_info = DeviceInfo(
|
self._attr_device_info = DeviceInfo(
|
||||||
identifiers={(DOMAIN, config_entry.entry_id)},
|
identifiers={(HOMEASSISTANT_DOMAIN, config_entry.entry_id)},
|
||||||
manufacturer="Ping",
|
manufacturer="Ping",
|
||||||
)
|
)
|
||||||
|
@ -12,7 +12,7 @@ import voluptuous as vol
|
|||||||
from homeassistant.components.light import ATTR_TRANSITION
|
from homeassistant.components.light import ATTR_TRANSITION
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import CONF_PLATFORM, SERVICE_TURN_ON, STATE_UNAVAILABLE
|
from homeassistant.const import CONF_PLATFORM, SERVICE_TURN_ON, STATE_UNAVAILABLE
|
||||||
from homeassistant.core import DOMAIN as HA_DOMAIN, HomeAssistant
|
from homeassistant.core import DOMAIN as HOMEASSISTANT_DOMAIN, HomeAssistant
|
||||||
from homeassistant.helpers.entity_component import EntityComponent
|
from homeassistant.helpers.entity_component import EntityComponent
|
||||||
from homeassistant.helpers.restore_state import RestoreEntity
|
from homeassistant.helpers.restore_state import RestoreEntity
|
||||||
from homeassistant.helpers.typing import ConfigType
|
from homeassistant.helpers.typing import ConfigType
|
||||||
@ -25,7 +25,7 @@ STATES: Final = "states"
|
|||||||
def _hass_domain_validator(config: dict[str, Any]) -> dict[str, Any]:
|
def _hass_domain_validator(config: dict[str, Any]) -> dict[str, Any]:
|
||||||
"""Validate platform in config for homeassistant domain."""
|
"""Validate platform in config for homeassistant domain."""
|
||||||
if CONF_PLATFORM not in config:
|
if CONF_PLATFORM not in config:
|
||||||
config = {CONF_PLATFORM: HA_DOMAIN, STATES: config}
|
config = {CONF_PLATFORM: HOMEASSISTANT_DOMAIN, STATES: config}
|
||||||
|
|
||||||
return config
|
return config
|
||||||
|
|
||||||
@ -67,7 +67,9 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
|||||||
await component.async_setup(config)
|
await component.async_setup(config)
|
||||||
# Ensure Home Assistant platform always loaded.
|
# Ensure Home Assistant platform always loaded.
|
||||||
hass.async_create_task(
|
hass.async_create_task(
|
||||||
component.async_setup_platform(HA_DOMAIN, {"platform": HA_DOMAIN, STATES: []}),
|
component.async_setup_platform(
|
||||||
|
HOMEASSISTANT_DOMAIN, {"platform": HOMEASSISTANT_DOMAIN, STATES: []}
|
||||||
|
),
|
||||||
eager_start=True,
|
eager_start=True,
|
||||||
)
|
)
|
||||||
component.async_register_entity_service(
|
component.async_register_entity_service(
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
"""Base entity for Streamlabs integration."""
|
"""Base entity for Streamlabs integration."""
|
||||||
|
|
||||||
from homeassistant.core import DOMAIN
|
from homeassistant.core import DOMAIN as HOMEASSISTANT_DOMAIN
|
||||||
from homeassistant.helpers.device_registry import DeviceInfo
|
from homeassistant.helpers.device_registry import DeviceInfo
|
||||||
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
||||||
|
|
||||||
@ -23,7 +23,8 @@ class StreamlabsWaterEntity(CoordinatorEntity[StreamlabsCoordinator]):
|
|||||||
self._location_id = location_id
|
self._location_id = location_id
|
||||||
self._attr_unique_id = f"{location_id}-{key}"
|
self._attr_unique_id = f"{location_id}-{key}"
|
||||||
self._attr_device_info = DeviceInfo(
|
self._attr_device_info = DeviceInfo(
|
||||||
identifiers={(DOMAIN, location_id)}, name=self.location_data.name
|
identifiers={(HOMEASSISTANT_DOMAIN, location_id)},
|
||||||
|
name=self.location_data.name,
|
||||||
)
|
)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -60,7 +60,7 @@ from .const import (
|
|||||||
LEGACY_CONF_WHITELIST_EXTERNAL_DIRS,
|
LEGACY_CONF_WHITELIST_EXTERNAL_DIRS,
|
||||||
__version__,
|
__version__,
|
||||||
)
|
)
|
||||||
from .core import DOMAIN as HA_DOMAIN, ConfigSource, HomeAssistant, callback
|
from .core import DOMAIN as HOMEASSISTANT_DOMAIN, ConfigSource, HomeAssistant, callback
|
||||||
from .exceptions import ConfigValidationError, HomeAssistantError
|
from .exceptions import ConfigValidationError, HomeAssistantError
|
||||||
from .generated.currencies import HISTORIC_CURRENCIES
|
from .generated.currencies import HISTORIC_CURRENCIES
|
||||||
from .helpers import config_validation as cv, issue_registry as ir
|
from .helpers import config_validation as cv, issue_registry as ir
|
||||||
@ -261,12 +261,12 @@ CUSTOMIZE_CONFIG_SCHEMA = vol.Schema(
|
|||||||
|
|
||||||
def _raise_issue_if_historic_currency(hass: HomeAssistant, currency: str) -> None:
|
def _raise_issue_if_historic_currency(hass: HomeAssistant, currency: str) -> None:
|
||||||
if currency not in HISTORIC_CURRENCIES:
|
if currency not in HISTORIC_CURRENCIES:
|
||||||
ir.async_delete_issue(hass, HA_DOMAIN, "historic_currency")
|
ir.async_delete_issue(hass, HOMEASSISTANT_DOMAIN, "historic_currency")
|
||||||
return
|
return
|
||||||
|
|
||||||
ir.async_create_issue(
|
ir.async_create_issue(
|
||||||
hass,
|
hass,
|
||||||
HA_DOMAIN,
|
HOMEASSISTANT_DOMAIN,
|
||||||
"historic_currency",
|
"historic_currency",
|
||||||
is_fixable=False,
|
is_fixable=False,
|
||||||
learn_more_url="homeassistant://config/general",
|
learn_more_url="homeassistant://config/general",
|
||||||
@ -278,12 +278,12 @@ def _raise_issue_if_historic_currency(hass: HomeAssistant, currency: str) -> Non
|
|||||||
|
|
||||||
def _raise_issue_if_no_country(hass: HomeAssistant, country: str | None) -> None:
|
def _raise_issue_if_no_country(hass: HomeAssistant, country: str | None) -> None:
|
||||||
if country is not None:
|
if country is not None:
|
||||||
ir.async_delete_issue(hass, HA_DOMAIN, "country_not_configured")
|
ir.async_delete_issue(hass, HOMEASSISTANT_DOMAIN, "country_not_configured")
|
||||||
return
|
return
|
||||||
|
|
||||||
ir.async_create_issue(
|
ir.async_create_issue(
|
||||||
hass,
|
hass,
|
||||||
HA_DOMAIN,
|
HOMEASSISTANT_DOMAIN,
|
||||||
"country_not_configured",
|
"country_not_configured",
|
||||||
is_fixable=False,
|
is_fixable=False,
|
||||||
learn_more_url="homeassistant://config/general",
|
learn_more_url="homeassistant://config/general",
|
||||||
@ -481,12 +481,14 @@ async def async_hass_config_yaml(hass: HomeAssistant) -> dict:
|
|||||||
for invalid_domain in invalid_domains:
|
for invalid_domain in invalid_domains:
|
||||||
config.pop(invalid_domain)
|
config.pop(invalid_domain)
|
||||||
|
|
||||||
core_config = config.get(HA_DOMAIN, {})
|
core_config = config.get(HOMEASSISTANT_DOMAIN, {})
|
||||||
try:
|
try:
|
||||||
await merge_packages_config(hass, config, core_config.get(CONF_PACKAGES, {}))
|
await merge_packages_config(hass, config, core_config.get(CONF_PACKAGES, {}))
|
||||||
except vol.Invalid as exc:
|
except vol.Invalid as exc:
|
||||||
suffix = ""
|
suffix = ""
|
||||||
if annotation := find_annotation(config, [HA_DOMAIN, CONF_PACKAGES, *exc.path]):
|
if annotation := find_annotation(
|
||||||
|
config, [HOMEASSISTANT_DOMAIN, CONF_PACKAGES, *exc.path]
|
||||||
|
):
|
||||||
suffix = f" at {_relpath(hass, annotation[0])}, line {annotation[1]}"
|
suffix = f" at {_relpath(hass, annotation[0])}, line {annotation[1]}"
|
||||||
_LOGGER.error(
|
_LOGGER.error(
|
||||||
"Invalid package configuration '%s'%s: %s", CONF_PACKAGES, suffix, exc
|
"Invalid package configuration '%s'%s: %s", CONF_PACKAGES, suffix, exc
|
||||||
@ -709,7 +711,7 @@ def stringify_invalid(
|
|||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
message_prefix = f"Invalid config for '{domain}'"
|
message_prefix = f"Invalid config for '{domain}'"
|
||||||
if domain != HA_DOMAIN and link:
|
if domain != HOMEASSISTANT_DOMAIN and link:
|
||||||
message_suffix = f", please check the docs at {link}"
|
message_suffix = f", please check the docs at {link}"
|
||||||
else:
|
else:
|
||||||
message_suffix = ""
|
message_suffix = ""
|
||||||
@ -792,7 +794,7 @@ def format_homeassistant_error(
|
|||||||
if annotation := find_annotation(config, [domain]):
|
if annotation := find_annotation(config, [domain]):
|
||||||
message_prefix += f" at {_relpath(hass, annotation[0])}, line {annotation[1]}"
|
message_prefix += f" at {_relpath(hass, annotation[0])}, line {annotation[1]}"
|
||||||
message = f"{message_prefix}: {str(exc) or repr(exc)}"
|
message = f"{message_prefix}: {str(exc) or repr(exc)}"
|
||||||
if domain != HA_DOMAIN and link:
|
if domain != HOMEASSISTANT_DOMAIN and link:
|
||||||
message += f", please check the docs at {link}"
|
message += f", please check the docs at {link}"
|
||||||
|
|
||||||
return message
|
return message
|
||||||
@ -916,7 +918,7 @@ async def async_process_ha_core_config(hass: HomeAssistant, config: dict) -> Non
|
|||||||
cust_glob = OrderedDict(config[CONF_CUSTOMIZE_GLOB])
|
cust_glob = OrderedDict(config[CONF_CUSTOMIZE_GLOB])
|
||||||
|
|
||||||
for name, pkg in config[CONF_PACKAGES].items():
|
for name, pkg in config[CONF_PACKAGES].items():
|
||||||
if (pkg_cust := pkg.get(HA_DOMAIN)) is None:
|
if (pkg_cust := pkg.get(HOMEASSISTANT_DOMAIN)) is None:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@ -940,7 +942,9 @@ def _log_pkg_error(
|
|||||||
) -> None:
|
) -> None:
|
||||||
"""Log an error while merging packages."""
|
"""Log an error while merging packages."""
|
||||||
message_prefix = f"Setup of package '{package}'"
|
message_prefix = f"Setup of package '{package}'"
|
||||||
if annotation := find_annotation(config, [HA_DOMAIN, CONF_PACKAGES, package]):
|
if annotation := find_annotation(
|
||||||
|
config, [HOMEASSISTANT_DOMAIN, CONF_PACKAGES, package]
|
||||||
|
):
|
||||||
message_prefix += f" at {_relpath(hass, annotation[0])}, line {annotation[1]}"
|
message_prefix += f" at {_relpath(hass, annotation[0])}, line {annotation[1]}"
|
||||||
|
|
||||||
_LOGGER.error("%s failed: %s", message_prefix, message)
|
_LOGGER.error("%s failed: %s", message_prefix, message)
|
||||||
@ -1055,7 +1059,7 @@ async def merge_packages_config(
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
for comp_name, comp_conf in pack_conf.items():
|
for comp_name, comp_conf in pack_conf.items():
|
||||||
if comp_name == HA_DOMAIN:
|
if comp_name == HOMEASSISTANT_DOMAIN:
|
||||||
continue
|
continue
|
||||||
try:
|
try:
|
||||||
domain = cv.domain_key(comp_name)
|
domain = cv.domain_key(comp_name)
|
||||||
@ -1200,7 +1204,7 @@ def _get_log_message_and_stack_print_pref(
|
|||||||
|
|
||||||
# Generate the log message from the English translations
|
# Generate the log message from the English translations
|
||||||
log_message = async_get_exception_message(
|
log_message = async_get_exception_message(
|
||||||
HA_DOMAIN,
|
HOMEASSISTANT_DOMAIN,
|
||||||
platform_exception.translation_key,
|
platform_exception.translation_key,
|
||||||
translation_placeholders=placeholders,
|
translation_placeholders=placeholders,
|
||||||
)
|
)
|
||||||
@ -1261,7 +1265,7 @@ def async_drop_config_annotations(
|
|||||||
|
|
||||||
# Don't drop annotations from the homeassistant integration because it may
|
# Don't drop annotations from the homeassistant integration because it may
|
||||||
# have configuration for other integrations as packages.
|
# have configuration for other integrations as packages.
|
||||||
if integration.domain in config and integration.domain != HA_DOMAIN:
|
if integration.domain in config and integration.domain != HOMEASSISTANT_DOMAIN:
|
||||||
drop_config_annotations_rec(config[integration.domain])
|
drop_config_annotations_rec(config[integration.domain])
|
||||||
return config
|
return config
|
||||||
|
|
||||||
@ -1313,7 +1317,7 @@ def async_handle_component_errors(
|
|||||||
raise ConfigValidationError(
|
raise ConfigValidationError(
|
||||||
translation_key,
|
translation_key,
|
||||||
[platform_exception.exception for platform_exception in config_exception_info],
|
[platform_exception.exception for platform_exception in config_exception_info],
|
||||||
translation_domain=HA_DOMAIN,
|
translation_domain=HOMEASSISTANT_DOMAIN,
|
||||||
translation_placeholders=placeholders,
|
translation_placeholders=placeholders,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ from .components import persistent_notification
|
|||||||
from .const import EVENT_HOMEASSISTANT_STARTED, EVENT_HOMEASSISTANT_STOP, Platform
|
from .const import EVENT_HOMEASSISTANT_STARTED, EVENT_HOMEASSISTANT_STOP, Platform
|
||||||
from .core import (
|
from .core import (
|
||||||
CALLBACK_TYPE,
|
CALLBACK_TYPE,
|
||||||
DOMAIN as HA_DOMAIN,
|
DOMAIN as HOMEASSISTANT_DOMAIN,
|
||||||
CoreState,
|
CoreState,
|
||||||
Event,
|
Event,
|
||||||
HassJob,
|
HassJob,
|
||||||
@ -1049,7 +1049,7 @@ class ConfigEntry(Generic[_DataT]):
|
|||||||
issue_id = f"config_entry_reauth_{self.domain}_{self.entry_id}"
|
issue_id = f"config_entry_reauth_{self.domain}_{self.entry_id}"
|
||||||
ir.async_create_issue(
|
ir.async_create_issue(
|
||||||
hass,
|
hass,
|
||||||
HA_DOMAIN,
|
HOMEASSISTANT_DOMAIN,
|
||||||
issue_id,
|
issue_id,
|
||||||
data={"flow_id": result["flow_id"]},
|
data={"flow_id": result["flow_id"]},
|
||||||
is_fixable=False,
|
is_fixable=False,
|
||||||
@ -1254,7 +1254,7 @@ class ConfigEntriesFlowManager(data_entry_flow.FlowManager[ConfigFlowResult]):
|
|||||||
flow_id=flow_id,
|
flow_id=flow_id,
|
||||||
handler=handler,
|
handler=handler,
|
||||||
reason="single_instance_allowed",
|
reason="single_instance_allowed",
|
||||||
translation_domain=HA_DOMAIN,
|
translation_domain=HOMEASSISTANT_DOMAIN,
|
||||||
)
|
)
|
||||||
|
|
||||||
loop = self.hass.loop
|
loop = self.hass.loop
|
||||||
@ -1343,7 +1343,7 @@ class ConfigEntriesFlowManager(data_entry_flow.FlowManager[ConfigFlowResult]):
|
|||||||
entry := self.config_entries.async_get_entry(entry_id)
|
entry := self.config_entries.async_get_entry(entry_id)
|
||||||
) is not None:
|
) is not None:
|
||||||
issue_id = f"config_entry_reauth_{entry.domain}_{entry.entry_id}"
|
issue_id = f"config_entry_reauth_{entry.domain}_{entry.entry_id}"
|
||||||
ir.async_delete_issue(self.hass, HA_DOMAIN, issue_id)
|
ir.async_delete_issue(self.hass, HOMEASSISTANT_DOMAIN, issue_id)
|
||||||
|
|
||||||
if result["type"] != data_entry_flow.FlowResultType.CREATE_ENTRY:
|
if result["type"] != data_entry_flow.FlowResultType.CREATE_ENTRY:
|
||||||
return result
|
return result
|
||||||
@ -1360,7 +1360,7 @@ class ConfigEntriesFlowManager(data_entry_flow.FlowManager[ConfigFlowResult]):
|
|||||||
flow_id=flow.flow_id,
|
flow_id=flow.flow_id,
|
||||||
handler=flow.handler,
|
handler=flow.handler,
|
||||||
reason="single_instance_allowed",
|
reason="single_instance_allowed",
|
||||||
translation_domain=HA_DOMAIN,
|
translation_domain=HOMEASSISTANT_DOMAIN,
|
||||||
)
|
)
|
||||||
|
|
||||||
# Check if config entry exists with unique ID. Unload it.
|
# Check if config entry exists with unique ID. Unload it.
|
||||||
@ -1752,7 +1752,7 @@ class ConfigEntries:
|
|||||||
if "flow_id" in progress_flow:
|
if "flow_id" in progress_flow:
|
||||||
self.hass.config_entries.flow.async_abort(progress_flow["flow_id"])
|
self.hass.config_entries.flow.async_abort(progress_flow["flow_id"])
|
||||||
issue_id = f"config_entry_reauth_{entry.domain}_{entry.entry_id}"
|
issue_id = f"config_entry_reauth_{entry.domain}_{entry.entry_id}"
|
||||||
ir.async_delete_issue(self.hass, HA_DOMAIN, issue_id)
|
ir.async_delete_issue(self.hass, HOMEASSISTANT_DOMAIN, issue_id)
|
||||||
|
|
||||||
# After we have fully removed an "ignore" config entry we can try and rediscover
|
# After we have fully removed an "ignore" config entry we can try and rediscover
|
||||||
# it so that a user is able to immediately start configuring it. We do this by
|
# it so that a user is able to immediately start configuring it. We do this by
|
||||||
|
@ -22,7 +22,7 @@ from homeassistant.config import ( # type: ignore[attr-defined]
|
|||||||
load_yaml_config_file,
|
load_yaml_config_file,
|
||||||
merge_packages_config,
|
merge_packages_config,
|
||||||
)
|
)
|
||||||
from homeassistant.core import DOMAIN as HA_DOMAIN, HomeAssistant
|
from homeassistant.core import DOMAIN as HOMEASSISTANT_DOMAIN, HomeAssistant
|
||||||
from homeassistant.exceptions import HomeAssistantError
|
from homeassistant.exceptions import HomeAssistantError
|
||||||
from homeassistant.requirements import (
|
from homeassistant.requirements import (
|
||||||
RequirementsNotFound,
|
RequirementsNotFound,
|
||||||
@ -157,10 +157,10 @@ async def async_check_ha_config_file( # noqa: C901
|
|||||||
return result.add_error(f"Error loading {config_path}: {err}")
|
return result.add_error(f"Error loading {config_path}: {err}")
|
||||||
|
|
||||||
# Extract and validate core [homeassistant] config
|
# Extract and validate core [homeassistant] config
|
||||||
core_config = config.pop(HA_DOMAIN, {})
|
core_config = config.pop(HOMEASSISTANT_DOMAIN, {})
|
||||||
try:
|
try:
|
||||||
core_config = CORE_CONFIG_SCHEMA(core_config)
|
core_config = CORE_CONFIG_SCHEMA(core_config)
|
||||||
result[HA_DOMAIN] = core_config
|
result[HOMEASSISTANT_DOMAIN] = core_config
|
||||||
|
|
||||||
# Merge packages
|
# Merge packages
|
||||||
await merge_packages_config(
|
await merge_packages_config(
|
||||||
@ -168,8 +168,8 @@ async def async_check_ha_config_file( # noqa: C901
|
|||||||
)
|
)
|
||||||
except vol.Invalid as err:
|
except vol.Invalid as err:
|
||||||
result.add_error(
|
result.add_error(
|
||||||
format_schema_error(hass, err, HA_DOMAIN, core_config),
|
format_schema_error(hass, err, HOMEASSISTANT_DOMAIN, core_config),
|
||||||
HA_DOMAIN,
|
HOMEASSISTANT_DOMAIN,
|
||||||
core_config,
|
core_config,
|
||||||
)
|
)
|
||||||
core_config = {}
|
core_config = {}
|
||||||
|
@ -4,7 +4,7 @@ from __future__ import annotations
|
|||||||
|
|
||||||
import ast
|
import ast
|
||||||
|
|
||||||
from homeassistant.core import DOMAIN as HA_DOMAIN
|
from homeassistant.core import DOMAIN as HOMEASSISTANT_DOMAIN
|
||||||
|
|
||||||
from .model import Config, Integration
|
from .model import Config, Integration
|
||||||
|
|
||||||
@ -12,7 +12,7 @@ CONFIG_SCHEMA_IGNORE = {
|
|||||||
# Configuration under the homeassistant key is a special case, it's handled by
|
# Configuration under the homeassistant key is a special case, it's handled by
|
||||||
# conf_util.async_process_ha_core_config already during bootstrapping, not by
|
# conf_util.async_process_ha_core_config already during bootstrapping, not by
|
||||||
# a schema in the homeassistant integration.
|
# a schema in the homeassistant integration.
|
||||||
HA_DOMAIN,
|
HOMEASSISTANT_DOMAIN,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user