mirror of
https://github.com/basnijholt/adaptive-lighting.git
synced 2026-09-12 06:44:04 +02:00
Fix default lights for adaptive_lighting.apply service
This commit is contained in:
parent
65fad19453
commit
cc90c51255
1 changed files with 9 additions and 3 deletions
|
|
@ -222,9 +222,15 @@ async def handle_apply(switch: AdaptiveSwitch, service_call: ServiceCall):
|
|||
"""Handle the entity service apply."""
|
||||
hass = switch.hass
|
||||
data = service_call.data
|
||||
all_lights = _expand_light_groups(hass, data[CONF_LIGHTS])
|
||||
all_lights = data[CONF_LIGHTS]
|
||||
if not all_lights:
|
||||
all_lights = switch._lights
|
||||
all_lights = _expand_light_groups(hass, all_lights)
|
||||
switch.turn_on_off_listener.lights.update(all_lights)
|
||||
|
||||
_LOGGER.debug(
|
||||
"Called 'adaptive_lighting.apply' service with '%s'",
|
||||
data,
|
||||
)
|
||||
for light in all_lights:
|
||||
if data[CONF_TURN_ON_LIGHTS] or is_on(hass, light):
|
||||
await switch._adapt_light( # pylint: disable=protected-access
|
||||
|
|
@ -322,7 +328,7 @@ async def async_setup_entry(
|
|||
platform.async_register_entity_service(
|
||||
SERVICE_APPLY,
|
||||
{
|
||||
vol.Optional(CONF_LIGHTS, default=switch._lights): cv.entity_ids, # pylint: disable=protected-access
|
||||
vol.Optional(CONF_LIGHTS, default=[]): cv.entity_ids, # pylint: disable=protected-access
|
||||
vol.Optional(
|
||||
CONF_TRANSITION,
|
||||
default=switch._initial_transition, # pylint: disable=protected-access
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue