💡 Sensor Light - Motion Sensor - Door Sensor - Sun Elevation - LUX Value - Scenes - Time - Light Control - Device Tracker - Night Lights

@inancatl You can do it but you just need a separate switch to turn the bypass on. You can also have that switch if you like turn your lights on and if needed control a time delay. The switch can take the spot of your current light switch.

How it is now, the automation turn the light ON. The switch turn the light ON. That switch can’t be the by-pass as every time the automation turns the light ON it also turn the switch ON, and if the switch is the by-pass then every time the automation starts it turn the by-pass ON as well and stops.

EDIT: Just saw your edit. Yes your correct if that is how your smart switch is.

Is there an option the light stays on in the last place movement is dectected? That would be very useful for me.

Hi @oli737 Firstly welcome to the community.

If you are asking it to turn a light on when motion is detected and stay on until you manually turn it off then no, sorry.

If you are asking if you walk around your house and the lights turn on and off as you move around and when you stay in a room then the light stays on? then yes, but you will need to set up different automations for each room or area. To do this you just open the blueprint set your setting for the light and motion sensor located in that room / area and click save, name it (example - kitchen Lights). Then just do it again for the next room and so on.

New update 2.9

This is quite a big update :firecracker: You will need to clean up a bit of code in the YAML. I will post a “How To” below. It is quite easy to do … Sorry it had to be done to get transition set up nicely :wink:

Maybe consider hitting the :heart: at the top post if you liked it.

New Features :new:

  • Added transition time for lights. :partying_face:. You now can set the dimming time (Transition) of your lights when they turn ON and OFF so it is softer on your eyes. You can also use this option to notify you when the lights are about to turn OFF by selecting a longer “Transition - OFF” time. This can give you a warning indication that the lights are about to turn OFF by slowly dimming and allow you to wave your hands :wave: around so you can trigger the motion sensor and keep the light ON :bulb: :+1:.
  • Added crossover from night lights to normal lights. If the night lights and the trigger is ON when the night lights end time expires, it will now cross over to normal lights.
  • Added a safe guard :shield:. It will now check the automation and continue on a restart of Home Assistant :gear: :stethoscope: :infinity:.

Bugs Fixes :bug:

  • Fixed a bug in light flicker when crossing over from normal lights to night lights.
  • Fixed bugs when using multiple triggers.
  • Fixed a bug in the by-pass.

:page_facing_up: NOTE: It will only turn ON and OFF - Lights, Switches & Scenes now. This prevents you turning off automations, etc within an area if an area is selected.

:white_check_mark: The code is now to big to post at the top. There is a link to my GitHub at the top where you can copy the code and update your files. Click Here to go to the top where you can find the link to my GitHub.


Blacky :grinning:

1 Like

FAQ - How do you update the blueprint from version 1.8 - 2.8 to version 2.9 and above?

If you haven’t yet installed the blueprint then all you need to do is to click on the big blue button “Import Blueprint” at the top of this post and follow the steps. Click Here to go to the top of the post.

If you would like to update without deleting all your automations and the blueprint, then reinstalling the blueprint again and adding back all your automations then continue to read. It is very simple to do.

First you need to update the blueprint. If you don’t know how to do this then Click Here as I have a “How to update a blueprint” already explain for this. Once you have updated your blueprint then come back here and follow the steps below.

You will need to do this for each automation you created with this blueprint.

Go into an automation you created using this blueprint and click on the 3 dots at the top left, then select “Edit in YAML”.

You can now see your YAML code. You could see a two different options (see below) but we are looking for the two lines that say “include_light_control:… & include_night_light_control:…”.

Now you will need to delete the 2 lines with “include_light_control:… & include_night_light_control:…” as shown below. Then click save.

Then go back into your automation by again clicking on the 3 dots and select “Edit in visual editor”. You then will need to re-select your selections under “Light Control & Night Lights - Control” and click save. Your are done. :tada:

If you see something different with a row of dashes and letters, you will need to delete all the dashes, and some with a dash and a single letter “- a” as shown below.

From this

To this, then click save.

Once you have clicked save, you then will need to re-select your selections under “Light Control & Night Lights - Control” and click save. Your are done. :tada:

Now just repeat for all your other automations you created using this blueprint.

If you would like to check what you have done then go back into your YAML and it should look something like this depending on your selection options.

NOTE: If you don’t see one or both of the lines with “include_light_control:… & include_night_light_control:…” then you have never selected these options and your already good to go.


Blacky :grinning:

Back to FAQ: Click Here

FAQ - How do the time options work including night lights time?

Below are all the time settings and what they do.

Use The Time Options (Optional)

Enabling this option will allow you to use the start time, end time and weekdays. It will allow you to only run the automation as per your settings (within the time period). All of these time setting are a global condition and can work alongside with the other options.

Most of the questions we get are when using this option with night lights and night lights time. Most people ask, “My lights don’t turn ON when using night lights?” NOTE: You do not need to enable this option to use the night lights and night light times. If you would like the automation to run 24/7 then best to select “Disable the time options”. If you are using this option to restrict when the automation can run along with the night lights option, then you must include the night lights time. Example:

  • If you set a start time of 6pm to 7am and a night time of 10pm to 7am then the automation will only run between 6pm to 7am and the night lights will work between 10pm and 7am. All good, setting are correct :+1:.

  • If you set start time of 6pm to 10pm and night time of 10pm to 7am then the automation will only work between 6pm to 10pm and your night lights will never come on as it is outside of the global condition. Not good, setting are incorrect :-1:.

Start Time

The start of when the automation can run.

End Time

The end of when the automation can’t run.

Note: The start and end times are like a race. Start being “the start of the race” and end being the “finish of the race”


It will only work on the selected days. This is a good option if you have a different schedule for weekends using the same lights, or if your office is only open from Monday to Friday and you don’t want the light coming ON Saturday or Sunday.

Night Lights - Start Time

The start of when the night lights can run. You don’t need to “Enable the time options” for this to work. The “Night Lights - Start Time” is enabled when you “Enable the night lights options”.

Night Lights - End Time

The end of when the night lights can’t run. You don’t need to “Enable the time options” for this to work. The “Night Lights - End Time” is enabled when you “Enable the night lights options”.

Hope this gives you a better understand of the time settings.


Blacky :grinning:

Back to FAQ: Click Here

Back to “The Settings & Best Practice Guidelines” Click Here

Thank you again for yet another awesome update, your blueprints are always inspirational! :tada:

1 Like

Loving this blueprint, before I get started with it I’m wondering how the timer works for turning off. if I trigger with a contact and Motion sensor. Will the timer wait for both the motion and contact to turn off/closed? Basically is there a wait for both to be true then the timer starts?

Hey @Blacky,

One note, lines 611 and 643, service name mispelled as switcht.turn_off.

1 Like

@samuelthng Oh, I thought I fixed that. Thanks for letting me know. I will do an update.

Edit: I will also push out the next release early.

1 Like

Hi @geox19, firstly welcome to the community.

Yes but some times you will need use a group helper. When using a contact sensor I would recommend you set up a group helper. It will then work for you. Here is a link to the FAQ on this Click Here

1 Like

New update 3.0

There was a bug in the by-pass of Version 2.9, thanks @samuelthng for letting us know.

:warning: Because this release is to fix this bug in version 2.9 that was release a day ago, if you are upgrading from version 2.8 and below please read the release notes of version 2.9 before upgrading as you will need to clean up a bit of code in the YAML. Click Here to see version 2.9 release notes.

I have also pushed out a new feature early :slightly_smiling_face:.

New Features :new:

  • Trigger can now be an ON/OFF pulse in milliseconds. This can be useful if you trigger is fast reacting.

Bugs Fixes :bug:

  • Fixed a bug that lights could stay ON when crossing over from normal lights to night lights and from night lights to normal lights in a time trigger. Known issue, light could flicker when this happens. We will try and fix this in the next release.

  • Fixed a bug in by-pass.


Blacky :grinning:

Thanks for your kind words. It is nice to hear you like them and just get a nice feedback :smiling_face_with_three_hearts:

Hi! First of all, thanks for the great blueprint!
Got one question, after updating to 2023.4 my automation stopped working correctly. My lights are switching on after motion detected, but switching off instantly. So it’s like a flash only, updating to 3.0 didn’t resolve the issue.
I’m using Hue spots with SkyConnect + ZHA.

alias: Lampen hal en trap aan bij beweging
description: ""
  path: Blackshome/sensor-light.yaml
      - binary_sensor.bewegingssensoren
        - 50c5bc6b0d4211eb8cc7ef4b9dc9b663
        - trap
    light_brightness: 50
    include_night_lights: night_lights_enabled
        - 50c5bc6b0d4211eb8cc7ef4b9dc9b663
        - trap
    night_time_delay: 2.5
    end_scenes: []
      - use_brightness
      - use_transition
      - use_brightness
      - use_transition
    night_light_brightness: 50
    night_lights_after_time: "23:00:00"
    night_lights_before_time: "06:30:00"
    time_delay: 5
    include_bypass: bypass_disabled
    light_transition_on: 1.5
    light_transition_off: 2
    night_light_transition_on: 1.5
    night_light_transition_off: 2

Any ideas? Thanks!

Hi Scott, thanks for your question, providing your YAML and welcome to the community.

We are on Home Assistant 2023.4.2. We have done a lot of testing with this update and it is all working perfectly here.

The blueprint must pass through the time delay before it will turn off your lights, so I would expect that something else could be the problem.

All your settings look ok. I have noticed you are using area’s so maybe your turning on something else that is turning off your lights. Maybe try and expand your area down to entities (from orange to green colour) you would like to control by clicking on the expand “<>” of your area (see below).

Another thing you could do is, trigger the automation and straight after this happens have a look at your traces. You can find it in the top right next to the 3 dots in your automation called “Traces”. Follow the orange line, it shouldn’t be at the end as you have a 5 min or 2.5 min delay.

Once you confirm your traces, and know the automation is not turning off the lights maybe check your other automations or have a look at your logbook.

1 Like

Just setup most of my lighting automations using this blueprint. What a time saver. I’m coming from Hubitat and having to learn some of the ways to do things in Home Assistant can really eat up the time. This blueprint let me point and click my way to success. Thank you Blacky
Where’s the donate link?

1 Like

Thanks for the welcome and your detailed answer. :smiley:

Apparently I put the hallway spots in a group and added it to the same area, so removing the group did the trick.

Thanks again and awesome timesaver for me. :+1:

1 Like

What a great blueprint. I use it for my setup as well. The only issue I have is the unwanted light turn off action when no motion is detected (for example on the toilet and your sitting still). Will there be a presence detection logic in the future that combines a door and motion sensor?

Hi @geox19

No problem at all glad you like it :+1: Nice to get this type of feedback :smiling_face_with_three_hearts:

I haven’t go one… Maybe I should set one up for people to say thanks… will let you know if I set one up.Thanks for your offer and your kind words. :+1:

1 Like

Hi @dkarijopawiro , firstly welcome to the community.


Could you explain how you think it should work? I will help me understand :thinking:.

Currently if you are using contact sensor (a door) and motion sensor I would recommend that you put them into a group for this to work correctly. It is in our FAQ, and here is the link on how to set one up. The only thing is if you close the door then the light will come on and I not sure if this is what your after.

If you have a fan in the toilet then maybe consider using my other blueprint called :toilet: Toilet Exhaust Fan with time delay