I have a script which gets called from an automation. The script turns on two lights and then waits for a trigger before turning on more lights. The trigger is light level from a Hue sensor. The script waits for light level to fall below 14000 for 5 minutes. For some reason, the script keeps waiting indefinitely for this trigger even when light level has fallen below 14000 and remained there for hours.
When script is called, switch.under_cabinet_lights is turned on, then a 5 seconds wait, then light.family_room_table_lamp is turned on. But after that, script keeps waiting for light level to go below 14000. The switch.staircase_top_lights is never turned on.
Under Trace Timeline, it keeps showing Wait for 1 trigger and Still running even after two hours.
Keep in mind that for all triggers (which includes wait_for_trigger) the trigger must transition from ‘not met’ to ‘met’ in order for the trigger to be fired. If you enter that wait_for_trigger block and the light level is already below 14000 then you must wait for the level to rise above 14000 and then fall back below 14000 and stay there for 5 minutes.
This is a strong possibility that I did not check for. It is very much possible that by the time script is called by the automation, the light level has already fallen below 14000. I will try to eliminate this possibility and update this post. The trigger transition did not cross my mind. Thanks for pointing it out.
The only way that can be true is if the sensor has the illuminance value both as its state and as a light_level attribute. Please share a screenshot from Developer Tools / States showing the state and attributes, like this:
If you are guessing things like this, it’ll take you much longer to get to a working solution. Use the States view above to work out if you should be referencing the state (so no attribute: line) or an attribute of the sensor.