mirror of
https://github.com/basnijholt/adaptive-lighting.git
synced 2026-09-12 06:44:04 +02:00
Fix HA 2025.12 breaking (#1291)
This commit is contained in:
parent
0a2d2e9fb5
commit
af5a7151aa
2 changed files with 21 additions and 2 deletions
|
|
@ -4,6 +4,7 @@ import logging
|
|||
from collections.abc import Awaitable, Callable
|
||||
|
||||
from homeassistant.core import HomeAssistant, ServiceCall
|
||||
from homeassistant.helpers import device_registry, entity_registry
|
||||
from homeassistant.util.read_only_dict import ReadOnlyDict
|
||||
|
||||
from .adaptation_utils import ServiceData
|
||||
|
|
@ -11,6 +12,25 @@ from .adaptation_utils import ServiceData
|
|||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def area_entities(hass: HomeAssistant, area_id: str):
|
||||
"""Get all entities linked to an area."""
|
||||
ent_reg = entity_registry.async_get(hass)
|
||||
entity_ids = [
|
||||
entry.entity_id
|
||||
for entry in entity_registry.async_entries_for_area(ent_reg, area_id)
|
||||
]
|
||||
dev_reg = device_registry.async_get(hass)
|
||||
entity_ids.extend(
|
||||
[
|
||||
entity.entity_id
|
||||
for device in device_registry.async_entries_for_area(dev_reg, area_id)
|
||||
for entity in entity_registry.async_entries_for_device(ent_reg, device.id)
|
||||
if entity.area_id is None
|
||||
],
|
||||
)
|
||||
return entity_ids
|
||||
|
||||
|
||||
def setup_service_call_interceptor(
|
||||
hass: HomeAssistant,
|
||||
domain: str,
|
||||
|
|
|
|||
|
|
@ -75,7 +75,6 @@ from homeassistant.helpers.event import (
|
|||
)
|
||||
from homeassistant.helpers.restore_state import RestoreEntity
|
||||
from homeassistant.helpers.sun import get_astral_location
|
||||
from homeassistant.helpers.template import area_entities
|
||||
from homeassistant.util import slugify
|
||||
from homeassistant.util.color import (
|
||||
color_temperature_to_rgb,
|
||||
|
|
@ -153,7 +152,7 @@ from .const import (
|
|||
apply_service_schema,
|
||||
replace_none_str,
|
||||
)
|
||||
from .hass_utils import setup_service_call_interceptor
|
||||
from .hass_utils import area_entities, setup_service_call_interceptor
|
||||
from .helpers import (
|
||||
clamp,
|
||||
color_difference_redmean,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue