Add @bind_hass to functions (#667)

This commit is contained in:
Bas Nijholt 2023-07-26 15:01:29 -07:00 committed by GitHub
commit 1cda675bbe
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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)