Happy Saturday everyone! I’m trying to work around a problem that I encountered after updating to the latest HA (was several back). Anyways, the light fader scripts started having nonzero division errors. So, I’m trying to figure out how to have an automation that, in parallel, controls multiple lights but has a delay a bit longer than the transition time to turn off the light instead of setting it at 0 (which used to work).
I have two scenarios - one light needing to be turned off after transition or multiple lights turned off and others left dimmed.
Here’s an example where I tried to think it through and my newb mind didn’t get there. Parallel means that all this runs at the same time so the delay and light.turn_off won’t work correctly for the preceding light dimming instance. Just can’t think of how to get around it. Not sure if an automation can have multiple action entries or something. My Googling is weak on this issue I suppose.
Aha that makes sense. So I figure this can be a simple script and keep the other tasks in parallel on the action based on what you provided. I skipped creating a script_2 in the example tutorial.
How far off is my first attempt at making the script?
Actually, if it’s sequential then I guess the delay isn’t needed if it waits for fader to complete and then turns off the light? Not sure how that would work - script in a script.
Well dang, I added it to scripts.yml to see what would happen and system’s log has an error:
Script with object id ‘kitchen_main_to_zero’ could not be validated and has been disabled: extra keys not allowed @ data[‘script_1’]. Got {‘sequence’: [{‘service’: ‘script.fade_light_v3’, ‘data’: {‘light’: ‘light.kitchen_main_lights’, ‘end_pct’: 5, ‘transition’: 200}}, {‘delay’: {‘seconds’: 300}}, {‘service’: ‘light.turn_off’, ‘target’: {‘entity_id’: ‘light.kitchen_main_lights’}}]} required key not provided @ data[‘sequence’]. Got None
Okay, error is gone now in the log by deleting script_1 stuff.
kitchen_main_to_zero:
description: Fades kitchen lights and then turns off
sequence:
- service: script.fade_light_v3
data:
light: light.kitchen_main_lights
end_pct: 5
transition: 200
- delay:
seconds: 300
- service: light.turn_off
target:
entity_id: light.kitchen_main_lights
Maybe this is progress.
EDIT - worked. Had the nonzero error I messaged about elsewhere, but seems that I found some random numbers that don’t cause it…since some real numbers (nonzeroes) were problematic.