7676from homeassistant .helpers .restore_state import RestoreEntity
7777from homeassistant .helpers .sun import get_astral_location
7878from homeassistant .helpers .template import area_entities
79- from homeassistant .loader import bind_hass
8079from homeassistant .util import slugify
8180from homeassistant .util .color import (
8281 color_temperature_to_rgb ,
@@ -226,7 +225,6 @@ def is_our_context(context: Context | None, which: str | None = None) -> bool:
226225 return is_our_context_id (context .id , which )
227226
228227
229- @bind_hass
230228def _switches_with_lights (
231229 hass : HomeAssistant ,
232230 lights : list [str ],
@@ -244,7 +242,7 @@ def _switches_with_lights(
244242 if entry is None : # entry might be disabled and therefore missing
245243 continue
246244 switch = data [config .entry_id ][SWITCH_DOMAIN ]
247- switch ._expand_light_groups ()
245+ switch ._expand_light_groups (hass = hass )
248246 # Check if any of the lights are in the switch's lights
249247 if set (switch .lights ) & set (all_check_lights ):
250248 switches .append (switch )
@@ -255,7 +253,6 @@ class NoSwitchFoundError(ValueError):
255253 """No switches found for lights."""
256254
257255
258- @bind_hass
259256def _switch_with_lights (
260257 hass : HomeAssistant ,
261258 lights : list [str ],
@@ -286,7 +283,6 @@ def _switch_with_lights(
286283
287284# For documentation on this function, see integration_entities() from HomeAssistant Core:
288285# https://github.com/home-assistant/core/blob/dev/homeassistant/helpers/template.py#L1109
289- @bind_hass
290286def _switches_from_service_call (
291287 hass : HomeAssistant ,
292288 service_call : ServiceCall ,
@@ -599,7 +595,6 @@ def _is_state_event(event: Event, from_or_to_state: Iterable[str]):
599595 )
600596
601597
602- @bind_hass
603598def _expand_light_groups (
604599 hass : HomeAssistant ,
605600 lights : list [str ],
@@ -628,7 +623,6 @@ def _is_light_group(state: State) -> bool:
628623 )
629624
630625
631- @bind_hass
632626def _supported_features (hass : HomeAssistant , light : str ) -> set [str ]:
633627 state = hass .states .get (light )
634628 assert state is not None
@@ -973,8 +967,9 @@ async def async_will_remove_from_hass(self):
973967 """Remove the listeners upon removing the component."""
974968 self ._remove_listeners ()
975969
976- def _expand_light_groups (self ) -> None :
977- all_lights = _expand_light_groups (self .hass , self .lights )
970+ def _expand_light_groups (self , hass = None ) -> None :
971+ hass = hass or self .hass
972+ all_lights = _expand_light_groups (hass , self .lights )
978973 self .manager .lights .update (all_lights )
979974 self .manager .set_auto_reset_manual_control_times (
980975 all_lights ,
0 commit comments