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

@Bleialf

Normally this is done in your sensor (reduce the false positives). The blueprint keeps being triggered so it may cause problems.

You could create a simple automation that turns ON a toggle helper if your theory is correct. You can then use this helper in Bypass Option 2 to turn the light OFF. Set Bypass Auto OFF to 1 second (0.016) so the toggle helper automatically turns OFF, allowing the blueprint automation to become active again and wait for the next trigger.

Blacky :grinning:

Thanks I’ll give that a try!

1 Like

@Sn0rrii

This looks a bit tricky and you will need to test it because your MR16 hue lights are OFF so HA can see them until they are ON. The order of the blueprint is lights first then switches (not switches then lights) and this is milliseconds apart but that may matter.

I am assuming you would like and have the Shelly mini to keep power OFF to your MR16 hue lights.

Option to try in this order are;

  1. Add your MR16 hue lights into Lights with your Shelly mini and in Light Control enable brightness and set it to 20%.

If that works :partying_face: if not then:

  1. Create a scene with your lights at 20% and your Shelly mini ON. Use the scene in Lights - Switches - Scenes - Scripts You then need to add a toggle helper into Scenes & Scripts - Toggle Helper and then create another scene with all your lights OFF and your Shelly mini OFF then add that scene into Scenes - Scripts To Turn OFF

If that works :partying_face: if not then:

  1. Turn your Shelly mini ON and leave it ON… Then just control you MR16 hue lights in the blueprint adding them to Lights and in Light Control enable brightness and set it to 20%

Blacky :grinning:

@FaviousM

Welcome to the community.

Currently no, if you set the time to 10pm it will turn the lights OFF because that is what we are asking it to do.

BUT!

This is going to get a but advance in templates. We need to create code using the entity ID of the template we just created in the code, so once you save the template then you have to get the entity ID and edit the template again. This will do what your asking but it is all at the trigger level.

  1. Go to Settings > Devices & Services > Helpers.

  2. Click “+ Create Helper” and choose Template > Binary sensor.

  3. Set a Name for your new binary sensor. This will create the entity ID we will use later in the code below once you saved the template.

  4. In the State template field, paste the code below.

    Replace:

    • binary_sensor.your_presence_sensor_here with the actual entity ID of your presence sensor.
    • I have set the start and end times to 9am to 10pm but if you need to change them then this is where you will do it… not in the blueprint time section. Disable the time section in the blueprint now.
    • The tricky part. Save the template sensor and then replace binary_sensor.this_binary_sensor_ID with this binary sensor ID.
  5. Set the Device class if you want this binary sensor to behave like a motion sensor, opening sensor, etc.

  6. Optionally, select a Device to link this sensor to. Leave it blank if not needed.

{% set motion = is_state('binary_sensor.your_presence_sensor_here', 'on') %}
{% set start = now().replace(hour=9, minute=0, second=0) %}
{% set end   = now().replace(hour=22, minute=0, second=0) %}
{% set allowed = start <= now() <= end %}
{% set prev = states('binary_sensor.this_binary_sensor_ID') %}

{{ (motion and allowed) or (prev == 'on' and motion) }}

Once you created this template binary sensor you then use it as the trigger ONLY (not your presence sensor).

Let us know how you go.

Blacky :grinning:

1 Like

Hey guys, I am wondering if I do not get it or if it works as intended. I have the sensor light blueprint set up with bypass option 3. My bypass switches are “input_boolean.woz_manual_control” for temporary blocking the automation in case my wife uses the light switch, “inbut_boolean.woz_bewegung_blocker” for permanent blocking the automation in case of guests in the room for overnight stay or a nap :smiley: , and another one for cleaning mode. When I switch of the manual mode input boolean with my switch (switch off the lights deactivates also the manual mode), then the lights switch on. Is this intentionally? Yes, I am in the room while doing this and the occupancy sensor is still detecting me. I was hoping the automation gets triggered only when the trigger is changing from clear to detected (or off to on).

Thanks
Niko

@Blacky - I have about 100 motion sensors throughout my home for lighting control (and other purposes). I would prefer not creating 100 binary sensors (one for each motion sensor). Any chance your blueprint could be altered to handle my wired motion sensors. I did confirm that their two states are either “violated” or “normal”.

Anyone having an issue with the Light sensor template not working anymore?

My issue is that the light won’t turn on/off when the human sensor changes. It was working fine before. I’ve checked the devices and all are working fine.

’
alias: Light 1F - light sensor
description: “”
use_blueprint:
path: Blackshome/sensor-light.yaml
input:
motion_trigger:
- binary_sensor.human_mmwave_occupancy
light_switch:
entity_id: light.1f_light
boolean_scenes_scripts: input_boolean.light_1f_scenes_scripts_toggle_helper
end_scenes:
- scene.light_1f_off
time_delay: 0
include_light_control:
light_brightness: 30
include_light_colour_control: use_colour_temperature
light_colour_temperature: 4300
include_dynamic_lighting: enable_sun_elevation_colour_lux_brightness
dynamic_lighting_lux_sensor: sensor.scaled_lux
dynamic_lighting_max_lux: 120
dynamic_lighting_min_lux: 10
dynamic_lighting_min_brightness: 4
dynamic_lighting_boolean: input_boolean.light_1f_dynamic_lighting_toggle_helper
dynamic_lighting_min_colour_temp: 4000
dynamic_lighting_max_colour_temp: 5000
dynamic_lighting_heartbeat: 0.25
dynamic_lighting_state_control_activation_state: “off”
include_sun: sun_enabled
’

Thanks a lot i’ll try 2.

1 Like

This blueprint is awesome, thank you so much for your work! @Blacky
I have been using it for quite a while now to turn on the lights with a motion sensor depending on the sun option.
Recently I wanted to add the night light function and turn on the same lights but with a lower brightness during the night (using time option).
Actually it’s working as intended but the lights now turn on without the motion sensor triggering exactly at the start and end time I set for the night light option.
I have not observed this behavior in another room where I use a different light entity as night light.
Is there anything I’m missing?

@Blacky

Also from my side thanks for this awesome blueprint! One issue I’m running into which I cannot solve. I only want to have the lights switched on during night time when motion is detected.

I’ve set the Night LIghts configuration as per screenshot below.

The main lights configuration is left empty:

But the automation is never triggered! Only with a light has been added to the “Lights” config then the automation is triggered. What am I doing wrong in the config and/or how to solve this?

My goal is to only have the lights on when my helper “NightTime” is true and motion is detected. Thamnks.

I have an issue that seems to have appeared only with the 8.5 release - wondering if anyone else has experienced this and if it’s a bug. I have enabled the ‘dim before off’ option and what I’m seeing if that when the lights are on, and motion is detected, the automation is changing the brightness to 100% - event though that is not the current brightness. I think what is happening is this:

  • Motion detected - lights are turned at defined brightness e.g. 80%
  • Within the lights-off timeout period (e.g. 10 minutes), motion is detected again.
  • Since ‘dim before off’ is enabled, the automation tries to calculate the correct brightness to set - is seems to assume we are in the dimmed phase, to it tries to restore the brightness level.
  • In my case I have the ‘dim before off’ percentage set to 50%, so it tries to restore the brightness level by calculating 80% / 0.5, which is above 100%, so it rounds to 100%.

I think the logic should check that when ‘dim before off’ is enabled, that we are actually in dimmed phase before trying to restore the brightness level.

Looking deeper at the options, it was user error. I didn’t have Dynamic Lighting - State Control Options configured.

After setting that to only trigger when the light is in an off state it appears to be working as I hoped.

Thank you for your work on this!

1 Like

If I run this manually, it bypasses sun sensor and times? In fact I think I am losing my mind. All I want to do is user a helper to show I am away from the house and turn on a light and then after so long being home turn it off. How can I best accomplish this? I’m struggling with my tests.

If you run any automation manually (the run command in the automation UI using ‘run’) then none of the triggers are used because you are triggering it manually.
Is that what you mean?

1 Like

Yes. I am looking for a way to test this. I am thinking I need to link it to the [high_brightness Smart Light - Entity - Sun Elevation - Ambient & Time Triggers]

Use Open your Home Assistant instance and show your state developer tools. to temporarily force a sensor to one of the available states to trigger things is my suggestion for testing.

1 Like

Thanks. That makes sense.

Now if I can figure out how to link this blueprint with the Smart Light blueprint.

1 Like

I have this configured to turn on the lights in a room at 100% during the day, and in the late hours of the morning it will only turn on at 10% (night light) with a 1% night glow.

After the sun goes down and before the night lights are active, I would like to turn the lights on at 75% with a similar effect as the night glow (1% or slightly more).

Since the dynamic lighting does not work with night lights, am I correct in understanding this is not possible?

Hello! Thanks for this awesome blueprint!
I have a problem with my Nanoleaf bulbs.
I can’t get the transition effect to work properly.

I’ve set 2 seconds in the device settings, and it works greatly manually, but with the automation it just flashes on/off, no matter whether I use transition option of the blueprint.

Here’s the Yaml:

alias: Main bathroom light automation
description: ""
use_blueprint:
  path: Blackshome/sensor-light.yaml
  input:
    motion_trigger:
      - binary_sensor.main_bathroom_presence_sensor_occupancy
    light_switch:
      entity_id:
        - light.main_bathroom_light_bulb
    time_delay: 0.5
    include_light_control:
      - use_brightness
      - use_transition
    include_light_colour_control: use_colour_temperature
    light_colour_temperature: 3300
    include_dynamic_lighting: enable_lux_controled_brightness
    dynamic_lighting_lux_sensor: sensor.main_bathroom_presence_sensor_illuminance
    include_device_tracker: device_tracker_disabled
    people: []
    include_night_lights: night_lights_enabled
    night_lights_conditions:
      - entity_state_enabled
    night_lights_entity_state:
      - input_boolean.night_mode
    night_lights:
      entity_id: light.main_bathroom_light_bulb
    night_time_delay: 2
    include_night_light_control:
      - use_brightness
      - use_transition
      - if_lights_are_on_adjust_when_crossing_over
    night_light_brightness: 50
    include_night_light_colour_control: use_colour_temperature
    night_light_colour_temperature: 3300
    include_night_glow: night_glow_disabled
    include_night_glow_light_control:
      - use_brightness
      - use_transition
    light_brightness: 100
    light_transition_off: 5
    dynamic_lighting_max_lux: 400
    dynamic_lighting_min_lux: 80
    dynamic_lighting_dead_zone: 0
    dynamic_lighting_step_value: 1
    ambient_light_sensor: sensor.main_bathroom_presence_sensor_illuminance
    night_glow_lights:
      entity_id: light.main_bathroom_light_bulb
    ambient_light_options: ambient_light_option_enabled
    light_transition_on: 2
    include_bypass:
      - bypass_enabled_stop
    motion_bypass_lights_stop:
      - input_boolean.main_bathroom_light_bypass
    bypass_auto_off_delay: 15
    include_bypass_auto_off:
      - bypass_auto_off_enabled_stop
    dynamic_lighting_min_brightness: 1

Love the Blueprint. I’m using it in a bunch of rooms and it feels like magic. :+1:

Two questions. First, I recently cleaned out some Helpers that I thought weren’t being used and I didn’t recognize, but I am now seeing a red error message “Unknown Entity Detected” message in the “Scenes & Scripts - Toggle Helper,” even though I am not using a Scene or Script here. I’ve tried reimporting the Blueprint, but am not sure if I messed something up and need to recreate a default helper (or if it can be reinstalled somehow), or if everyone is seeing this error message and it can be ignored.

Second, @Blacky I saw a story recently about the different Modes in automations, and in my case, would prefer Restart vs. Single mode for my light automations, that way detecting motion would restart the clock rather than adding it to an ongoing timer. Is that how your Blueprint works, or is that a config setting I’m missing, or is that not an option for Blueprints like this? Just curious as I have noticed some lights seem to go off faster than my timer but only after I leave and re-enter the room a few times.