Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion homeassistant/helpers/entity_component.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,9 +270,15 @@ async def _async_reset(self) -> None:

async def async_remove_entity(self, entity_id: str) -> None:
"""Remove an entity managed by one of the platforms."""
found = None

for platform in self._platforms.values():
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)
Comment thread
Danielhiversen marked this conversation as resolved.

async def async_prepare_reload(self, *, skip_reset: bool = False) -> Optional[dict]:
"""Prepare reloading this entity component.
Expand Down
20 changes: 13 additions & 7 deletions homeassistant/helpers/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -545,19 +545,25 @@ async def check_permissions(call):

reg = await hass.helpers.entity_registry.async_get_registry()

authorized = False

for entity in reg.entities.values():
if entity.platform != domain:
continue

if user.permissions.check_entity(entity.entity_id, POLICY_CONTROL):
return await service_handler(call)
authorized = True
break

raise Unauthorized(
context=call.context,
permission=POLICY_CONTROL,
user_id=call.context.user_id,
perm_category=CAT_ENTITIES,
)
if not authorized:
raise Unauthorized(
context=call.context,
permission=POLICY_CONTROL,
user_id=call.context.user_id,
perm_category=CAT_ENTITIES,
)

return await service_handler(call)

return check_permissions

Expand Down