diff --git a/custom_components/adaptive_lighting/const.py b/custom_components/adaptive_lighting/const.py index e8494fe6..a963efae 100644 --- a/custom_components/adaptive_lighting/const.py +++ b/custom_components/adaptive_lighting/const.py @@ -90,7 +90,7 @@ EXTRA_VALIDATION = { } -def maybe_coerse(key, validation): +def maybe_coerce(key, validation): validation, coerce = EXTRA_VALIDATION.get(key, (validation, None)) if coerce is not None: return vol.All(validation, vol.Coerce(coerce)) @@ -102,7 +102,7 @@ def replace_none(x): validation_tuples = [ - (key, default, maybe_coerse(key, validation)) + (key, default, maybe_coerce(key, validation)) for key, default, validation in VALIDATION_TUPLES ] + [(CONF_NAME, DEFAULT_NAME, cv.string)] diff --git a/custom_components/adaptive_lighting/switch.py b/custom_components/adaptive_lighting/switch.py index b7b8dd4e..c47d6fb8 100755 --- a/custom_components/adaptive_lighting/switch.py +++ b/custom_components/adaptive_lighting/switch.py @@ -105,12 +105,11 @@ async def handle_apply(entity, service_call): """Handle the entity service apply.""" if not isinstance(entity, AdaptiveSwitch): raise ValueError("Apply can only be called for a AdaptiveSwitch.") - _LOGGER.error(str(entity) + str(service_call)) - await entity._adjust_lights( - service_call.data[CONF_LIGHTS], - service_call.data.get(CONF_TRANSITION), - force=True, - ) + lights = service_call.data[CONF_LIGHTS] + transition = service_call.data.get(CONF_TRANSITION, entity._initial_transition) + tasks = [await entity._adjust_light(light, transition) for light in lights] + if tasks: + await asyncio.wait(tasks) async def async_setup_entry(hass, config_entry, async_add_entities):