mirror of
https://github.com/basnijholt/adaptive-lighting.git
synced 2026-09-11 14:24:03 +02:00
Add @bind_hass to functions (#667)
This commit is contained in:
parent
e9297d562f
commit
1cda675bbe
1 changed files with 6 additions and 0 deletions
|
|
@ -78,6 +78,7 @@ 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.loader import bind_hass
|
||||
from homeassistant.util import slugify
|
||||
from homeassistant.util.color import (
|
||||
color_RGB_to_xy,
|
||||
|
|
@ -274,6 +275,7 @@ def is_our_context(context: Context | None) -> bool:
|
|||
return is_our_context_id(context.id)
|
||||
|
||||
|
||||
@bind_hass
|
||||
def _switches_with_lights(
|
||||
hass: HomeAssistant,
|
||||
lights: list[str],
|
||||
|
|
@ -299,6 +301,7 @@ class NoSwitchFoundError(ValueError):
|
|||
"""No switches found for lights."""
|
||||
|
||||
|
||||
@bind_hass
|
||||
def _switch_with_lights(
|
||||
hass: HomeAssistant,
|
||||
lights: list[str],
|
||||
|
|
@ -328,6 +331,7 @@ def _switch_with_lights(
|
|||
|
||||
# For documentation on this function, see integration_entities() from HomeAssistant Core:
|
||||
# https://github.com/home-assistant/core/blob/dev/homeassistant/helpers/template.py#L1109
|
||||
@bind_hass
|
||||
def _switches_from_service_call(
|
||||
hass: HomeAssistant,
|
||||
service_call: ServiceCall,
|
||||
|
|
@ -617,6 +621,7 @@ def _is_state_event(event: Event, from_or_to_state: Iterable[str]):
|
|||
)
|
||||
|
||||
|
||||
@bind_hass
|
||||
def _expand_light_groups(hass: HomeAssistant, lights: list[str]) -> list[str]:
|
||||
all_lights = set()
|
||||
manager = hass.data[DOMAIN][ATTR_ADAPTIVE_LIGHTING_MANAGER]
|
||||
|
|
@ -635,6 +640,7 @@ def _expand_light_groups(hass: HomeAssistant, lights: list[str]) -> list[str]:
|
|||
return list(all_lights)
|
||||
|
||||
|
||||
@bind_hass
|
||||
def _supported_features(hass: HomeAssistant, light: str) -> set[str]:
|
||||
state = hass.states.get(light)
|
||||
supported_features = state.attributes.get(ATTR_SUPPORTED_FEATURES, 0)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue