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

Hi Blacky,
Great automation. I love the brightness adjustment based on lux option. I understand we can set night lighting conditions when a boolean switch is turned on. Is there a way to set lighting for other modes (other than night)? The only way I see is to use the bypass feature and have another automation activate a scene. Is this correct or am I missing something?
Louis

:santa: Santa is coming:christmas_tree:and 2025 :partying_face:

@Blacky
Many thanks for your comprehensive and handy blueprints, and for all the support throughout the year.
Merry Christmas and all the best for the New Year!

3 Likes

Hey Blacky,

I need to implement a second state for my lights. They should dim to 50% before they go off. But this only should happed if the turned on by the sensor.

Where can I implement such a sequence?

Thx for this fantastic blueprint.

@Spencer8742

Because you are wanting the automation to run 24/7 you don’t need to enable the main time condition so I have disabled that and cleaned up your YAML as I see there were some old code in there. Also in Night Light Control I enabled If lights are ON, adjust the lights when crossing over so if the lights are ON they will transition to the correct brightness. Up to you if you don’t want that then just disable it. Also consider using the Transition if required. Below is you code fixed up.

Note: If you were not running 24/7 then your main time condition must include the night light time. Example main time from 5pm to 5am and night light time from 10:30pm to 5am. You can see the night light time is included in the main time.

id: '1701985979449'
alias: Upstairs Bathrooms Lights
description: ''
use_blueprint:
 path: Blackshome/sensor-light.yaml
 input:
    motion_trigger:
      - binary_sensor.upstairs_bathroom_motion_sensor_occupancy
    light_switch:
      entity_id: light.upstairs_bathroom_lights
    include_light_control: use_brightness
    include_night_lights: night_lights_enabled
    night_lights:
      entity_id: light.upstairs_bathroom_lights
    include_night_light_control:
      - if_lights_are_on_adjust_when_crossing_over
      - use_brightness
    night_light_brightness: 2
    night_lights_after_time: "22:30:00"
    night_lights_before_time: "05:00:00"
    time_delay: 30
    night_time_delay: 3
    night_lights_conditions:
      - time_enabled

Enjoy

Blacky :smiley:

@will5

Yeah there is a lot of logic in the code. You could have a custom automation that when you turn the bypass ON it sets your light to 100% but I can see when testing this I need to fix a bit of logic in this blueprint so when you turn the bypass OFF it resets you lights to the correct % value. I will have to update the blueprint for this to work.

Blacky :smiley:

1 Like

@victoroos

When you turn ON a bypass, it executes the action associated with that bypass. If you activate another bypass, the system will perform the action for the newly activated bypass.

Examples:

  • Turning ON Bypass Option 1 turns the lights ON.
  • Turning ON Bypass Option 2 turns the lights OFF.

Once all bypasses are turned OFF (cleared), the system evaluates site conditions and reacts based on your trigger settings.

Scenarios:

  • If the lights are ON and you turn OFF the bypass, they may not turn OFF immediately because:
    • The trigger is still active.
    • The Bypass - Time Delay is still in effect.
  • If the lights are OFF and you turn OFF the bypass while the trigger is active, the lights may turn ON depending on the conditions you’ve set.

Blacky :smiley:

@Olli0073

I think your asking for a feature that is already there. Have a look under Ambient

Blacky :smiley:

@lmmalouin

Currently there are only 2 modes that I call normal lights and night lights. If you would like more different modes then you could use a script and say if X is on then = ABC lights @ 30% green if XY is ON then = ABC lights @ 60% blue etc. You can make as many as you like


Blacky :smiley:

@b_tton

You would use a scene or script to turn the light ON in Lights - Switches - Scenes - Scripts and then in your Scenes - Scripts To Turn OFF you would use a script to turn your lights first to 50%, delay and then turn OFF.

Blacky :smiley:

This is a great blueprint, thankyou. I have a few improvements mainly allow multiple ambient light sensors.

I think I have found a bug or oversight, if I have night glow enabled and dont have all of the “night light entities” selected in the “night glow” entities then the night light entities never end up turning off.

I have a hallway with a few bathrooms that I have 4 of the Third Reality night lights that have a motion, illumination and color bulb. I have 2 of them in them in a hallway and another 2 in bathrooms connected to the hallway. Ideally Id like the lights in the hallway to enable night glow and then have the 2 lights in the bathroom only act as a night light and turn off after no motion. As it is now the lights in the bathroom dont seem to get the off signal.

@Ksully86

Please see this FAQ click here

I have tested it here and it is working
 please look at Night Lights - Time Delay as this is the time it will take to transition back to night glow once your motion sensor is clear.

I am working on this blueprint now so if you could you please provide us your YAML of the automation? This YAML code are the settings you have selected in the automation so I can help. To do this go into your automation, top right 3 dots, Edit in YAML, copy all the code, come back to the forum and in your reply at the top tool bar click on “</>” and paste code in there.

Blacky :smiley:

New update 7.4

:santa: Merry Christmas to all and all the best for the New Year!

Your lighting experience, your way – take control and customize it to perfection! :bulb::sparkles:

:bug: Bugs Fixed

  • Fixed a bug in the bypass function where, when the bypass was turned ON, changes in site conditions from normal lights to night lights or glow lights were not evaluated correctly when the bypass was turned OFF. This bug has now been resolved.

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:

Enjoy

Blacky :grinning:

Trying to see if this would work for me. My biggest problem is my cat that keeps me from just using mmWave.
Is it a correct use of the bypass to use the PIR for triggering and mmWave for Keep current state bypass?
I want to trigger with PIR but keep on if mmWave is detecting something.
Ideally I’d like to trigger with PIR, keep on if mmWave is detecting but no longer than 30 minutes (unless PIR is high again).

@Warthog

I would try and look at the problem (The Cat). So there are a few ways.

  1. You could use the Device Tracker so the automation will only run then you are home. If you are away the cat wont / can’t trigger the automation.
  2. Maybe manually turning ON the light but then have the PIR or the mmWave keep the light ON and turn it OFF for you. Take a look at this blueprint :magic_wand: Manual light control with auto OFF
  3. Have a look at the Aqara FP2. I don’t have one but I understand that they may ignore cats and only look for humans. You will have to research this.

Blacky :smiley:

New update 7.5

:santa: Hope everyone had a Merry Christmas to all and all the best for the New Year!

Your lighting experience, your way – take control and customize it to perfection! :bulb::sparkles:

:bug: Bugs Fixed

  • Fixed a bug in bypass. This is when using my other blueprints that may have an automation link.

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:

Enjoy

Blacky :grinning:

Hello all! I’m not sure i’m using it right or if its possible.I have until now just had 2 scenes to control my garden lights. 1 turn off at 8am and 11pm, 1 turn on 5.30am and 6pm. But i bought a sensor and would use this blueprint to turn on the lights in the periods where its not controlled by the timebased scenes. Problem is that then the sensor is triggered within the scenes turn on periods, its turn off the lights after the time set in the blueprint. Is that what the bypass function could be used for or?

Hey!

I am trying to implement the night light function in my automation. Turning the night light on at the selected time works just fine. But it doesnt turn back to the normal light at the end night light time. I guess i have an error in my logic. It fires at 15:05 but nothing happens at still stays at the night light.

alias: Sensor Light - Wohnzimmer
description: ""
use_blueprint:
  path: Blackshome/sensor-light.yaml
  input:
    motion_trigger:
      - binary_sensor.group_motion_sensor_wohnzimmer
    light_switch:
      entity_id: light.wohnzimmer_decken_lampe
    include_light_control:
      - use_transition
    include_bypass: []
    motion_bypass_lights_on: []
    motion_bypass_lights_off: []
    include_bypass_auto_off: []
    include_ambient: ambient_enabled
    ambient_light_sensor: sensor.wohnzimmer_presence_sensor_illuminance_lux
    ambient_light_options: ambient_light_option_disabled
    ambient_light_value: 150
    include_device_tracker: zone_people_enabled
    zone: zone.home
    people:
      - person.test
    night_light_brightness: 10
    night_light_colour_temperature: 2300
    motion_bypass_lights_stop: []
    include_dynamic_lighting: disable_dynamic_lighting
    dynamic_lighting_min_brightness: 1
    dynamic_lighting_sun_elevation_end_falling: -13.5
    dynamic_lighting_sun_elevation_start_rising: -13.5
    dynamic_lighting_sun_elevation_end_rising: 60
    dynamic_lighting_sun_elevation_start_falling: 60
    dynamic_lighting_lux_sensor: sensor.wohnzimmer_presence_sensor_illuminance_lux
    ambient_light_high_value: 350
    light_transition_on: 2
    light_transition_off: 5
    bypass_time_delay: 5
    light_colour_temperature: 2400
    include_light_colour_control: disable_colour_control
    include_night_lights: night_lights_enabled
    night_lights_conditions:
      - time_enabled
    night_lights_after_time: "14:50:00"
    night_lights_before_time: "15:05:00"
    include_night_light_control: []
    night_boolean_scenes_scripts: input_boolean.toggle_helper_night_light_wohnzimmer
    night_lights:
      entity_id: scene.night_light_wohnzimmer
    end_scenes:
      - scene.night_light_wohnzimmer_off

Tried to figure it out myself but i cant seem to. Thanks! Happy Holidays!

edit: input_boolean.toggle_helper_night_light_wohnzimmer stays on after it fires at 15:05. I guess it should turn off? At 14:50 it turned on.

Hi @Blacky ,

Let’s imagine that the lights are on (with a scene for example). Can you explain how to keep the lights on after the delay if the automation has triggered?

I suppose that I need to use a by-pass but I don’t know how.

Sorry, but I need someone that understands this blueprint to give me a hand.

I have a light and an IKEA motion sensor. Until now I have bind the motion sensor in Zigbee2MQTT to turn the light on/off when activated.

Now I want to use my outdoor illuminance sensor to adjust the brightness of this light. I want the light to be less bright when if gets darker outside. I also want to light not to be turned on at all when it is very bright outside.
I want the motion sensor to turn on the light as usual and be on for two minutes.
I started by unbinding the sensor from the light in Z2M, so it no longer controls the light, but allowing for this blueprint/automation to control the light.

I used the configuration wizard and this YAML is the result. However nothing happens. What have I done wrong?

alias: The brightness of the lamp
description: ""
use_blueprint:
  path: Blackshome/sensor-light.yaml
  input:
    motion_trigger:
      - binary_sensor.mymotionsensor_occupancy
    light_switch:
      entity_id: light.thelamp
    time_delay: 2
    include_dynamic_lighting: enable_lux_controled_brightness_inv
    dynamic_lighting_lux_sensor: sensor.outdoor_lightsensor
    dynamic_lighting_max_lux: 100
    dynamic_lighting_min_lux: 20
    dynamic_lighting_min_brightness: 5
    include_ambient: ambient_enabled
    ambient_light_sensor: sensor.outdoor_lightsensor
    ambient_light_value: 200
    ambient_light_high_value: 200

Hi! I have the problem described in the FAQ that the lights ignore the timer and turn off immediately after the motion sensor stops detecting motion if I use the ambient light condition. I added a toggle helper as described but it does nothing.

My setup: I have 2 motion detectors controlling several lights. The occupancy sensors from both detectors are grouped and the ambient light sensors are also grouped. The occupancy is used as trigger and the grouped ambient sensor as the ambient light condition (all are entities). The lights are also grouped (entity). I only use the normal light switching with the ambient condition, nothing else (no night lights, dynamic lighting or whatever). Why is the timer (“time delay”) ignored when the ambient light condition is used? How can I debug it?