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

Hi Blacky,

With the changes of reproducing the issue being very slim, I tried something else just now.

I have put the transition time to 10 seconds.
During the dimming HA led state is “Off”, which is a good thing.
During the dimming I triggered the motion sensor to see if this messes things up.
And it did…
Lights went off (HA thinks it’s on) and couldn’t get them on again using the motion sensor. All I got is a quick flash once motion is detected.
If I look at the logbook it looks the same as it’s functioning properly.
Had to disable and enable the automation to get it working again.

So I guess this is related to the led controller, but disabling the transition time might eliminate this.

So for now I will disable the transition time and if that eliminates the issue then I’m fine with it.

Thanks so far Blacky, and have a nice weekend!

Hi, I love the blueprint and have used it for the last few months.

I’ve decided that I wanted to change it slightly but I can’t seem to get it to work.

I want the lights to be on a dimmed setting between sunset / dusk and 2300 daily, but when the PIR sensor activates I want the light to go to a bright setting for a few minutes and then return to the dimmed setting.

Is this possible?

Thanks in Advance

1 Like


sorry for the late reply ! Tried what you suggested but still no luck. The lights still go off after 2 Minutes ( as set in the Blueprint).
I will continue fiddling around with it.


Thanks for your kind words.

Yes, there is a but though.

Before I explain the “but”, I agree this is something that needs to be resolved and will require some thought and some consideration. I will put it on the list.

Now the “but” or the how to.

  1. First create an automation using this blueprint.
  2. Set up your lights as required.
  3. Create a scene for your dimmed lights. Enter that scene into “Scenes To Turn OFF”.
  4. Enable the sun condition and adjust your settings to your liking.
  5. Enable the time options. Set the start time to a time the sun will be above your sun elevation setting. Like 4pm. Then set the end time to 2300.

This will now do the motion part and reset to dim.

Next step

  1. Download my other blueprint. :gear: Turn Light, Switch or Scene On & Off with Trigger Conditions
  2. Create an automation using this blueprint.
  3. In "Lights - Switches - Entities - Scenes " enter the dimmed scene used in the first sensor light automation.
  4. Create another scene with all the light OFF and enter it into “Scenes To Turn OFF”.
  5. Enable the sun option with the same settings as in the first sensor light automation.
  6. Enable the time option and set your start time to 23:00:01 (and 1 second).
  7. Set the end time to 23:00:02 (and 2 second).

This will turn the light ON to the dimmed setting sunset / dusk and turn the lights OFF at 23:00:02.

Your done

Hope this helps

Blacky :smiley:


:warning: NOTE: HA is releasing a new helper for templates. Maybe just wait for the next release before you do all this work. It will be out this Wednesday for HA release 2023.9.

There are many ways to split up the configuration. There is no wrong or right way to do it, it just realy depends on the way you would like it + it must work. Before splitting up your configuration I would strongly recommend that you do some research before committing to one way, as it takes some time to set everything up. Below are two links to the official Home Assistant website on this topic (there could be more but this is what I know). Both ways work. There are also a lot of different posts on this forum + some YouTube videos also on this topic so maybe check them out.

  1. Splitting up the configuration
  2. Packages

The way I like is; Splitting up the configuration - Advanced Usage " !include_dir_merge_list". For me it is very similar to you normal PC file structure. I simple and easy and I like that. Below I will show how I set up my template sensors as I did create a FAQ on template sensors in this topic. This “Sensor Light” post is not a “How To Use Home Assistant” and would prefer to stay on topic of this blueprint so I will stick to just template sensors. If you would like more information on split up the configuration please search this forum or create a new topic. There are a lot of active community members that will be able to assist you.

How I split up the configuration

1 - First most important, do a full backup of your Home Assistant, and store it in a location where you can get to it if you brick your Home Assistant (on a separate computer not running Home Assistant).

2 - You must have a file editor. There are few to choose from. If you don’t have one already installed then this is how to add the official “File Editor” into your Home Assistant. Go to Settings / Add-ons and then click on “add-on store”. In the " Official add-ons" heading you will see “File Editor”, click on it and install it.

3 - Once you have a file editor you will need to create a new folder called “template” in the main directory “/config/” (same location you can see your “configuration.yaml” file). Once done you will have “/config/template” folder location. This is where we are going to put all our template sensors. In this folder I have also created another folder called “sensors”. This is where I put all my sensor in. I don’t care if they are a “sensor”, “template binary_sensor”, “template trigger_sensor”, etc they are all in the one folder. Some people like to split there sensors into the domain of the sensor, it up to you. So now I have a “/config/template/sensors” folder location.

4 - In your “configuration.yaml” file we will need to point HA to it. To do this you would enter this code.

template: !include_dir_merge_list template

Now all your templates must go into this folder.

5 - In the “/sensors” folder, I create a new file for each sensor. We will use the template sensor I call “Bee In The Hive” for this example. So I create a file called “bee-in-the-hive.yaml”. Note: You must have the “.yaml” for each file you create. In that file I put this code as described in my FAQ Template Sensors.

# Bee In The Hive

  - trigger:
      - platform: state
        entity_id: binary_sensor.your_door_sensor_here
        to: "on"
      - platform: state
        entity_id: binary_sensor.your_door_sensor_here
        to: "off"
          seconds: 10
      - platform: state
        entity_id: binary_sensor.your_motion_sensor_here
        to: "on"
      - name: "Bee In The Hive"
        device_class: occupancy
        icon: mdi:account-box-outline
        state: >
          {{ is_state('binary_sensor.your_door_sensor_here', 'off') and is_state('input_boolean.testing_motion_sensor', 'on') }}

Note: We did not need to put


at the top if each sensor file as this is back in the “configuration.yaml” file.

Then check your configuration by going to “Developer Tools” and “Check Configuration” link. Once it passes " restart HA with one sensor first to make sure you have everything correct. Test it make sure it is working. Then when you feel confident add the rest of your sensors checking your configuration every time you add a file as it is easer to find what you have done wrong.

Then you would just do the same for all your template sensors in there own file.

Hope this helps you.

Blacky :smiley:

1 Like

New update 4.7

:warning: Some work is required in this upgrade. Please see below on the steps required when upgrading. It is easy and not a breaking change.

New Features :new:

:white_check_mark: MULTIPLE BY-PASS UPGRADE

In our update to version 4.5 we added the ability to have multiple by-pass switches. Example, by-pass for;

  • All light Automations
  • Party Mode
  • Guest Mode
  • Night Time
  • Sleep Mode
  • Movie Mode
  • Upstairs Lights
  • Downstairs Lights
  • Bedroom Lights
  • Smoke Alarm
  • Alarm System
  • Kitchen Lights
  • Outside Lights
  • Etc

It allowed multiple by-passes but you could only select one enable option and each by-pass could require to preform a different action.

In this update you can now add multiple by-pass switches for each of the 3 different by-pass enable options :partying_face:

  1. Enable the By-pass - Turn lights ON
  2. Enable the By-pass - Turn lights OFF
  3. Enable the By-pass - Keep the lights current state

Now you can created multiple by-passes with different actions. Example, by-pass for;

  • All light Automations = ON & OFF
  • Party Mode = ON
  • Guest Mode = Pause
  • Night Time = OFF
  • Sleep Mode = OFF
  • Movie Mode = OFF
  • Upstairs Lights = ON & OFF
  • Downstairs Lights = ON & OFF
  • Bedroom Lights = OFF
  • Smoke Alarm = ON
  • Alarm System = ON
  • Kitchen Lights = ON & OFF
  • Outside Lights = ON & OFF
  • Etc

Hopefully it will help assist you on how you control your lights.

Example Use Case: Say it is a windy night and your outside lights keep going ON. You can now have a by-pass that is for “All Outside - Lights OFF” and add this bypass into every outside light automation. Then you can turn ON one by-pass switch and all your outside light will go OFF and stay OFF (disabling every automation). What happens if you hear something outside you could have a by-pass “All Outside - Lights ON” and add this bypass into every outside light automation. I think you get the idea behind it. There are so many scenarios that you can do.
We are also getting ready for more to come in the road map ahead :wink:

:warning: BLUEPRINT CODE UPDATE :exclamation:

Just a heads up if your still on a old HA version before you update.

From time to time Home Assistant update their code structure and the old code will become “DEPRECATED” stopping / breaking automations from working. It effected this blueprint about 4 to 6 months ago. I wanted to wait some time so everyone had a chance to update their HA version before updating the code as older HA versions can not run the new code. This blueprint has now been updated so it will still operate once HA remove the “DEPRECATED” code from their system. :wink: :+1:

Bugs Fixes :bug:

  • Fixed bugs in HA restart.

:warning: :stethoscope: STEPS REQUIRED WHEN UPGRADING :white_check_mark:

If you have never selected to use a by-pass then most likely you won’t need to do anything but you may want to check just encase you have selected by-pass in the past.

1 - Upgrade your blueprint.
2 - Go into your automation (the ones using this blueprint). Click the 3 dots top right and “Edit in YAML”. We are looking for orange text “include_bypass”, “motion_bypass” & “include_bypass_auto_off”. If you don’t see this then your all good to go and have never selected the by-pass. If you see this then read on.

3 - Take note of the code so you can remember what by-passes were used in the automation. We then are going to completely remove the orange text including the black input text for “include_bypass”, “motion_bypass” & “include_bypass_auto_off” as shown below.

4 - Then click 3 dots and select “Edit in visual editor”


5 - You will then have a clean input selection for your by-passes. Update / add the by-passes into the correct corresponding inputs.

6 - Click save, you’re done. Now just do the same in your other automations using this blueprint.

If you would like to easily find all the automation that are using this blueprint so you can check your YAML. Go into blueprints and click on the 3 dots next to the sensor light blueprint and select “show automations using this blueprint” You then can easily edit them all. See below.

If you like this blueprint? Consider hitting the :heart: button in the top post :+1:

If you like my blueprints, and would like to show your support or just say thank you? Click Here :smiling_face_with_three_hearts:


Blacky :grinning:

Back to FAQ: Click Here


Thank you very much for the time and detailed explanation… I’ll give it a whirl and let you know how I get on :+1:

And a but with a how to, isn’t really a but :joy:

No problem at all :+1:

Yea it is always nice to know how you go.


In first place, thank you for this amazing blueprint. It’s great.

I have a problem with it … When sun elevation is below !input sun_elevation, lights switch on without the motion trigger still being activated. I have to manually switch off the lights and then everything works as expected. I don’t know if I’m missing something or my configuration has any error.

Here it is my blueprint configuration:

alias: Home:luces hall automáticas
description: Controla luces del hall con sensor de movimiento
  path: Blackshome/sensor-light.yaml
      - binary_sensor.sonoff_a4800671ba
    time_delay: 0.5
    include_light_control: []
    light_brightness: 75
    light_transition_on: 1
    light_transition_off: 1
    include_sun: sun_enabled
    sun_elevation: 4
    include_night_lights: night_lights_enabled
      entity_id: scene.luces_hall_pinar_naranja
      - scene.luces_hall_pinar_apagadas
      entity_id: scene.luces_hall_pinar_noche
    night_time_delay: 0.5
      - time_enabled
    night_lights_before_time: "08:00:00"

Thank you!


Your welcome, glad you like it and thanks for your kind words.

Thanks for providing your YAML… it all looks good :wink:

I have this set up at home and it runs every day. The light should not come ON when the sun elevation crosses over and your motion sensor is “clear”. It will only turn ON when the sun elevation crosses over and your motion sensor is “Detected”. If it turned your light ON, when your motion sensor becomes “clear” it will turn OFF the light.

I suspect that you may have another automation turning it ON and that is why you need to turn it OFF as this blueprint automation never triggered thus not turning OFF your light when the motion sensor is “clear”. I have been caught out on this many times :pensive:

What I would do is monitor it one night. When the light turns ON check your automations and see what triggered it. A easy way to find it, is to look in your logbook. As you can see below in my logbook I can see that the hallway lights were turned on by the “Hallway Lights” automation with motion sensor 1.

Then you can click on the link to edit it and or delete / disable the automation.

Let us know if this fixes it.

Blacky :smiley:

@Blacky not sure whats wrong but since i updated to the latest ersion the bypass switch is not work as before, i.e in my kitchen i has where when i entered the room the under cabinets led’s and floor led strip would come on, for 1.5mins, but if i turned on the LED’s going off if they was no motion for 1.5 mins. But this now is happening, the cabinet and floor LED arr turning off if someone is not moving arroud.

here’s my config, can you see anything wrong ?

alias: Kitchen Motion Light
description: ""
  path: Blackshome/sensor-light.yaml
      - binary_sensor.kitchen_motion_sensor_occupancy
    include_light_control: dont_use_brightness
    include_sun: sun_enabled
    time_delay: 1.5
      - scene.kitchen_motion_light_off
    include_night_lights: night_lights_disabled
      entity_id: scene.kitchen_motion_light_on
    sun_elevation: 0
    light_transition_on: 0.5
      - light.kitchen_lights
      - light.kitchen_lights


Hi Andy, thanks for asking the question.

You have selected light.kitchen_lights for 2 scenarios.

      - light.kitchen_lights
      - light.kitchen_lights

I wouldn’t do this at it will fight each other ON / OFF. So before you updated what by-pass did you use.

  1. Turn Lights ON
  2. Turn Lights OFF
  3. Keep The Lights Current State

So you haven’t enabled a by-pass yet. So you will need to select what enable option you had before. 1, 2 or 3. Then whatever option you select you will have to enter light.kitchen_lights into the correct input. Below is an example of my hallway lights. Don’t use the same entity for 2 options.

Dope!!, I feel so stupid for missing this option, before I just had it as ON, I have done it as you have your Hallway.

Thanks again.

1 Like

No problem, happy to help :smiley:

You can now see that you can have different by-pass that will do different actions.


I’ve been looking at yesterday’s history and the problem was with the motion sensor, which, I don’t know why, was on from 18:08 (when I left home) until I arrived back, at 23:33. So, as it was on when sun elevation triggered the automation, ligths set on at that time.

One additional (related) question. Is there any option in the blueprint that allows the timeout to start from the off->on of the motion sensor instead of from the on->off? I could use it to avoid lights being on all the time if motion sensor is stuck in on state.

In this case, timeout timer would start from the off->on triggering of the motion sensor, and if another off->triggering occurs before timeout, the timer would reset.

It would have one additional advantage, as some motion sensors (mine) stay in on state for a couple of minutes not to trigger so often and save battery. If timer starts from the off->on triggering, it could be set to less time than minimum, which is the “on timeout” of the motion sensor.


Yea well that makes sense.

No, it wouldn’t work correctly.

If your sensor has a time delay already in it then set the time delay in the automation to “0”.

If you like try my blueprint :round_pushpin: State Notifications & Actions but the next update is what you need, be out soon. Then you could set up a notify to send you a message if your motion sensor is ON for X amount of time. Then you will know to reset it. :wink:

Ok, then I forget about it.

It’s a hardware sensor, and the only possibility is to reset it unplugging the Zigbee bridge from electricity. I’ll do that with an automation.

I’ll wait for next update then.
Thank you!

1 Like


It has been updated now :round_pushpin: State Notifications & Actions



1 Like

Edit: I deleted the original message as when reading the yaml I noticed the line ambient_light_options: ambient_light_option_disabled which I now removed, hoping that my lights will turn on this evening even if there’s constant motion, meaning the motion trigger will trigger very rarely and stay at ON for many, many hours.

Yes it will work. Also notice that in ambient there is also a site condition. So if your sensor is effected by the lights when they turn ON then you would select YES.