Motion-activated light between dusk/dawn (with offsets) only if ambient LUX is low. Includes adjustable timer

@Beerlesklopfer further problems with using your blueprint …

I took control of my automation created from your blueprint so I could correct the condition templates from using now() to as_timestamp(now()); which stopped the automation crashing.

Waited until after dark then triggered the motion sensor, but the light doesn’t come on.

Looking more closely at your condition code, it looks to be flawed and as written will never work.

Specifically, the condition code checks:

          {{ as_timestamp(now()) >= (as_timestamp(state_attr('sun.sun',
          'next_dusk')) + (dusk_offset * 60)) }}

with the intent that its checking that its after the sun has done down

and also

          {{ as_timestamp(now()) <= (as_timestamp(state_attr('sun.sun',
          'next_dawn')) - (dawn_offset * 60)) }}

and that the sun hasn’t risen yet.

BUT as soon as the sun has gone down, state_attr(‘sun.sun’, ‘next_dusk’) will return the date/time OF THE NEXT DUSK, i.e. tomorrow’s dusk NOT today’s

So right now, at 21:36 on 25/8/25, sun.sun attributes are:
next_dawn: 2025-08-26T04:24:29.653954+00:00
next_dusk: 2025-08-26T19:38:59.713211+00:00

So the next_dusk test will always fail and the light not come on after dark.

I suspect there may be similar issues with the next_dawn and the code during the daytime.

Am wondering how you tested this blueprint?

Looking at other blueprints to see how they handle this, the couple I looked at do not use next_dawn and next_dusk, instead they use the sun elevation

e.g. :bulb: Sensor Light - Motion Sensor - Blueprints Exchange and read this FAQ Why did you choose to use sun elevation?

For now I will disable the template conditions for dawn and dusk and rely on only the lux sensor. The blueprint needs rewriting to handle operation after dark, sun elevation might be the easier route to go down rather than complex date/time manipulation based on the sun position and today/tomorrow dusk etc