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

@AndyPp

Hi Andy,

All you settings look good. One thing I would do is to group your trigger sensors and then just use the group as the trigger. There is a link in the blueprint in triggers that shows you how to do this.

If you see the light turn ON when sunset condition is met is because one of your triggers is ON at this time.

If you like to update the blueprint to version 8.2 just click the import blueprint button at the top of this post. All your automations will be okay you will just be on the latest version.

Blacky :grinning:

Hi again!

My chandelier with Sensor Light blueprint is working great for morning and daytime, @Blacky last suggestion allows it to turn on briefly at a high enough percent to start, and then immediately dims to barely visible which is what I want in the morning times.

My goal now is how to make the light much brighter in the evening even though the outside lux is still zero.

Question about Night Lights - I actually want a lux option but appears my choices are State, Time or Sun Elevation.

I’ve tried using sun elevation by setting the rising to -30 degrees and the setting to +50 degrees because my goal is set a minimum brightness on the light in the evening.

In other words, I want it to go from 3% brightness in the early morning when lux is zero, and then are some crossover point (say 4pm) I’d like it to remain at about 14% brightness until it turns off by schedule at 11pm.

Suggestions on how to accomplish this?

I suppose I could create two blueprints, but that’s no fun :wink:

alias: Sensor Light - Chandelier - Time Schedule w/Lux
description: ""
use_blueprint:
  path: Blackshome/sensor-light.yaml
  input:
    include_dynamic_lighting: enable_lux_controled_brightness_inv
    dynamic_lighting_max_brightness: 45
    dynamic_lighting_min_brightness: 3
    dynamic_lighting_sun_elevation_start_rising: -30
    dynamic_lighting_max_lux: 20000
    dynamic_lighting_min_lux: 0
    dynamic_lighting_lux_sensor: sensor.home_pws_solar_rad_lx
    light_switch:
      entity_id:
        - light.front_foyer_chandelier
        - script.script_to_reduce_foyer_chandelier_brightness_at_turn_on
    motion_trigger:
      - schedule.chandelier_light_schedule
    include_time: time_disabled
    after_time: "08:00:00"
    before_time: "19:00:00"
    dynamic_lighting_heartbeat: 2
    dynamic_lighting_dead_zone: 4
    boolean_scenes_scripts: input_boolean.foyer_chandelier_helper
    dynamic_lighting_boolean: input_boolean.foyer_chandelier_helper
    night_lights_sun_elevation_rising: -30
    night_lights_conditions:
      - sun_enabled
    night_lights:
      entity_id: light.front_foyer_chandelier
    include_night_light_control:
      - use_brightness
      - if_lights_are_on_adjust_when_crossing_over
    night_light_brightness: 14
    night_light_transition_on: 5
    night_light_transition_off: 15
    night_lights_sun_elevation: 50
    include_night_lights: night_lights_enabled


I wonder if you could help me understand how best to use the bypass options for my use case. The lights are working great automatically using the Sensor Light blueprint, but sometimes I want to override this.

For example, to turn them off if I’m going to watch a movie, which means they should stay off until I turn them back on again. Or, even better, they could reset if the trigger sensor (a group of motion/presence sensors) becomes clear and then activates again.

The physical switch I’d like to use is a Hue dimmer via zigbee2mqtt. At the moment it turns the lights off, but they usually turn themselves back on some time later which is not what I want. But as this is basically just a button, it doesn’t expose a “switch” in the Home Assistant sense with an on/off state, which is what the bypass option seems to need.

Any advice on this would be appreciated!

@Blacky
I am having trouble bypassing a sensor light automation with Lutron scenes. Do I need a Lutron bridge pro to be able to have the status of the scene? I have an Aqara FP2 sensor triggering the living room light and kitchen lights. When I use the ‘Relax’ scene on Lutron, I want to be able to bypass the automation so the living room lights don’t turn on. I notice Home Assistant isn’t able to recognize the status of the scene on Lutron. Does that mean I have to write the scene on Home Assistant?

Ohh ok i see, i thought it wouldnt let me because it went red there :sweat_smile:

1 Like

@Blacky ATM we have 3 option to allow the motion sensor to activate the light Sun Elevation, Ambient and Time.

would I be possible to add a Option for an input_boolean, as I use a Evening input boolean for my automations, If the evening entity is on then it allows all my evening automation work. This save me editing when they are allowed ie, sun elevation or time etc, allow over the place.

I then have 1 automation that controls this input_boolean

Have you looked at this blueprint :high_brightness: Smart Light.

If you use time as the trigger say ON at 6am and off at 11pm 3% brightness. Then use night lights from 4pm till 11pm at 14% brightness. If you would lux here you can use a template binary sensor that looks at a lux sensor to see if it is below X and then use that as the state condition… is lux sensor below X then ON

Blacky :grinning:

@botboy

Have you seen this blueprint :infinity: Sensor Light Add On. When you watch a move it will control all your light for you.

Failing this, use a toggle helper that is turned ON with your button. Use the toggle helper in the bypass option 2. You can set a bypass auto OFF in X amount of time.

Blacky :grinning:

@SparkJax

Scenes have no state in HA. They are just executed. So if you like add a toggle helper to the ‘Relax’ scene and when that scene turns ON it also turns ON the toggle helper. The thing is you need to make sure the toggle helper is turned OFF when you turn OFF the ‘Relax’ scene. You then use that toggle helper in the bypass of the living room lights.

Blacky :grinning:

@andyblac

Have you tried to invert the input_boolean with a template binary sensor and then use it in the bypass?

{{ is_state('input_boolean.example', 'off') }}

Blacky :grinning:

where do I put in in config, so I can stop using ambient_light_options , I already use the bypass, so the lights do not turn off when I’m in the kitchen. (i.e if someone is just stood around talking no movement)

alias: Kitchen Motion Light
description: ""
use_blueprint:
  path: Blackshome/sensor-light.yaml
  input:
    motion_trigger:
      - binary_sensor.kitchen_motion_sensor_occupancy
    time_delay: 1.5
    end_scenes:
      - scene.kitchen_motion_light_off
    include_night_lights: night_lights_disabled
    light_switch:
      entity_id: scene.kitchen_motion_light_on
    include_bypass:
      - bypass_enabled_turn_on
    motion_bypass_lights_on:
      - light.kitchen_lights
    ambient_light_sensor: sensor.kitchen_motion_sensor_illuminance
    ambient_light_options: ambient_light_option_enabled
    include_ambient: ambient_enabled
    ambient_light_value: 25
    ambient_light_high_value: 40

I am using 5 different types of zigbee switches (via zigbee2mqtt), from Xiaomi/Tuya/Ikea, neither of them has a state, these are push buttons and any Ikea sells them cheap. Shelly i4 is a wifi thing which requires external power (and if I have to walk to the switch instead of putting it on a desk in front of me - then I do not really need it) and more expensive than zigbee stuff.
But even with the hw switch, if the same device implements a switch and power control - such switch cannot be used for the blueprint (yeah, I know it is explained in faq).

Thanks! I have seen the add on, but I want to control it manually. Sometimes I’m watching more casually or in the background and want to keep the lights on, but if I want to watch something properly without distractions I want the lights off.

I will have to explore the toggle helper route. I guess the thing is, it would need to be kept up to date with the state of the lights. I still want the button to act as an on off switch, eg, as the lights are also using the ambient sensor, sometimes so want to turn them on when it hasn’t quite triggered yet.

Basically, what I want to achieve is that the lights turn on and off automatically based on the sensors, but if I turn them off OR on manually in contrast to what the sensors are suggesting, that should stick until the state changes again. But seems like I might have to go with the time delay for now!

This is what I’m referring to:

You mentioned turning the Evening input boolean ON, but I’m not sure why you’re turning it ON instead of OFF… and that choice matters. The reason is that when the Evening input boolean is ON and you’re using it in a bypass, it will disable the automation. On the other hand, if you turn it OFF when you want the automation to run, it will just work without needing any special handling.

You have a few options:

  1. Adjust your automation to turn the Evening boolean OFF when you want the sensor light automation to be enabled.

    This is the simplest approach, but it may not look as intuitive in the UI.

If you’re turning it ON for visual clarity in the UI (so it shows that it’s evening), but still want the automation to run, you have two more options:

  1. Create a second input boolean that is OFF when it’s evening.
    Use this one in the bypass, while keeping the original Evening boolean ON for clarity in the UI.
  2. Create a template binary sensor that inverts the Evening boolean.
    You can then use this sensor in the bypass condition, so even when the Evening boolean is ON, the bypass behaves as if it’s OFF. Then use it in bypass option 2.

How to Create a Template Binary Sensor Helper.

  1. Go to Settings > Devices & Services > Helpers.
  2. Click “+ Create Helper” and choose Template > Template a binary sensor.
  3. Set a Name for your new binary sensor.
  4. In the State template field, paste the code below.
    Replace input_boolean.your_entity_here with the actual entity ID of your Evening boolean.
  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.
{{ is_state('input_boolean.your_entity_here', 'off') }}

I now see that you have another bypass that turns the lights ON, and it’s a light you might also be using in a scene. This isn’t really how the automation was originally designed to work.

Blacky :grinning:

Yeah, I get what you’re saying, but I’m not sure what you’re using as the button, and not every button works the same way. I was just trying to point you toward checking whether your button has an option to act like a switch, similar to how Shelly devices do it: Press = ON, press again = OFF.

If it doesn’t have that kind of toggle mode, you can still make it work by having the button toggle a toggle helper instead.

So each button press would flip the state of the toggle helper, just like if you were using the button to control a light directly (turn ON/OFF).

If you’re not sure how to do that with your specific device, maybe try asking on the forum something like:

“How do I get the IKEA button model XXX to toggle a toggle helper?”

That way, someone familiar with that device can help you set it up properly.

Blacky :grinning:

Hi There,

Firstly thankyou for such a cool blueprint!

In this application I am using it for night lights. I have a string of RGB (not RGBW, important later) under the bed connected to a SHELLY RGB.

Triggers are:
Under bed sensor, by elevated sensors (the problem ish)
an everything presence sensor – PIR (not the MMwave, the PIR is to sensitive)

As it stands now the blueprint is set up with the PIR of the EPS to trigger the blueprint in a time window 1030pm to 6am and it works, with 2 reasonable issues.

Problems.
1: the RGB is just showing white.
(remember, its just an RGB strip.)
I have selected the entities for the Shelly RGB, chosen the colour and all it does is show white. i checked the YAML. as you will see below, it has the section to use the RGB section, and was not working. So i deleted the entries in your blueprint and you will see the updated code below.
I have to go out and i will test that code when i get back after 1030pm

Problem 2:
the second problem is that the PIR is way to sensitive, and as best as i can tell, i cant tune it. (i will send an email asking if there is a way) so reading your instructions I saw the section of grouping, and this would help with the advance version of this. I get up from the LHS and the light go green, the partner gets up from the RHS and the lights go PINK.
So I created a group with
PIR (default state off)
bed presence (default state off)

The problem is that they are both TRIGGERED, so when I lie on the bed it goes to ON and the PIR is triggered by movement, so I need a way to invert say the bed sensor so that when I am lying on it, it is off and when I get off its on so that the conditions of the dual sensors are meet. I need some sort of invert toggle of the bed for just the use of blueprint.

IE
there is movement – check
there is someone in bed – don’t turn on the light
or
there is movement – check
someone just got out of bed – check
Turn on the night light.

Clearly this is simplified example as the bed sensor has two sides to make it take notice of both sides and I would need to do a lot more programming to get this to work.

I will report back with the new code slice after 1030 when I get home.

And again thanks for the great blueprint!

-=-=-= Original code -=-=-=-=-
alias: Night Lights - Automation
description: ""
use_blueprint:
  path: Blackshome/sensor-light.yaml
  input:
    motion_trigger:
      - binary_sensor.everything_presence_one_a8c724_pir
    light_switch:
      entity_id:
        - light.shellyrgbw2_a7dd58_channel_1
        - light.shellyrgbw2_a7dd58_channel_2
        - light.shellyrgbw2_a7dd58_channel_3
    include_light_control:
      - use_brightness
    light_brightness: 1
    include_light_colour_control: use_rgb_colour
    light_rgb_colour:
      - 0
      - 6
      - 97
    include_time: time_enabled
    after_time: "22:30:00"
    before_time: "06:00:00"
    time_delay: 1
    light_rgbw_colour:
      - 0
      - 107
      - 7
      - 0
    light_colour_temperature: 2500

-=-=-=- Modified code to test -=-=-=-
alias: Night Lights - Automation
description: ""
use_blueprint:
  path: Blackshome/sensor-light.yaml
  input:
    motion_trigger:
      - binary_sensor.everything_presence_one_a8c724_pir
    light_switch:
      entity_id:
        - light.shellyrgbw2_a7dd58_channel_1
        - light.shellyrgbw2_a7dd58_channel_2
        - light.shellyrgbw2_a7dd58_channel_3
    include_light_control:
      - use_brightness
    light_brightness: 1
    include_light_colour_control: use_rgb_colour
    light_rgb_colour:
      - 0
      - 6
      - 97
    include_time: time_enabled
    after_time: "22:30:00"
    before_time: "06:00:00"
    time_delay: 1
    light_rgbw_colour: {}
    light_colour_temperature: 2500
    light_rgbww_colour: {}

@fjhendo

Your light looks wrong. You have channel 1, 2 & 3. You just need the light entity (one entity only).

Create a Template Binary Sensor Helper

How to Create a Template Binary Sensor Helper.

  1. Go to Settings > Devices & Services > Helpers.
  2. Click “+ Create Helper” and choose Template > Template a binary sensor.
  3. Set a Name for your new binary sensor.
  4. In the State template field, paste the code below.
    Replace input_boolean.your_bed_sensor_here with the actual entity ID of your bed sensor
  5. Set the Device class if you want this binary sensor to behave like a motion sensor, etc.
  6. Optionally, select a Device to link this sensor to (bed sensor). Leave it blank if not needed.
{{ is_state('input_boolean.your_bed_sensor_here', 'off') }}

Blacky :grinning:

ok, now that is strange. the devices only list the channels 1,2,3 &4

but the shelly integration, lists the light as a single interface and i cant find that any where.

I have created helper, via your post, but this one is different, let me see if i can recreate that helper here

OK,
so i have created that input helper and combined those using another helper.

Now the helper that your blueprint uses, shows as detected. Even thought the PIR is showing “clear” (not ‘OFF’) so i was thinking that the combined helper was going to be a AND. so the bed sensor AND the PIR had to be detected, (ie me get up out of bed) but its not.
I wonder if the word “Clear” is the problem, as its not “OFF”