Hi folks, I have the following script (actual script contains a number more lights). It is triggered by a time automation, designed to check if any lights are on, and if they are, brighten them and up the kelvin.
I realise probably not the cleanest way to do this (i.e. could use a loop of sorts, so open to suggestions), but my main issue is, let’s say light.bor1 is on, then it performs correctly and brightens. If light.hallways is actually off though, the script just stops, rather than moving on to the next light to check whether that’s on.
If one step fails because the light is off, how do I make sure the script continues to asess the rest of the lights?
Why would a light.turn_on action fail because a light is off?
You can add a continue_on_error: true parameter to an action, but that may or may not do anything depending on how the integration in question handles errors and why the error occurred. If you try to execute a non-existant action or supply an action with faulty parameters then the parser will fail rather than the action and thus won’t continue anyway.
The else probably isn’t necessary. And you’re right, the bulbs don’t actually go to 0 Kelvin. The min on these is 2202. That said, that isn’t cause an error. If I ensure all bulbs are on, the automation runs just fine. So just trying to establish how to make it continue if a bulb in the middle of the sequence happens to not be on already.
Can you show us the code you used with continue on error?
I’m quite sure it’s either the brightness 0 or the kelvin 0 that is the cause, since those are 0 meaning there is a division by zero
Is it possible to do that? Just not have an else or should I use something else to do an else do nothing with this bulb?
I tried removing the else and I tried using null in place of 0, but that just gave the error: Error: expected int for dictionary value @ data['brightness']
Message malformed: Entity {{ repeat.item }} is neither a valid entity ID nor a valid UUID for dictionary value @ data['sequence'][0]['repeat']['sequence'][0]['if'][0]['entity_id']
More than likely the issue is the zero Kelvin color temperature.
Some bulbs and/or integrations only accept a color temperature in mireds. The formula for converting Kelvin to mireds is 1000000 / color_temp_kelvin which would lead to the division by zero error.
Use a lowest color temperature of 1 instead and it’ll probably work.