Adjust entity registry access in core platforms (#88944)

* Adjust entity registry access in platforms

* Adjust more core components
This commit is contained in:
epenet 2023-03-01 08:02:16 +01:00 committed by GitHub
parent 50f908ce2d
commit f2b736fad0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
37 changed files with 154 additions and 121 deletions

View file

@ -6,15 +6,12 @@ from typing import TYPE_CHECKING
import attr import attr
if TYPE_CHECKING: if TYPE_CHECKING:
from homeassistant.helpers import ( from homeassistant.helpers import device_registry as dr, entity_registry as er
device_registry as dev_reg,
entity_registry as ent_reg,
)
@attr.s(slots=True) @attr.s(slots=True)
class PermissionLookup: class PermissionLookup:
"""Class to hold data for permission lookups.""" """Class to hold data for permission lookups."""
entity_registry: ent_reg.EntityRegistry = attr.ib() entity_registry: er.EntityRegistry = attr.ib()
device_registry: dev_reg.DeviceRegistry = attr.ib() device_registry: dr.DeviceRegistry = attr.ib()

View file

@ -21,7 +21,7 @@ from homeassistant.const import (
SERVICE_ALARM_TRIGGER, SERVICE_ALARM_TRIGGER,
) )
from homeassistant.core import Context, HomeAssistant from homeassistant.core import Context, HomeAssistant
from homeassistant.helpers import entity_registry from homeassistant.helpers import entity_registry as er
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity import get_supported_features from homeassistant.helpers.entity import get_supported_features
from homeassistant.helpers.typing import ConfigType, TemplateVarsType from homeassistant.helpers.typing import ConfigType, TemplateVarsType
@ -57,11 +57,11 @@ async def async_get_actions(
hass: HomeAssistant, device_id: str hass: HomeAssistant, device_id: str
) -> list[dict[str, str]]: ) -> list[dict[str, str]]:
"""List device actions for Alarm control panel devices.""" """List device actions for Alarm control panel devices."""
registry = entity_registry.async_get(hass) registry = er.async_get(hass)
actions = [] actions = []
# Get all the integrations entities for this device # Get all the integrations entities for this device
for entry in entity_registry.async_entries_for_device(registry, device_id): for entry in er.async_entries_for_device(registry, device_id):
if entry.domain != DOMAIN: if entry.domain != DOMAIN:
continue continue

View file

@ -21,7 +21,11 @@ from homeassistant.const import (
STATE_ALARM_TRIGGERED, STATE_ALARM_TRIGGERED,
) )
from homeassistant.core import HomeAssistant, callback from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers import condition, config_validation as cv, entity_registry from homeassistant.helpers import (
condition,
config_validation as cv,
entity_registry as er,
)
from homeassistant.helpers.config_validation import DEVICE_CONDITION_BASE_SCHEMA from homeassistant.helpers.config_validation import DEVICE_CONDITION_BASE_SCHEMA
from homeassistant.helpers.entity import get_supported_features from homeassistant.helpers.entity import get_supported_features
from homeassistant.helpers.typing import ConfigType, TemplateVarsType from homeassistant.helpers.typing import ConfigType, TemplateVarsType
@ -64,11 +68,11 @@ async def async_get_conditions(
hass: HomeAssistant, device_id: str hass: HomeAssistant, device_id: str
) -> list[dict[str, str]]: ) -> list[dict[str, str]]:
"""List device conditions for Alarm control panel devices.""" """List device conditions for Alarm control panel devices."""
registry = entity_registry.async_get(hass) registry = er.async_get(hass)
conditions = [] conditions = []
# Get all the integrations entities for this device # Get all the integrations entities for this device
for entry in entity_registry.async_entries_for_device(registry, device_id): for entry in er.async_entries_for_device(registry, device_id):
if entry.domain != DOMAIN: if entry.domain != DOMAIN:
continue continue

View file

@ -23,7 +23,7 @@ from homeassistant.const import (
STATE_ALARM_TRIGGERED, STATE_ALARM_TRIGGERED,
) )
from homeassistant.core import CALLBACK_TYPE, HomeAssistant from homeassistant.core import CALLBACK_TYPE, HomeAssistant
from homeassistant.helpers import config_validation as cv, entity_registry from homeassistant.helpers import config_validation as cv, entity_registry as er
from homeassistant.helpers.entity import get_supported_features from homeassistant.helpers.entity import get_supported_features
from homeassistant.helpers.trigger import TriggerActionType, TriggerInfo from homeassistant.helpers.trigger import TriggerActionType, TriggerInfo
from homeassistant.helpers.typing import ConfigType from homeassistant.helpers.typing import ConfigType
@ -57,11 +57,11 @@ async def async_get_triggers(
hass: HomeAssistant, device_id: str hass: HomeAssistant, device_id: str
) -> list[dict[str, str]]: ) -> list[dict[str, str]]:
"""List device triggers for Alarm control panel devices.""" """List device triggers for Alarm control panel devices."""
registry = entity_registry.async_get(hass) registry = er.async_get(hass)
triggers: list[dict[str, str]] = [] triggers: list[dict[str, str]] = []
# Get all the integrations entities for this device # Get all the integrations entities for this device
for entry in entity_registry.async_entries_for_device(registry, device_id): for entry in er.async_entries_for_device(registry, device_id):
if entry.domain != DOMAIN: if entry.domain != DOMAIN:
continue continue

View file

@ -11,7 +11,7 @@ from homeassistant.const import (
CONF_TYPE, CONF_TYPE,
) )
from homeassistant.core import Context, HomeAssistant from homeassistant.core import Context, HomeAssistant
from homeassistant.helpers import entity_registry from homeassistant.helpers import entity_registry as er
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.typing import ConfigType, TemplateVarsType from homeassistant.helpers.typing import ConfigType, TemplateVarsType
@ -31,7 +31,7 @@ async def async_get_actions(
hass: HomeAssistant, device_id: str hass: HomeAssistant, device_id: str
) -> list[dict[str, str]]: ) -> list[dict[str, str]]:
"""List device actions for button devices.""" """List device actions for button devices."""
registry = entity_registry.async_get(hass) registry = er.async_get(hass)
return [ return [
{ {
CONF_DEVICE_ID: device_id, CONF_DEVICE_ID: device_id,
@ -39,7 +39,7 @@ async def async_get_actions(
CONF_ENTITY_ID: entry.entity_id, CONF_ENTITY_ID: entry.entity_id,
CONF_TYPE: "press", CONF_TYPE: "press",
} }
for entry in entity_registry.async_entries_for_device(registry, device_id) for entry in er.async_entries_for_device(registry, device_id)
if entry.domain == DOMAIN if entry.domain == DOMAIN
] ]

View file

@ -16,7 +16,7 @@ from homeassistant.const import (
CONF_TYPE, CONF_TYPE,
) )
from homeassistant.core import CALLBACK_TYPE, HomeAssistant from homeassistant.core import CALLBACK_TYPE, HomeAssistant
from homeassistant.helpers import config_validation as cv, entity_registry from homeassistant.helpers import config_validation as cv, entity_registry as er
from homeassistant.helpers.trigger import TriggerActionType, TriggerInfo from homeassistant.helpers.trigger import TriggerActionType, TriggerInfo
from homeassistant.helpers.typing import ConfigType from homeassistant.helpers.typing import ConfigType
@ -36,7 +36,7 @@ async def async_get_triggers(
hass: HomeAssistant, device_id: str hass: HomeAssistant, device_id: str
) -> list[dict[str, str]]: ) -> list[dict[str, str]]:
"""List device triggers for button devices.""" """List device triggers for button devices."""
registry = entity_registry.async_get(hass) registry = er.async_get(hass)
return [ return [
{ {
CONF_PLATFORM: "device", CONF_PLATFORM: "device",
@ -45,7 +45,7 @@ async def async_get_triggers(
CONF_ENTITY_ID: entry.entity_id, CONF_ENTITY_ID: entry.entity_id,
CONF_TYPE: "pressed", CONF_TYPE: "pressed",
} }
for entry in entity_registry.async_entries_for_device(registry, device_id) for entry in er.async_entries_for_device(registry, device_id)
if entry.domain == DOMAIN if entry.domain == DOMAIN
] ]

View file

@ -12,7 +12,7 @@ from homeassistant.const import (
) )
from homeassistant.core import Context, HomeAssistant from homeassistant.core import Context, HomeAssistant
from homeassistant.exceptions import HomeAssistantError from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers import entity_registry from homeassistant.helpers import entity_registry as er
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity import get_capability, get_supported_features from homeassistant.helpers.entity import get_capability, get_supported_features
from homeassistant.helpers.typing import ConfigType, TemplateVarsType from homeassistant.helpers.typing import ConfigType, TemplateVarsType
@ -44,11 +44,11 @@ async def async_get_actions(
hass: HomeAssistant, device_id: str hass: HomeAssistant, device_id: str
) -> list[dict[str, str]]: ) -> list[dict[str, str]]:
"""List device actions for Climate devices.""" """List device actions for Climate devices."""
registry = entity_registry.async_get(hass) registry = er.async_get(hass)
actions = [] actions = []
# Get all the integrations entities for this device # Get all the integrations entities for this device
for entry in entity_registry.async_entries_for_device(registry, device_id): for entry in er.async_entries_for_device(registry, device_id):
if entry.domain != DOMAIN: if entry.domain != DOMAIN:
continue continue

View file

@ -13,7 +13,11 @@ from homeassistant.const import (
) )
from homeassistant.core import HomeAssistant, callback from homeassistant.core import HomeAssistant, callback
from homeassistant.exceptions import HomeAssistantError from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers import condition, config_validation as cv, entity_registry from homeassistant.helpers import (
condition,
config_validation as cv,
entity_registry as er,
)
from homeassistant.helpers.config_validation import DEVICE_CONDITION_BASE_SCHEMA from homeassistant.helpers.config_validation import DEVICE_CONDITION_BASE_SCHEMA
from homeassistant.helpers.entity import get_capability, get_supported_features from homeassistant.helpers.entity import get_capability, get_supported_features
from homeassistant.helpers.typing import ConfigType, TemplateVarsType from homeassistant.helpers.typing import ConfigType, TemplateVarsType
@ -45,11 +49,11 @@ async def async_get_conditions(
hass: HomeAssistant, device_id: str hass: HomeAssistant, device_id: str
) -> list[dict[str, str]]: ) -> list[dict[str, str]]:
"""List device conditions for Climate devices.""" """List device conditions for Climate devices."""
registry = entity_registry.async_get(hass) registry = er.async_get(hass)
conditions = [] conditions = []
# Get all the integrations entities for this device # Get all the integrations entities for this device
for entry in entity_registry.async_entries_for_device(registry, device_id): for entry in er.async_entries_for_device(registry, device_id):
if entry.domain != DOMAIN: if entry.domain != DOMAIN:
continue continue

View file

@ -20,7 +20,7 @@ from homeassistant.const import (
PERCENTAGE, PERCENTAGE,
) )
from homeassistant.core import CALLBACK_TYPE, HomeAssistant from homeassistant.core import CALLBACK_TYPE, HomeAssistant
from homeassistant.helpers import config_validation as cv, entity_registry from homeassistant.helpers import config_validation as cv, entity_registry as er
from homeassistant.helpers.trigger import TriggerActionType, TriggerInfo from homeassistant.helpers.trigger import TriggerActionType, TriggerInfo
from homeassistant.helpers.typing import ConfigType from homeassistant.helpers.typing import ConfigType
@ -62,11 +62,11 @@ async def async_get_triggers(
hass: HomeAssistant, device_id: str hass: HomeAssistant, device_id: str
) -> list[dict[str, str]]: ) -> list[dict[str, str]]:
"""List device triggers for Climate devices.""" """List device triggers for Climate devices."""
registry = entity_registry.async_get(hass) registry = er.async_get(hass)
triggers = [] triggers = []
# Get all the integrations entities for this device # Get all the integrations entities for this device
for entry in entity_registry.async_entries_for_device(registry, device_id): for entry in er.async_entries_for_device(registry, device_id):
if entry.domain != DOMAIN: if entry.domain != DOMAIN:
continue continue

View file

@ -8,7 +8,7 @@ from homeassistant.components.automation.config import (
) )
from homeassistant.config import AUTOMATION_CONFIG_PATH from homeassistant.config import AUTOMATION_CONFIG_PATH
from homeassistant.const import CONF_ID, SERVICE_RELOAD from homeassistant.const import CONF_ID, SERVICE_RELOAD
from homeassistant.helpers import config_validation as cv, entity_registry from homeassistant.helpers import config_validation as cv, entity_registry as er
from . import ACTION_DELETE, EditIdBasedConfigView from . import ACTION_DELETE, EditIdBasedConfigView
@ -23,7 +23,7 @@ async def async_setup(hass):
if action != ACTION_DELETE: if action != ACTION_DELETE:
return return
ent_reg = entity_registry.async_get(hass) ent_reg = er.async_get(hass)
entity_id = ent_reg.async_get_entity_id(DOMAIN, DOMAIN, config_key) entity_id = ent_reg.async_get_entity_id(DOMAIN, DOMAIN, config_key)

View file

@ -5,7 +5,7 @@ from homeassistant.components.scene import DOMAIN, PLATFORM_SCHEMA
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 from homeassistant.core import DOMAIN as HA_DOMAIN
from homeassistant.helpers import config_validation as cv, entity_registry from homeassistant.helpers import config_validation as cv, entity_registry as er
from . import ACTION_DELETE, EditIdBasedConfigView from . import ACTION_DELETE, EditIdBasedConfigView
@ -19,7 +19,7 @@ async def async_setup(hass):
await hass.services.async_call(DOMAIN, SERVICE_RELOAD) await hass.services.async_call(DOMAIN, SERVICE_RELOAD)
return return
ent_reg = entity_registry.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, HA_DOMAIN, config_key)

View file

@ -18,7 +18,7 @@ from homeassistant.const import (
SERVICE_STOP_COVER, SERVICE_STOP_COVER,
) )
from homeassistant.core import Context, HomeAssistant from homeassistant.core import Context, HomeAssistant
from homeassistant.helpers import entity_registry from homeassistant.helpers import entity_registry as er
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity import get_supported_features from homeassistant.helpers.entity import get_supported_features
from homeassistant.helpers.typing import ConfigType, TemplateVarsType from homeassistant.helpers.typing import ConfigType, TemplateVarsType
@ -63,11 +63,11 @@ async def async_get_actions(
hass: HomeAssistant, device_id: str hass: HomeAssistant, device_id: str
) -> list[dict[str, str]]: ) -> list[dict[str, str]]:
"""List device actions for Cover devices.""" """List device actions for Cover devices."""
registry = entity_registry.async_get(hass) registry = er.async_get(hass)
actions = [] actions = []
# Get all the integrations entities for this device # Get all the integrations entities for this device
for entry in entity_registry.async_entries_for_device(registry, device_id): for entry in er.async_entries_for_device(registry, device_id):
if entry.domain != DOMAIN: if entry.domain != DOMAIN:
continue continue

View file

@ -18,7 +18,11 @@ from homeassistant.const import (
STATE_OPENING, STATE_OPENING,
) )
from homeassistant.core import HomeAssistant, callback from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers import condition, config_validation as cv, entity_registry from homeassistant.helpers import (
condition,
config_validation as cv,
entity_registry as er,
)
from homeassistant.helpers.config_validation import DEVICE_CONDITION_BASE_SCHEMA from homeassistant.helpers.config_validation import DEVICE_CONDITION_BASE_SCHEMA
from homeassistant.helpers.entity import get_supported_features from homeassistant.helpers.entity import get_supported_features
from homeassistant.helpers.typing import ConfigType, TemplateVarsType from homeassistant.helpers.typing import ConfigType, TemplateVarsType
@ -66,11 +70,11 @@ async def async_get_conditions(
hass: HomeAssistant, device_id: str hass: HomeAssistant, device_id: str
) -> list[dict[str, str]]: ) -> list[dict[str, str]]:
"""List device conditions for Cover devices.""" """List device conditions for Cover devices."""
registry = entity_registry.async_get(hass) registry = er.async_get(hass)
conditions: list[dict[str, str]] = [] conditions: list[dict[str, str]] = []
# Get all the integrations entities for this device # Get all the integrations entities for this device
for entry in entity_registry.async_entries_for_device(registry, device_id): for entry in er.async_entries_for_device(registry, device_id):
if entry.domain != DOMAIN: if entry.domain != DOMAIN:
continue continue

View file

@ -24,7 +24,7 @@ from homeassistant.const import (
STATE_OPENING, STATE_OPENING,
) )
from homeassistant.core import CALLBACK_TYPE, HomeAssistant from homeassistant.core import CALLBACK_TYPE, HomeAssistant
from homeassistant.helpers import config_validation as cv, entity_registry from homeassistant.helpers import config_validation as cv, entity_registry as er
from homeassistant.helpers.entity import get_supported_features from homeassistant.helpers.entity import get_supported_features
from homeassistant.helpers.trigger import TriggerActionType, TriggerInfo from homeassistant.helpers.trigger import TriggerActionType, TriggerInfo
from homeassistant.helpers.typing import ConfigType from homeassistant.helpers.typing import ConfigType
@ -71,11 +71,11 @@ async def async_get_triggers(
hass: HomeAssistant, device_id: str hass: HomeAssistant, device_id: str
) -> list[dict[str, str]]: ) -> list[dict[str, str]]:
"""List device triggers for Cover devices.""" """List device triggers for Cover devices."""
registry = entity_registry.async_get(hass) registry = er.async_get(hass)
triggers = [] triggers = []
# Get all the integrations entities for this device # Get all the integrations entities for this device
for entry in entity_registry.async_entries_for_device(registry, device_id): for entry in er.async_entries_for_device(registry, device_id):
if entry.domain != DOMAIN: if entry.domain != DOMAIN:
continue continue

View file

@ -13,7 +13,11 @@ from homeassistant.const import (
STATE_HOME, STATE_HOME,
) )
from homeassistant.core import HomeAssistant, callback from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers import condition, config_validation as cv, entity_registry from homeassistant.helpers import (
condition,
config_validation as cv,
entity_registry as er,
)
from homeassistant.helpers.config_validation import DEVICE_CONDITION_BASE_SCHEMA from homeassistant.helpers.config_validation import DEVICE_CONDITION_BASE_SCHEMA
from homeassistant.helpers.typing import ConfigType, TemplateVarsType from homeassistant.helpers.typing import ConfigType, TemplateVarsType
@ -33,11 +37,11 @@ async def async_get_conditions(
hass: HomeAssistant, device_id: str hass: HomeAssistant, device_id: str
) -> list[dict[str, str]]: ) -> list[dict[str, str]]:
"""List device conditions for Device tracker devices.""" """List device conditions for Device tracker devices."""
registry = entity_registry.async_get(hass) registry = er.async_get(hass)
conditions = [] conditions = []
# Get all the integrations entities for this device # Get all the integrations entities for this device
for entry in entity_registry.async_entries_for_device(registry, device_id): for entry in er.async_entries_for_device(registry, device_id):
if entry.domain != DOMAIN: if entry.domain != DOMAIN:
continue continue

View file

@ -17,7 +17,7 @@ from homeassistant.const import (
CONF_ZONE, CONF_ZONE,
) )
from homeassistant.core import CALLBACK_TYPE, HomeAssistant from homeassistant.core import CALLBACK_TYPE, HomeAssistant
from homeassistant.helpers import config_validation as cv, entity_registry from homeassistant.helpers import config_validation as cv, entity_registry as er
from homeassistant.helpers.trigger import TriggerActionType, TriggerInfo from homeassistant.helpers.trigger import TriggerActionType, TriggerInfo
from homeassistant.helpers.typing import ConfigType from homeassistant.helpers.typing import ConfigType
@ -38,11 +38,11 @@ async def async_get_triggers(
hass: HomeAssistant, device_id: str hass: HomeAssistant, device_id: str
) -> list[dict[str, str]]: ) -> list[dict[str, str]]:
"""List device triggers for Device Tracker devices.""" """List device triggers for Device Tracker devices."""
registry = entity_registry.async_get(hass) registry = er.async_get(hass)
triggers = [] triggers = []
# Get all the integrations entities for this device # Get all the integrations entities for this device
for entry in entity_registry.async_entries_for_device(registry, device_id): for entry in er.async_entries_for_device(registry, device_id):
if entry.domain != DOMAIN: if entry.domain != DOMAIN:
continue continue

View file

@ -14,7 +14,11 @@ from homeassistant.const import (
STATE_ON, STATE_ON,
) )
from homeassistant.core import HomeAssistant, callback from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers import condition, config_validation as cv, entity_registry from homeassistant.helpers import (
condition,
config_validation as cv,
entity_registry as er,
)
from homeassistant.helpers.config_validation import DEVICE_CONDITION_BASE_SCHEMA from homeassistant.helpers.config_validation import DEVICE_CONDITION_BASE_SCHEMA
from homeassistant.helpers.typing import ConfigType, TemplateVarsType from homeassistant.helpers.typing import ConfigType, TemplateVarsType
@ -34,11 +38,11 @@ async def async_get_conditions(
hass: HomeAssistant, device_id: str hass: HomeAssistant, device_id: str
) -> list[dict[str, str]]: ) -> list[dict[str, str]]:
"""List device conditions for Fan devices.""" """List device conditions for Fan devices."""
registry = entity_registry.async_get(hass) registry = er.async_get(hass)
conditions = [] conditions = []
# Get all the integrations entities for this device # Get all the integrations entities for this device
for entry in entity_registry.async_entries_for_device(registry, device_id): for entry in er.async_entries_for_device(registry, device_id):
if entry.domain != DOMAIN: if entry.domain != DOMAIN:
continue continue

View file

@ -14,7 +14,7 @@ from homeassistant.const import (
) )
from homeassistant.core import Context, HomeAssistant from homeassistant.core import Context, HomeAssistant
from homeassistant.exceptions import HomeAssistantError from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers import entity_registry from homeassistant.helpers import entity_registry as er
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity import get_capability, get_supported_features from homeassistant.helpers.entity import get_capability, get_supported_features
from homeassistant.helpers.typing import ConfigType, TemplateVarsType from homeassistant.helpers.typing import ConfigType, TemplateVarsType
@ -48,11 +48,11 @@ async def async_get_actions(
hass: HomeAssistant, device_id: str hass: HomeAssistant, device_id: str
) -> list[dict[str, str]]: ) -> list[dict[str, str]]:
"""List device actions for Humidifier devices.""" """List device actions for Humidifier devices."""
registry = entity_registry.async_get(hass) registry = er.async_get(hass)
actions = await toggle_entity.async_get_actions(hass, device_id, DOMAIN) actions = await toggle_entity.async_get_actions(hass, device_id, DOMAIN)
# Get all the integrations entities for this device # Get all the integrations entities for this device
for entry in entity_registry.async_entries_for_device(registry, device_id): for entry in er.async_entries_for_device(registry, device_id):
if entry.domain != DOMAIN: if entry.domain != DOMAIN:
continue continue

View file

@ -15,7 +15,11 @@ from homeassistant.const import (
) )
from homeassistant.core import HomeAssistant, callback from homeassistant.core import HomeAssistant, callback
from homeassistant.exceptions import HomeAssistantError from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers import condition, config_validation as cv, entity_registry from homeassistant.helpers import (
condition,
config_validation as cv,
entity_registry as er,
)
from homeassistant.helpers.config_validation import DEVICE_CONDITION_BASE_SCHEMA from homeassistant.helpers.config_validation import DEVICE_CONDITION_BASE_SCHEMA
from homeassistant.helpers.entity import get_capability, get_supported_features from homeassistant.helpers.entity import get_capability, get_supported_features
from homeassistant.helpers.typing import ConfigType, TemplateVarsType from homeassistant.helpers.typing import ConfigType, TemplateVarsType
@ -41,11 +45,11 @@ async def async_get_conditions(
hass: HomeAssistant, device_id: str hass: HomeAssistant, device_id: str
) -> list[dict[str, str]]: ) -> list[dict[str, str]]:
"""List device conditions for Humidifier devices.""" """List device conditions for Humidifier devices."""
registry = entity_registry.async_get(hass) registry = er.async_get(hass)
conditions = await toggle_entity.async_get_conditions(hass, device_id, DOMAIN) conditions = await toggle_entity.async_get_conditions(hass, device_id, DOMAIN)
# Get all the integrations entities for this device # Get all the integrations entities for this device
for entry in entity_registry.async_entries_for_device(registry, device_id): for entry in er.async_entries_for_device(registry, device_id):
if entry.domain != DOMAIN: if entry.domain != DOMAIN:
continue continue

View file

@ -22,7 +22,7 @@ from homeassistant.const import (
PERCENTAGE, PERCENTAGE,
) )
from homeassistant.core import CALLBACK_TYPE, HomeAssistant from homeassistant.core import CALLBACK_TYPE, HomeAssistant
from homeassistant.helpers import config_validation as cv, entity_registry from homeassistant.helpers import config_validation as cv, entity_registry as er
from homeassistant.helpers.trigger import TriggerActionType, TriggerInfo from homeassistant.helpers.trigger import TriggerActionType, TriggerInfo
from homeassistant.helpers.typing import ConfigType from homeassistant.helpers.typing import ConfigType
@ -56,11 +56,11 @@ async def async_get_triggers(
hass: HomeAssistant, device_id: str hass: HomeAssistant, device_id: str
) -> list[dict[str, str]]: ) -> list[dict[str, str]]:
"""List device triggers for Humidifier devices.""" """List device triggers for Humidifier devices."""
registry = entity_registry.async_get(hass) registry = er.async_get(hass)
triggers = await toggle_entity.async_get_triggers(hass, device_id, DOMAIN) triggers = await toggle_entity.async_get_triggers(hass, device_id, DOMAIN)
# Get all the integrations entities for this device # Get all the integrations entities for this device
for entry in entity_registry.async_entries_for_device(registry, device_id): for entry in er.async_entries_for_device(registry, device_id):
if entry.domain != DOMAIN: if entry.domain != DOMAIN:
continue continue

View file

@ -14,7 +14,7 @@ from homeassistant.const import (
SERVICE_UNLOCK, SERVICE_UNLOCK,
) )
from homeassistant.core import Context, HomeAssistant from homeassistant.core import Context, HomeAssistant
from homeassistant.helpers import entity_registry from homeassistant.helpers import entity_registry as er
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity import get_supported_features from homeassistant.helpers.entity import get_supported_features
from homeassistant.helpers.typing import ConfigType, TemplateVarsType from homeassistant.helpers.typing import ConfigType, TemplateVarsType
@ -35,11 +35,11 @@ async def async_get_actions(
hass: HomeAssistant, device_id: str hass: HomeAssistant, device_id: str
) -> list[dict[str, str]]: ) -> list[dict[str, str]]:
"""List device actions for Lock devices.""" """List device actions for Lock devices."""
registry = entity_registry.async_get(hass) registry = er.async_get(hass)
actions = [] actions = []
# Get all the integrations entities for this device # Get all the integrations entities for this device
for entry in entity_registry.async_entries_for_device(registry, device_id): for entry in er.async_entries_for_device(registry, device_id):
if entry.domain != DOMAIN: if entry.domain != DOMAIN:
continue continue

View file

@ -17,7 +17,11 @@ from homeassistant.const import (
STATE_UNLOCKING, STATE_UNLOCKING,
) )
from homeassistant.core import HomeAssistant, callback from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers import condition, config_validation as cv, entity_registry from homeassistant.helpers import (
condition,
config_validation as cv,
entity_registry as er,
)
from homeassistant.helpers.config_validation import DEVICE_CONDITION_BASE_SCHEMA from homeassistant.helpers.config_validation import DEVICE_CONDITION_BASE_SCHEMA
from homeassistant.helpers.typing import ConfigType, TemplateVarsType from homeassistant.helpers.typing import ConfigType, TemplateVarsType
@ -45,11 +49,11 @@ async def async_get_conditions(
hass: HomeAssistant, device_id: str hass: HomeAssistant, device_id: str
) -> list[dict[str, str]]: ) -> list[dict[str, str]]:
"""List device conditions for Lock devices.""" """List device conditions for Lock devices."""
registry = entity_registry.async_get(hass) registry = er.async_get(hass)
conditions = [] conditions = []
# Get all the integrations entities for this device # Get all the integrations entities for this device
for entry in entity_registry.async_entries_for_device(registry, device_id): for entry in er.async_entries_for_device(registry, device_id):
if entry.domain != DOMAIN: if entry.domain != DOMAIN:
continue continue

View file

@ -19,7 +19,7 @@ from homeassistant.const import (
STATE_UNLOCKING, STATE_UNLOCKING,
) )
from homeassistant.core import CALLBACK_TYPE, HomeAssistant from homeassistant.core import CALLBACK_TYPE, HomeAssistant
from homeassistant.helpers import config_validation as cv, entity_registry from homeassistant.helpers import config_validation as cv, entity_registry as er
from homeassistant.helpers.trigger import TriggerActionType, TriggerInfo from homeassistant.helpers.trigger import TriggerActionType, TriggerInfo
from homeassistant.helpers.typing import ConfigType from homeassistant.helpers.typing import ConfigType
@ -40,11 +40,11 @@ async def async_get_triggers(
hass: HomeAssistant, device_id: str hass: HomeAssistant, device_id: str
) -> list[dict[str, str]]: ) -> list[dict[str, str]]:
"""List device triggers for Lock devices.""" """List device triggers for Lock devices."""
registry = entity_registry.async_get(hass) registry = er.async_get(hass)
triggers = [] triggers = []
# Get all the integrations entities for this device # Get all the integrations entities for this device
for entry in entity_registry.async_entries_for_device(registry, device_id): for entry in er.async_entries_for_device(registry, device_id):
if entry.domain != DOMAIN: if entry.domain != DOMAIN:
continue continue

View file

@ -18,7 +18,11 @@ from homeassistant.const import (
STATE_PLAYING, STATE_PLAYING,
) )
from homeassistant.core import HomeAssistant, callback from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers import condition, config_validation as cv, entity_registry from homeassistant.helpers import (
condition,
config_validation as cv,
entity_registry as er,
)
from homeassistant.helpers.config_validation import DEVICE_CONDITION_BASE_SCHEMA from homeassistant.helpers.config_validation import DEVICE_CONDITION_BASE_SCHEMA
from homeassistant.helpers.typing import ConfigType, TemplateVarsType from homeassistant.helpers.typing import ConfigType, TemplateVarsType
@ -45,11 +49,11 @@ async def async_get_conditions(
hass: HomeAssistant, device_id: str hass: HomeAssistant, device_id: str
) -> list[dict[str, str]]: ) -> list[dict[str, str]]:
"""List device conditions for Media player devices.""" """List device conditions for Media player devices."""
registry = entity_registry.async_get(hass) registry = er.async_get(hass)
conditions: list[dict[str, str]] = [] conditions: list[dict[str, str]] = []
# Get all the integrations entities for this device # Get all the integrations entities for this device
for entry in entity_registry.async_entries_for_device(registry, device_id): for entry in er.async_entries_for_device(registry, device_id):
if entry.domain != DOMAIN: if entry.domain != DOMAIN:
continue continue

View file

@ -23,7 +23,7 @@ from homeassistant.const import (
STATE_PLAYING, STATE_PLAYING,
) )
from homeassistant.core import CALLBACK_TYPE, HomeAssistant from homeassistant.core import CALLBACK_TYPE, HomeAssistant
from homeassistant.helpers import config_validation as cv, entity_registry from homeassistant.helpers import config_validation as cv, entity_registry as er
from homeassistant.helpers.trigger import TriggerActionType, TriggerInfo from homeassistant.helpers.trigger import TriggerActionType, TriggerInfo
from homeassistant.helpers.typing import ConfigType from homeassistant.helpers.typing import ConfigType
@ -52,11 +52,11 @@ async def async_get_triggers(
hass: HomeAssistant, device_id: str hass: HomeAssistant, device_id: str
) -> list[dict[str, str]]: ) -> list[dict[str, str]]:
"""List device triggers for Media player entities.""" """List device triggers for Media player entities."""
registry = entity_registry.async_get(hass) registry = er.async_get(hass)
triggers = await entity.async_get_triggers(hass, device_id, DOMAIN) triggers = await entity.async_get_triggers(hass, device_id, DOMAIN)
# Get all the integration entities for this device # Get all the integration entities for this device
for entry in entity_registry.async_entries_for_device(registry, device_id): for entry in er.async_entries_for_device(registry, device_id):
if entry.domain != DOMAIN: if entry.domain != DOMAIN:
continue continue

View file

@ -11,7 +11,7 @@ from homeassistant.const import (
CONF_TYPE, CONF_TYPE,
) )
from homeassistant.core import Context, HomeAssistant from homeassistant.core import Context, HomeAssistant
from homeassistant.helpers import entity_registry from homeassistant.helpers import entity_registry as er
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.typing import ConfigType, TemplateVarsType from homeassistant.helpers.typing import ConfigType, TemplateVarsType
@ -32,11 +32,11 @@ async def async_get_actions(
hass: HomeAssistant, device_id: str hass: HomeAssistant, device_id: str
) -> list[dict[str, str]]: ) -> list[dict[str, str]]:
"""List device actions for Number.""" """List device actions for Number."""
registry = entity_registry.async_get(hass) registry = er.async_get(hass)
actions: list[dict[str, str]] = [] actions: list[dict[str, str]] = []
# Get all the integrations entities for this device # Get all the integrations entities for this device
for entry in entity_registry.async_entries_for_device(registry, device_id): for entry in er.async_entries_for_device(registry, device_id):
if entry.domain != DOMAIN: if entry.domain != DOMAIN:
continue continue

View file

@ -42,7 +42,7 @@ from homeassistant.core import (
from homeassistant.helpers import ( from homeassistant.helpers import (
collection, collection,
config_validation as cv, config_validation as cv,
entity_registry, entity_registry as er,
service, service,
) )
from homeassistant.helpers.entity_component import EntityComponent from homeassistant.helpers.entity_component import EntityComponent
@ -226,7 +226,7 @@ class PersonStorageCollection(collection.StorageCollection):
"""Load the Storage collection.""" """Load the Storage collection."""
await super().async_load() await super().async_load()
self.hass.bus.async_listen( self.hass.bus.async_listen(
entity_registry.EVENT_ENTITY_REGISTRY_UPDATED, self._entity_registry_updated er.EVENT_ENTITY_REGISTRY_UPDATED, self._entity_registry_updated
) )
async def _entity_registry_updated(self, event) -> None: async def _entity_registry_updated(self, event) -> None:

View file

@ -29,7 +29,7 @@ import voluptuous as vol
from homeassistant.const import ATTR_UNIT_OF_MEASUREMENT from homeassistant.const import ATTR_UNIT_OF_MEASUREMENT
from homeassistant.core import Event, HomeAssistant, callback, valid_entity_id from homeassistant.core import Event, HomeAssistant, callback, valid_entity_id
from homeassistant.exceptions import HomeAssistantError from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers import entity_registry from homeassistant.helpers import entity_registry as er
from homeassistant.helpers.json import JSONEncoder from homeassistant.helpers.json import JSONEncoder
from homeassistant.helpers.start import async_at_start from homeassistant.helpers.start import async_at_start
from homeassistant.helpers.storage import STORAGE_DIR from homeassistant.helpers.storage import STORAGE_DIR
@ -338,7 +338,7 @@ def async_setup(hass: HomeAssistant) -> None:
def setup_entity_registry_event_handler(hass: HomeAssistant) -> None: def setup_entity_registry_event_handler(hass: HomeAssistant) -> None:
"""Subscribe to event registry events.""" """Subscribe to event registry events."""
hass.bus.async_listen( hass.bus.async_listen(
entity_registry.EVENT_ENTITY_REGISTRY_UPDATED, er.EVENT_ENTITY_REGISTRY_UPDATED,
_async_entity_id_changed, _async_entity_id_changed,
event_filter=entity_registry_changed_filter, event_filter=entity_registry_changed_filter,
) )

View file

@ -10,7 +10,7 @@ import voluptuous as vol
from homeassistant.components import automation, group, person, script, websocket_api from homeassistant.components import automation, group, person, script, websocket_api
from homeassistant.components.homeassistant import scene from homeassistant.components.homeassistant import scene
from homeassistant.core import HomeAssistant, callback, split_entity_id from homeassistant.core import HomeAssistant, callback, split_entity_id
from homeassistant.helpers import device_registry, entity_registry from homeassistant.helpers import device_registry as dr, entity_registry as er
from homeassistant.helpers.entity import entity_sources as get_entity_sources from homeassistant.helpers.entity import entity_sources as get_entity_sources
from homeassistant.helpers.typing import ConfigType from homeassistant.helpers.typing import ConfigType
@ -53,8 +53,8 @@ def websocket_search_related(
"""Handle search.""" """Handle search."""
searcher = Searcher( searcher = Searcher(
hass, hass,
device_registry.async_get(hass), dr.async_get(hass),
entity_registry.async_get(hass), er.async_get(hass),
get_entity_sources(hass), get_entity_sources(hass),
) )
connection.send_result( connection.send_result(
@ -86,8 +86,8 @@ class Searcher:
def __init__( def __init__(
self, self,
hass: HomeAssistant, hass: HomeAssistant,
device_reg: device_registry.DeviceRegistry, device_reg: dr.DeviceRegistry,
entity_reg: entity_registry.EntityRegistry, entity_reg: er.EntityRegistry,
entity_sources: dict[str, dict[str, str]], entity_sources: dict[str, dict[str, str]],
) -> None: ) -> None:
"""Search results.""" """Search results."""
@ -141,12 +141,10 @@ class Searcher:
@callback @callback
def _resolve_area(self, area_id) -> None: def _resolve_area(self, area_id) -> None:
"""Resolve an area.""" """Resolve an area."""
for device in device_registry.async_entries_for_area(self._device_reg, area_id): for device in dr.async_entries_for_area(self._device_reg, area_id):
self._add_or_resolve("device", device.id) self._add_or_resolve("device", device.id)
for entity_entry in entity_registry.async_entries_for_area( for entity_entry in er.async_entries_for_area(self._entity_reg, area_id):
self._entity_reg, area_id
):
self._add_or_resolve("entity", entity_entry.entity_id) self._add_or_resolve("entity", entity_entry.entity_id)
for entity_id in script.scripts_with_area(self.hass, area_id): for entity_id in script.scripts_with_area(self.hass, area_id):
@ -178,12 +176,12 @@ class Searcher:
Will only be called if config entry is an entry point. Will only be called if config entry is an entry point.
""" """
for device_entry in device_registry.async_entries_for_config_entry( for device_entry in dr.async_entries_for_config_entry(
self._device_reg, config_entry_id self._device_reg, config_entry_id
): ):
self._add_or_resolve("device", device_entry.id) self._add_or_resolve("device", device_entry.id)
for entity_entry in entity_registry.async_entries_for_config_entry( for entity_entry in er.async_entries_for_config_entry(
self._entity_reg, config_entry_id self._entity_reg, config_entry_id
): ):
self._add_or_resolve("entity", entity_entry.entity_id) self._add_or_resolve("entity", entity_entry.entity_id)
@ -203,9 +201,7 @@ class Searcher:
# We do not resolve device_entry.via_device_id because that # We do not resolve device_entry.via_device_id because that
# device is not related data-wise inside HA. # device is not related data-wise inside HA.
for entity_entry in entity_registry.async_entries_for_device( for entity_entry in er.async_entries_for_device(self._entity_reg, device_id):
self._entity_reg, device_id
):
self._add_or_resolve("entity", entity_entry.entity_id) self._add_or_resolve("entity", entity_entry.entity_id)
for entity_id in script.scripts_with_device(self.hass, device_id): for entity_id in script.scripts_with_device(self.hass, device_id):

View file

@ -14,7 +14,7 @@ from homeassistant.const import (
) )
from homeassistant.core import Context, HomeAssistant from homeassistant.core import Context, HomeAssistant
from homeassistant.exceptions import HomeAssistantError from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers import entity_registry from homeassistant.helpers import entity_registry as er
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity import get_capability from homeassistant.helpers.entity import get_capability
from homeassistant.helpers.typing import ConfigType, TemplateVarsType from homeassistant.helpers.typing import ConfigType, TemplateVarsType
@ -74,7 +74,7 @@ async def async_get_actions(
hass: HomeAssistant, device_id: str hass: HomeAssistant, device_id: str
) -> list[dict[str, str]]: ) -> list[dict[str, str]]:
"""List device actions for Select devices.""" """List device actions for Select devices."""
registry = entity_registry.async_get(hass) registry = er.async_get(hass)
return [ return [
{ {
CONF_DEVICE_ID: device_id, CONF_DEVICE_ID: device_id,
@ -89,7 +89,7 @@ async def async_get_actions(
SERVICE_SELECT_OPTION, SERVICE_SELECT_OPTION,
SERVICE_SELECT_PREVIOUS, SERVICE_SELECT_PREVIOUS,
) )
for entry in entity_registry.async_entries_for_device(registry, device_id) for entry in er.async_entries_for_device(registry, device_id)
if entry.domain == DOMAIN if entry.domain == DOMAIN
] ]

View file

@ -13,7 +13,11 @@ from homeassistant.const import (
) )
from homeassistant.core import HomeAssistant, callback from homeassistant.core import HomeAssistant, callback
from homeassistant.exceptions import HomeAssistantError from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers import condition, config_validation as cv, entity_registry from homeassistant.helpers import (
condition,
config_validation as cv,
entity_registry as er,
)
from homeassistant.helpers.config_validation import DEVICE_CONDITION_BASE_SCHEMA from homeassistant.helpers.config_validation import DEVICE_CONDITION_BASE_SCHEMA
from homeassistant.helpers.entity import get_capability from homeassistant.helpers.entity import get_capability
from homeassistant.helpers.typing import ConfigType, TemplateVarsType from homeassistant.helpers.typing import ConfigType, TemplateVarsType
@ -38,7 +42,7 @@ async def async_get_conditions(
hass: HomeAssistant, device_id: str hass: HomeAssistant, device_id: str
) -> list[dict[str, str]]: ) -> list[dict[str, str]]:
"""List device conditions for Select devices.""" """List device conditions for Select devices."""
registry = entity_registry.async_get(hass) registry = er.async_get(hass)
return [ return [
{ {
CONF_CONDITION: "device", CONF_CONDITION: "device",
@ -47,7 +51,7 @@ async def async_get_conditions(
CONF_ENTITY_ID: entry.entity_id, CONF_ENTITY_ID: entry.entity_id,
CONF_TYPE: "selected_option", CONF_TYPE: "selected_option",
} }
for entry in entity_registry.async_entries_for_device(registry, device_id) for entry in er.async_entries_for_device(registry, device_id)
if entry.domain == DOMAIN if entry.domain == DOMAIN
] ]

View file

@ -20,7 +20,7 @@ from homeassistant.const import (
) )
from homeassistant.core import CALLBACK_TYPE, HomeAssistant from homeassistant.core import CALLBACK_TYPE, HomeAssistant
from homeassistant.exceptions import HomeAssistantError from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers import config_validation as cv, entity_registry from homeassistant.helpers import config_validation as cv, entity_registry as er
from homeassistant.helpers.entity import get_capability from homeassistant.helpers.entity import get_capability
from homeassistant.helpers.trigger import TriggerActionType, TriggerInfo from homeassistant.helpers.trigger import TriggerActionType, TriggerInfo
from homeassistant.helpers.typing import ConfigType from homeassistant.helpers.typing import ConfigType
@ -44,7 +44,7 @@ async def async_get_triggers(
hass: HomeAssistant, device_id: str hass: HomeAssistant, device_id: str
) -> list[dict[str, str]]: ) -> list[dict[str, str]]:
"""List device triggers for Select devices.""" """List device triggers for Select devices."""
registry = entity_registry.async_get(hass) registry = er.async_get(hass)
return [ return [
{ {
CONF_PLATFORM: "device", CONF_PLATFORM: "device",
@ -53,7 +53,7 @@ async def async_get_triggers(
CONF_ENTITY_ID: entry.entity_id, CONF_ENTITY_ID: entry.entity_id,
CONF_TYPE: "current_option_changed", CONF_TYPE: "current_option_changed",
} }
for entry in entity_registry.async_entries_for_device(registry, device_id) for entry in er.async_entries_for_device(registry, device_id)
if entry.domain == DOMAIN if entry.domain == DOMAIN
] ]

View file

@ -11,7 +11,7 @@ from homeassistant.const import (
CONF_TYPE, CONF_TYPE,
) )
from homeassistant.core import Context, HomeAssistant from homeassistant.core import Context, HomeAssistant
from homeassistant.helpers import entity_registry from homeassistant.helpers import entity_registry as er
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.typing import ConfigType, TemplateVarsType from homeassistant.helpers.typing import ConfigType, TemplateVarsType
@ -32,11 +32,11 @@ async def async_get_actions(
hass: HomeAssistant, device_id: str hass: HomeAssistant, device_id: str
) -> list[dict[str, str]]: ) -> list[dict[str, str]]:
"""List device actions for Text.""" """List device actions for Text."""
registry = entity_registry.async_get(hass) registry = er.async_get(hass)
actions: list[dict[str, str]] = [] actions: list[dict[str, str]] = []
# Get all the integrations entities for this device # Get all the integrations entities for this device
for entry in entity_registry.async_entries_for_device(registry, device_id): for entry in er.async_entries_for_device(registry, device_id):
if entry.domain != DOMAIN: if entry.domain != DOMAIN:
continue continue

View file

@ -11,7 +11,7 @@ from homeassistant.const import (
CONF_TYPE, CONF_TYPE,
) )
from homeassistant.core import Context, HomeAssistant from homeassistant.core import Context, HomeAssistant
from homeassistant.helpers import entity_registry from homeassistant.helpers import entity_registry as er
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.typing import ConfigType, TemplateVarsType from homeassistant.helpers.typing import ConfigType, TemplateVarsType
@ -31,11 +31,11 @@ async def async_get_actions(
hass: HomeAssistant, device_id: str hass: HomeAssistant, device_id: str
) -> list[dict[str, str]]: ) -> list[dict[str, str]]:
"""List device actions for Vacuum devices.""" """List device actions for Vacuum devices."""
registry = entity_registry.async_get(hass) registry = er.async_get(hass)
actions = [] actions = []
# Get all the integrations entities for this device # Get all the integrations entities for this device
for entry in entity_registry.async_entries_for_device(registry, device_id): for entry in er.async_entries_for_device(registry, device_id):
if entry.domain != DOMAIN: if entry.domain != DOMAIN:
continue continue

View file

@ -12,7 +12,11 @@ from homeassistant.const import (
CONF_TYPE, CONF_TYPE,
) )
from homeassistant.core import HomeAssistant, callback from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers import condition, config_validation as cv, entity_registry from homeassistant.helpers import (
condition,
config_validation as cv,
entity_registry as er,
)
from homeassistant.helpers.config_validation import DEVICE_CONDITION_BASE_SCHEMA from homeassistant.helpers.config_validation import DEVICE_CONDITION_BASE_SCHEMA
from homeassistant.helpers.typing import ConfigType, TemplateVarsType from homeassistant.helpers.typing import ConfigType, TemplateVarsType
@ -32,11 +36,11 @@ async def async_get_conditions(
hass: HomeAssistant, device_id: str hass: HomeAssistant, device_id: str
) -> list[dict[str, str]]: ) -> list[dict[str, str]]:
"""List device conditions for Vacuum devices.""" """List device conditions for Vacuum devices."""
registry = entity_registry.async_get(hass) registry = er.async_get(hass)
conditions = [] conditions = []
# Get all the integrations entities for this device # Get all the integrations entities for this device
for entry in entity_registry.async_entries_for_device(registry, device_id): for entry in er.async_entries_for_device(registry, device_id):
if entry.domain != DOMAIN: if entry.domain != DOMAIN:
continue continue

View file

@ -14,7 +14,7 @@ from homeassistant.const import (
CONF_TYPE, CONF_TYPE,
) )
from homeassistant.core import CALLBACK_TYPE, HomeAssistant from homeassistant.core import CALLBACK_TYPE, HomeAssistant
from homeassistant.helpers import config_validation as cv, entity_registry from homeassistant.helpers import config_validation as cv, entity_registry as er
from homeassistant.helpers.trigger import TriggerActionType, TriggerInfo from homeassistant.helpers.trigger import TriggerActionType, TriggerInfo
from homeassistant.helpers.typing import ConfigType from homeassistant.helpers.typing import ConfigType
@ -35,11 +35,11 @@ async def async_get_triggers(
hass: HomeAssistant, device_id: str hass: HomeAssistant, device_id: str
) -> list[dict[str, str]]: ) -> list[dict[str, str]]:
"""List device triggers for Vacuum devices.""" """List device triggers for Vacuum devices."""
registry = entity_registry.async_get(hass) registry = er.async_get(hass)
triggers = [] triggers = []
# Get all the integrations entities for this device # Get all the integrations entities for this device
for entry in entity_registry.async_entries_for_device(registry, device_id): for entry in er.async_entries_for_device(registry, device_id):
if entry.domain != DOMAIN: if entry.domain != DOMAIN:
continue continue

View file

@ -13,7 +13,7 @@ from homeassistant.const import (
SERVICE_TURN_ON, SERVICE_TURN_ON,
) )
from homeassistant.core import Context, HomeAssistant from homeassistant.core import Context, HomeAssistant
from homeassistant.helpers import entity_registry from homeassistant.helpers import entity_registry as er
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.typing import ConfigType, TemplateVarsType from homeassistant.helpers.typing import ConfigType, TemplateVarsType
@ -33,10 +33,10 @@ async def async_get_actions(
hass: HomeAssistant, device_id: str hass: HomeAssistant, device_id: str
) -> list[dict[str, str]]: ) -> list[dict[str, str]]:
"""List device actions for Water Heater devices.""" """List device actions for Water Heater devices."""
registry = entity_registry.async_get(hass) registry = er.async_get(hass)
actions = [] actions = []
for entry in entity_registry.async_entries_for_device(registry, device_id): for entry in er.async_entries_for_device(registry, device_id):
if entry.domain != DOMAIN: if entry.domain != DOMAIN:
continue continue