call even if off

This commit is contained in:
Bas Nijholt 2020-09-25 10:33:49 +02:00
commit 21cc22d42c
2 changed files with 7 additions and 8 deletions

View file

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

View file

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