mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Minor helpers cleanup (#34786)
This commit is contained in:
parent
28f6e79385
commit
87801d8aca
@ -270,9 +270,15 @@ class EntityComponent:
|
|||||||
|
|
||||||
async def async_remove_entity(self, entity_id: str) -> None:
|
async def async_remove_entity(self, entity_id: str) -> None:
|
||||||
"""Remove an entity managed by one of the platforms."""
|
"""Remove an entity managed by one of the platforms."""
|
||||||
|
found = None
|
||||||
|
|
||||||
for platform in self._platforms.values():
|
for platform in self._platforms.values():
|
||||||
if entity_id in platform.entities:
|
if entity_id in platform.entities:
|
||||||
await platform.async_remove_entity(entity_id)
|
found = platform
|
||||||
|
break
|
||||||
|
|
||||||
|
if found:
|
||||||
|
await found.async_remove_entity(entity_id)
|
||||||
|
|
||||||
async def async_prepare_reload(self, *, skip_reset: bool = False) -> Optional[dict]:
|
async def async_prepare_reload(self, *, skip_reset: bool = False) -> Optional[dict]:
|
||||||
"""Prepare reloading this entity component.
|
"""Prepare reloading this entity component.
|
||||||
|
@ -545,13 +545,17 @@ def verify_domain_control(hass: HomeAssistantType, domain: str) -> Callable:
|
|||||||
|
|
||||||
reg = await hass.helpers.entity_registry.async_get_registry()
|
reg = await hass.helpers.entity_registry.async_get_registry()
|
||||||
|
|
||||||
|
authorized = False
|
||||||
|
|
||||||
for entity in reg.entities.values():
|
for entity in reg.entities.values():
|
||||||
if entity.platform != domain:
|
if entity.platform != domain:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if user.permissions.check_entity(entity.entity_id, POLICY_CONTROL):
|
if user.permissions.check_entity(entity.entity_id, POLICY_CONTROL):
|
||||||
return await service_handler(call)
|
authorized = True
|
||||||
|
break
|
||||||
|
|
||||||
|
if not authorized:
|
||||||
raise Unauthorized(
|
raise Unauthorized(
|
||||||
context=call.context,
|
context=call.context,
|
||||||
permission=POLICY_CONTROL,
|
permission=POLICY_CONTROL,
|
||||||
@ -559,6 +563,8 @@ def verify_domain_control(hass: HomeAssistantType, domain: str) -> Callable:
|
|||||||
perm_category=CAT_ENTITIES,
|
perm_category=CAT_ENTITIES,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
return await service_handler(call)
|
||||||
|
|
||||||
return check_permissions
|
return check_permissions
|
||||||
|
|
||||||
return decorator
|
return decorator
|
||||||
|
Loading…
x
Reference in New Issue
Block a user