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

@syrys

Yes, the best way to do this it to group your PIR/MMW sensor and then use the group only as the trigger. It then will work perfectly for you.

For more information on grouping your trigger sensors Click Here

Blacky :smiley:

@Vorhand

All your YAML looks good.

Lets look at your suggestion to see if it works as you could be on the right track.

This is the new code that will look at the distinction between rising and falling.

{{ (((is_state_attr('sun.sun', 'rising', false)) 
   and (state_attr('sun.sun', 'elevation') < -1.0)) 
   and now().hour < 21) 
   or ((now().hour >= 7 
   and (is_state_attr('sun.sun', 'rising', true)) 
   and (state_attr('sun.sun', 'elevation') < -3.0))) }}

Blacky :smiley:

hi, i need more lux ! :slight_smile: mein sensor detect on daylight 3000 and more. your blueprint ends at 500 and 1000 :frowning:

Pls try again, the link had a wrong expiration, now I fixed it

Ok now I discovered the same problem appears even with tv lights addon, but not only for led scrivania, but all lights

It only seems to be a problem when they’re used at the same time: if no presence is detected after the TV shuts off, the add-on turns the light on, and then the sensor immediately turns it off again, causing a mess.

For some strange reason, the blueprint stops working in v7.9. I have door sensor and Motion sensor grouped together which worked okay, but now I see this under traces:

Stopped because a condition failed at 4 February 2025 at 20:37:02 (runtime: 0.02 seconds)

Tracelog attached

If I manually Run it, it works fine.

Hey there! Love the template, I’ve got a question though about toggle helpers.

I use a scene to turn the lights on, off and a different scene to turn them on at night with the night light feature.

Am I supposed to use the same Toggle Helper in both the Lights-section “Scenes & Scripts - Toggle Helper” and the Night Lights-section “Night Lights - Scenes & Scripts - Toggle Helper”? Or should I use two independent ones?

For clarification, I also have the Bypass Option “3 - Enable the Bypass - Keep the lights current state” enabled together with the “Enable the auto OFF for the bypass switch - Keep The Lights Current State” option. For that I have a seperate input_boolean configured.

I’m having some issues either way.

Case 1: I use one shared Toggle Helper for both the Lights and Night Lights sections:
In that case, after turning OFF the Bypass, my lights also turn OFF (OFF scene is being triggered), even though the motion sensor is ON, and thus my OFF-scene should not be triggered.

Case 2: I use two seperate Toggle Helpers “TH-Day” and “TH-Night” for Lights and Night Lights sections:
In this case, the issue from Case 1 does not happen, the lights stay ON when I turn OFF the Bypass as long as the motion sensor is ON.
What I do have an issue with is the time when it goes past “Night Lights - Start Time” while the normal lights (as in my “daytime”-scene) and thus also TH-Day are currently turned ON.
In the case that my normal lights are turned ON (Toggle Helper TH-Day for normal lights is also ON) & the time shifts into the Night Lights phase & then my lights are turned OFF by the automation (no more motion occupancy), what will happen is: The lights turn OFF (off-scene being triggered), but TH-Day will stay ON, causing the automation to break and not toggle the Night Lights on by motion anymore afterwards. At this point I have to manually turn OFF TH-Day.

Is there anything in my setup wrong, or am I missing something?

Latest Config I’m using:

alias: Motion - Automate Bathroom Lights
description: ""
use_blueprint:
  path: Blackshome/sensor-light.yaml
  input:
    motion_trigger:
      - binary_sensor.bathroom_motion_occupancy
    light_switch:
      entity_id: scene.bathroom_shower
    time_delay: 1
    include_light_control: []
    include_light_colour_control: use_colour_temperature
    light_colour_temperature: 2000
    include_night_lights: night_lights_enabled
    night_lights_conditions:
      - time_enabled
    include_bypass:
      - bypass_enabled_stop
    motion_bypass_lights_stop:
      - input_boolean.bathroom_presence_motion_bypass
    night_lights_after_time: "23:00:00"
    night_lights_before_time: "07:00:00"
    night_lights:
      entity_id: scene.bathroom_night
    night_time_delay: 1
    include_night_light_control: []
    night_light_brightness: 2
    night_light_colour_temperature: 2000
    night_light_transition_on: 1
    include_bypass_auto_off:
      - bypass_auto_off_enabled_stop
    boolean_scenes_scripts: input_boolean.bathroom_toggle_helper
    end_scenes:
      - scene.bathroom_off
      - script.bathroom_toggle_helper_off_fix
    night_boolean_scenes_scripts: input_boolean.bathroom_night_toggle_helper
    bypass_auto_off_delay: 45

Thank you in advance!

EDIT: I’m still running Version 7.8, can test it again with 7.9, but it seems it only includes fixes for Night Glow, if I see it right.
EDIT2: Issue persists with Version 7.9.
EDIT3: As a workaround I now added a script to “Lights: Scenes - Scripts To Turn OFF”, that just turns off both my Toggle Helpers TH-Day and TH-Night, which seems to fix the issue. So it seems the Toggle Helpers should just be turned OFF by the automation when changing over from day time to night time?
EDIT4: Added config inclding the workaround from EDIT3.

@ric.roe

Just type the number in you would like and click save.

Blacky :smiley:

@PilaScat

It’s hard to follow what’s happening because there are many scenes, and I have no idea what each scene contains.

TIP: When to Use Scenes

Only use a scene if you have a set of lights with different brightness levels or colors. For example:

  • Light A = 100% brightness, white light
  • Light B = 50% brightness, white light
  • Light C = 25% brightness, green
  • Light D = 100% brightness, blue

If all your lights have the same brightness and colour, it’s better to control them directly using entities and the light control options.

Issues with the Add-on Blueprint

  • Your add-on blueprint turns on multiple lights at the end, but since it uses a snapshot, the result can be different each time.
  • If you’re using this with a sensor light blueprint, try letting the sensor light blueprint handle turning lights ON or OFF at the end.
  • In your sensor light blueprint, the Bypass - Time Delay is currently set to 0, meaning lights might turn on and then immediately off.
    • To keep the lights ON, try setting this delay to 1 minute (or another desired duration).
    • If you want a specific light to turn ON at the end but it’s not part of the sensor light blueprint, add it separately.

Start Simple, Then Build

Begin by setting things up with just entities:

  • Only include end lights that aren’t part of the sensor light blueprint. Then, add them one by one to observe the behavior.
  • Pay attention to the Bypass - Time Delay setting… adjust it to see how it affects the timing of lights turning on and off.
  • Avoid using a snapshot to prevent unpredictable behavior.
  • Keep it simple at first, then gradually build complexity as needed.

Blacky :smiley:

1 Like

Thanks I’ll try

@iona

This looks to be the start of night lights with no light ON so it stopped it as it should.

Blacky :smiley:

@Atry

You need 2 independent helpers that are only used in the automation.

Good that is correct.

You need independent helpers

I have tested it and I can see the bug. I will fix this and a update will be out soon. Also note if you use If lights are ON, adjust the lights when crossing over in the Night Light Control it will toggle the helpers and adjust your lights. The bug fix will only toggle the helpers and wont adjust your lights.

Thanks for testing it out and reporting the bug in detail as this helps me find it.

Blacky :smiley:

1 Like

New update 8.0

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

:bug: Bug Fixes

Bypass - Motion trigger is off and check if any by-passes are on, fix sequence back to version 7.8

Crossing Over - When using scenes toggle helpers will change over when lights are ON.

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:

3 Likes

@Blacky Hoping you can help, I’m trying to setup with a bypass option, I want the sensor light to activate on motion etc, but when bypass is ON for the light NOT to turn off. but atm the motion trigger is not turning on the light what have I done wrong.

the bypass toggle was off at time of automation activate

alias: Hall Motion
description: Turn on Hall Lights
use_blueprint:
  path: Blackshome/sensor-light.yaml
  input:
    motion_trigger:
      - binary_sensor.hall_motion_sensor_occupancy
    include_light_control: use_brightness
    include_sun: sun_enabled
    time_delay: 0.5
    end_scenes: []
    include_night_lights: night_lights_disabled
    light_brightness: 5
    light_switch:
      entity_id:
        - light.hall_lights
    sun_elevation: -1.5
    include_bypass:
      - bypass_enabled_stop
    motion_bypass_lights_stop:
      - automation.hall_lights_bypass_toggle

AUTOMATION LOG

condition: or
conditions:
  - '{{ include_bypass == [] }}'
  - condition: and
    conditions:
      - >-
        {{ ('bypass_enabled_turn_on' in include_bypass) and
        ('bypass_enabled_turn_off' in include_bypass) and ('bypass_enabled_stop'
        in include_bypass) }}
      - condition: state
        entity_id: []
        state: 'off'
      - condition: state
        entity_id: []
        state: 'off'
      - condition: state
        entity_id:
          - automation.hall_lights_bypass_toggle
        state: 'off'
  - condition: and
    conditions:
      - >-
        {{ ('bypass_enabled_turn_on' in include_bypass) and
        ('bypass_enabled_turn_off' in include_bypass) and ('bypass_enabled_stop'
        not in include_bypass) }}
      - condition: state
        entity_id: []
        state: 'off'
      - condition: state
        entity_id: []
        state: 'off'
  - condition: and
    conditions:
      - >-
        {{ ('bypass_enabled_turn_on' in include_bypass) and
        ('bypass_enabled_turn_off' not in include_bypass) and
        ('bypass_enabled_stop' in include_bypass) }}
      - condition: state
        entity_id: []
        state: 'off'
      - condition: state
        entity_id:
          - automation.hall_lights_bypass_toggle
        state: 'off'
  - condition: and
    conditions:
      - >-
        {{ ('bypass_enabled_turn_on' not in include_bypass) and
        ('bypass_enabled_turn_off' in include_bypass) and ('bypass_enabled_stop'
        in include_bypass) }}
      - condition: state
        entity_id: []
        state: 'off'
      - condition: state
        entity_id:
          - automation.hall_lights_bypass_toggle
        state: 'off'
  - condition: and
    conditions:
      - >-
        {{ ('bypass_enabled_turn_on' in include_bypass) and
        ('bypass_enabled_turn_off' not in include_bypass) and
        ('bypass_enabled_stop' not in include_bypass) }}
      - condition: state
        entity_id: []
        state: 'off'
  - condition: and
    conditions:
      - >-
        {{ ('bypass_enabled_turn_on' not in include_bypass) and
        ('bypass_enabled_turn_off' in include_bypass) and ('bypass_enabled_stop'
        not in include_bypass) }}
      - condition: state
        entity_id: []
        state: 'off'
  - condition: and
    conditions:
      - >-
        {{ ('bypass_enabled_turn_on' not in include_bypass) and
        ('bypass_enabled_turn_off' not in include_bypass) and
        ('bypass_enabled_stop' in include_bypass) }}
      - condition: state
        entity_id:
          - automation.hall_lights_bypass_toggle
        state: 'off'
  - condition: trigger
    id:
      - t7_on
      - t7_off
      - t7_stop
      - t8_on
      - t8_off
      - t8_stop
      - t17

EDIT:

forget it it was me, I was using the automation to control the bypass and not the actual bypass input boolean in the blue print.

    motion_bypass_lights_stop:
      - automation.hall_lights_bypass_toggle
1 Like

@DariusM73

Now I understand what you’re trying to do. We’re going to flip the logic a bit, so don’t worry too much about the terms Lights and Night Lights… just focus on the setup.

Step 1: Create a Template Binary Sensor

Before we begin, ensure your device tracker is already set up. Now, follow these steps to create a Template Binary Sensor to track when no one is home:

  1. Go to Settings > Devices & Services > Helpers (top tab).
  2. Click Create Helper.
  3. Select Template, then choose Template Binary Sensor.
  4. Provide a Name and select a Device Class (optional).
  5. (Optional) Link this sensor to an existing device for better organization.
  6. In the State template field, enter one of the following codes:

State Templates
You will have to choose the one that suits you the best.

  • All devices away
{{ states.device_tracker | selectattr('state', 'eq', 'home') | list | count == 0 }}
  • All persons away
{{ state_attr('zone.home', 'persons') | list | length == 0 }}
  • All specified persons away
{{ state_attr('zone.home', 'persons') | list | select('in', ['person.one_here', 'person.two_here']) | list | count == 0 }}

Step 2: Configure the Sensor Light Blueprint

Once your binary sensor is created, use these settings in your Sensor Light Blueprint:

  1. Trigger: Your motion sensor.
  2. Lights: Add your lights, set a delay, and under Light Control, set brightness to 5%, then choose a transition and colour (for sleep mode).
  3. Bypass: Enable option 2 and enter in your Template Binary Sensor for tracking if your home or not.
  4. Ambient Light: Enable and configure to your preference but make sure NO - My Ambient Light Sensor is not affected by the Lights is selected.
  5. Night Lights Settings: Enable it, use the State Condition and enter your sleep helper (Note: Sleep helper must be OFF when sleeping, ON when awake).
  6. Night Lights Add your lights and set a 2 minute delay.
  7. Night Light Control, set brightness to 100% and choose a colour. make sure you also Enable “If lights are ON, adjust when crossing over.”
  8. Glow Lights: Enable it and configure them, set brightness to 10% and choose a colour. (This is for when you arrive home)

In the morning and evening, the light colour will remain the same, but Dynamic Lighting (colour temperature adjustment) will handle that.

For now, set this up and test it… I haven’t run it myself… all in my head, but this is the general approach. Once it’s working, you can explore Dynamic Lighting further.

Let us know how you go.

Blacky :smiley:

Thanks so far, I will try it out and feedback what happens;)

I have a bathroom light controlled by a PIR sensor. I use a time delay to keep the light on. Is it possible to reset the time delay if the light is manually turned off? E.g user 1 turns off light while exiting bathroom. User 2 enters and lights stay off until time delay finishes and pir signals motion. I’d like for user 2 to have lights on immediately when pir senses motion