Turn on light, switch, scene, script or group based on motion, illuminance, sun (+ more conditions)

Do you have errors in your home assistant log? Did you check the automation debugger?

I think you have an outdated version of the blueprint. Can you try reinstalling it and trying again?

Hi,

Thanks for your heads up. I didn’t find anything revealing in the logs or the traces (i find the traces very cryptic for my level of knowledge). :confused:

But I found a workaround for my case. My lights are all Philips Hue and they are set to turn on/off the last state/scene. So I select a scene from the Hue app, and when the automation triggers the lights in HA, then the last scene gets turned on/off. It’ll do for my use case.

Please add the conditions for sunset and sunrise

1 Like

Hi! Great blueprint thanks for making this. I’m probably missing something simple as I’m still new to HA, but how can I set this up where if I turn the light switch on manually it will block the turn off automation? I can’t think of how to automate turning on an input Boolean blocker from the light switch turn on without the boolean also turning on when the automation turns the switch on

That is indeed not very easy to solve.
This thread might give you some ideas.

Just want to say thank you very much for this blueprint.
I have recently moved from Homebridge to Home Assistant, as I think the new HomeApp is ass on ios16, and want some more flexibility.

I came across a comment essentially saying to not reinvent the wheel when you are creating automation and use blueprints as they are tried and tested. I went to the repository where they all are, and sorted by top - and this seemed to be the winner for automating lights.

As a complete newbie it did take me a little time in setting up the helpers (I hadn’t set one of those up as of yet) and assigning them.

While your documentation at the top is correct, from a complete newbie stance, its hard to understand as it assumes some knowledge. But with a bit of bashing about I was able to get there - and now understand your documentation more. Its super important to understand what entities / helpers, and their different types are, and how to set them up.

In my use I am using a Philips Hue sensor to turn on 2 downlights in my ensuite. Your blueprint is working great, as i want different lux levels and colors based on time of day.

If we could request a possible option: Sunrise/Sunset as an option.

For example, i would like my lights to turn from cool white when they are triggered during the day, to warm white if they are triggered after sunset. It may not be possible, and that’s understandable, but would be a great improvement if possible.

Either way that’s enough of my rambling, i think its important for people to know that the community work they do is appreciated, so thank you for doing this and sharing it.

Dave

I’ve been using this blueprint extensively for managing my lights for some time now and it works great, thanks. However, I’ve come up against an issue with using the optional turn-off entity:

If defined, this entity will be turned off instead of the default target entity. This can be helpful when using target entities of type scene or script.

If I put the name of a scene in there, it does not work. Looking at the code it generates I see this:

        sequence:
          - delay:
              minutes: '{{ states(no_motion_wait) | int(0) }}'
          - service: homeassistant.turn_off
            entity_id: scene.tv_dining_area_lights_off_scene

So it’s using the homeassistant.turn_off service to cail the scene. This does not work, it should use the scene.turn_on service.

Have I misunderstood something or is this a bug?

You seem to have misunderstood indeed.
Since a scene cannot be turned off, when you use a scene as a target entity, you also must define a turn-off entity (most likely a light or light group), otherwise nothing will turn off.

Thanks for the kind words. When I have some free time I’ll try to add sun state as a condition for this blueprint.

The scene is being used to turn off some of the lights in the area and to dim others, I use it in other automations using the scene.turn_on service. Yes, I could create a light group but that will only turn off all the lights in the group, so no dimming.
Your blueprint mentions target entities of type scene or script. which I took to mean that I could put a scene entity in there and it would trigger it.

If you want to do more than just turn lights off after the wait period has ended, this blueprint does not support that. Unless you would use a hacky workaround, like turning off an input_boolean helper (set as the turn-off entity). That helper entity would then be a trigger for a separate automation that turns on the scene you want to be activated. The question however if it’s then worth the effort to use this blueprint, or write your own automation altogether. That’s up to you :wink:

Yes, that’s exactly what I ended up doing, and it works fine even if it’s a bit hacky as you say.It’s just that the text describing that option let me to believe that it supported scenes directly.
Thanks!

I now took some time to add sunrise/sunset as a possible condition.
Please update the blueprint and see if it works for you.

Would it take much to tweak the blueprint to trigger based on just illumination without using a motion sensor.

Hi,
would it be possible to add a condition check for Turn-off Blocking entity just before the turn-off?
The reason ist this:
I have a template turn-off blocking entity which is getting activated if I manually press my switch 2 times within 3 seconds. But the automation is already started and already checked the turn-off blocking entity. So, the light goes off and I have to manually switch it on again.

Thank you for the nice coding :slight_smile:

The automation works like a charm with one exception. Can you please have the turn-off blocking entity to check right before turn-off? It seems that this was solved in the past, but it does not work any more.

I have made a helper entity (switch) which can be changed with a remote, but the automation does not act accordingly when the turn-off blocking entity is changed to an “on” status when the automation is already started.

It looks like the automation does not check the turn-off blocking entity right before the turn off. I tried it by putting the entity in an “on” status before the automation starts, but then it works fine.

EDIT: Actually it seems that it is quite simpel.

It was solved in my case when I exchanged the “wait for motion sensor” (5 lines) and the “turn-off blocking entity” (4 lines) in the YAML. I do not know if you had bad experiences with this exchange?

@andisp @FlorisMark I see your points, I think I fixed the issue in a new version of the blueprint.
Please test the new version and let me know if it now works correctly.

I would appreciate this feature (using luminosity as trigger instead of motion) as well.

My use case:
when it’s getting dark outside (sunset, rain, …) I would like to switch on some lights.
and of course the opposite, when it gets lighter outside (rain is over) I would like to switch the lights off.
at midnight the lights should be switched off in any case.

That’s a good one, as I am running into the same issue. But then for “Turn off time”.

I use the blueprint for managing my bathroom lights. I want to increase the turn off time if somebody is using the shower. I have a script that will increase this helper (actually based on my humidity fan). But it seems this helper is not being updated if the blueprint already runs