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

@DarkFeniXZp

Welcome to the community.

If your using the second switch for the bypass, when you turn it OFF (turn OFF the bypass) if the presence sensor has detected motion it will turn ON the first switch as this is what we are asking the automation to do. Once motion is not detected then it will turn OFF your first switch.

Blacky :smiley:

i am not using a motion sensor. my trigger is a helper which switches on in the morning and off at night. the lights are there for apearing someone is home. even when away. but they dont need to work during the day when nobody is home.

Hello Blacky, you have built an awesome automation here🙏 I have only been using HA for four weeks but I am already using it in a few rooms. But in the living room it doesn’t work as intended. I have already experimented a lot and looked for the error, but I still don’t have the know-how here. Maybe you can tell me what my problem is?

I have the following requirement: PC lamp should support the brightness in the living room from 9am to 11am. When it is darker it should shine more cold white and when there is less lux it should get warm and reduce the brightness to the point where it goes off (lux settings exceeded). Then from 7am it should automatically switch to a fixed night lighting without regulation. At 11am the lamp should then go out completely. I have currently chosen a long delay time so that the lamp does not always go out, as there is currently a motion detector. A presence detector is to be added later. Here is the current yaml for it. It will probably be completely wrong now because I have been trying too many things🙈

alias: Automation PC Lampe
description: “”
use_blueprint:
path: Blackshome/sensor-light.yaml
input:
motion_trigger:
- binary_sensor.wohnzimmer_bewegungsmelder_occupancy
light_switch:
entity_id: light.lampepc
time_delay: 30
include_light_control:
- use_brightness
include_light_colour_control: use_colour_temperature
light_colour_temperature: 4300
light_rgb_colour:
- 255
- 255
- 255
include_dynamic_lighting: enable_lux_controled_brightness
dynamic_lighting_lux_sensor: sensor.wohnzimmer_bewegungsmelder_illuminance_lux
dynamic_lighting_max_lux: 110
dynamic_lighting_min_lux: 10
dynamic_lighting_max_colour_temp: 4300
dynamic_lighting_min_colour_temp: 2200
dynamic_lighting_heartbeat: 0.25
dynamic_lighting_step_value: 100
dynamic_lighting_dead_zone: 0
include_ambient: ambient_enabled
ambient_light_sensor: sensor.wohnzimmer_bewegungsmelder_illuminance_lux
ambient_light_value: 10
ambient_light_high_value: 110
zone: zone.home
people:
- person.chris
- person.rina
include_time: time_enabled
night_lights_conditions:
- time_enabled
- entity_state_enabled
include_night_lights: night_lights_enabled
night_lights_entity_state:
- schedule.helfer_zeitplan_nightlights_pclampe
night_time_delay: 140
night_lights:
entity_id: light.lampepc
night_light_brightness: 1
include_night_light_control:
- use_brightness
include_night_light_colour_control: use_colour_temperature
night_light_colour_temperature: 2000
night_lights_after_time: “19:00:00”
light_brightness: 100
dynamic_lighting_max_brightness: 100
after_time: “09:00:00”
before_time: “23:00:00”
include_device_tracker: zone_people_enabled
dynamic_lighting_min_brightness: 0
night_lights_before_time: “23:00:00”
ambient_light_options: ambient_light_option_disabled
night_light_rgb_colour:
- 255
- 201
- 147
dynamic_lighting_boolean: input_boolean.helfer_pc_lampe

Hi @Blacky Thank you for yet another great blueprint. I just can not seem to figure out why my lights won’t turn off when it is light enough. I have checked the value of the ambient light sensor used and its well above it.

alias: woonkamer test 3
description: ""
use_blueprint:
  path: Blackshome/sensor-light.yaml
  input:
    night_boolean_scenes_scripts: input_boolean.nightlight
    motion_trigger:
      - binary_sensor.presence_detected
    light_switch:
      entity_id: scene.woonkamer_relax_2
    boolean_scenes_scripts: input_boolean.toggle_lights
    end_scenes:
      - scene.lampen_beneden_uit
    include_ambient: ambient_enabled
    ambient_light_sensor: sensor.fp2_woonkamer_light_sensor_light_level
    include_night_lights: night_lights_disabled
    night_lights_conditions:
      - entity_state_enabled
    night_lights_entity_state:
      - sensor.robin_telefoon_do_not_disturb_sensor
      - binary_sensor.nightlight_presense
    night_lights:
      entity_id: scene.nacht
    ambient_light_options: ambient_light_option_enabled
    include_light_control: []
    include_device_tracker: zone_enabled
    zone: zone.home
    ambient_light_value: 15
    ambient_light_high_value: 45
    time_delay: 4
    dynamic_lighting_min_lux: 20
    dynamic_lighting_lux_sensor: sensor.aqara_fp2_woonkamer_light_sensor_light_level
    dynamic_lighting_boolean: input_boolean.dynamic_lighting
    include_bypass: []
    motion_bypass_lights_off: []

Thanks in advance

@Blacky Merry Christmas and soon Happy New Year. Thank you for all the work you do on this.

Quick question, I should know this as I was an early adopter. Your bypass entities seem to be OR conditions, in other words if you add 2 entities as a “turn off” bypass, the lights won’t turn on if either of the entities is true.

Is there a trick I can use to have it be an AND condition. Trying to have certain light automations not trigger when I set a toggle helper to “guest_over” AND the time of day helper is set between X and Y.

Thank you

@harryfine

Hi Harry, Merry Christmas to you to and all the best for the New Year.

Yes it is or so if you would like to have your bypass ON when both “guest_over” AND the time of day helper is ON then you will need to create a template binary sensor and then just use that in the bypass.

To create a Template binary sensor, follow these steps:

  1. Navigate to Settings > Device & Services > Helpers tab at the top.
  2. Click the Create helper button.
  3. Select Template and then choose Template a binary sensor.

Next, provide a Name and Device class of your choice. If applicable, you can link this template to an existing device so it appears under that device’s details.

In the State template field, add the code below, replacing the two entities with your entity ID.

{{ is_state('input_boolean.guest_over”','on') and is_state('binary_sensor.your_time_of_day_helper','on')}}

Blacky :smiley:

@Frank78

So you only want it to work when someone is home but your trigger stays ON from morning to night. Then you could create a template binary sensor and use the device tracker. Then put it into bypass option 2.

To create a Template binary sensor, follow these steps:

  1. Navigate to Settings > Device & Services > Helpers tab at the top.
  2. Click the Create helper button.
  3. Select Template and then choose Template a binary sensor.

Next, provide a Name and Device class of your choice. If applicable, you can link this template to an existing device so it appears under that device’s details.

In the State template field, add the code below.

{{ not states.device_tracker | selectattr('state', 'eq', 'home') | list | count > 0 }}

Blacky :smiley:

@RooneyFPV

You can do whatever you like sometimes you will need to do scripts but you got alot of times that are confusing.

Dynamic form 9am to 11am
Night lights from 7am to ??

There is only one time and it looks like you have your global time from 9am to 11pm. That is when the automation can run.

Dynamic lighting will work from 9am to 7pm then night lighs take over.
Night lights will work from 7pm to 112pm as long as the schedule.helfer_zeitplan_nightlights_pclampe is ON too. Do you need this? or do you need night time? looks to be the same.
It will only trigger ON when your lux is below 10 set in your ambient so that conflicts with dynamic as you would like it on at 110. I adjusted these settings so dynamic lighting will work.

I changed some settings so now it works like this.

  1. Only run when it is between 9am to 11pm, below 110lx and one of the 2 people are home.
  2. Dynamic lighting works between 9am to 7pm. At 10lx = 100% brightness and 110lx = 0% (that is light OFF).
  3. At 7pm to 11pm night lights and your light will be 1% (check your light can do this normaly they need more but sone are ok) with colour temp 2000.
  4. If lights are ON and it crosses over to night lights the light will change.
  5. Light OFF at 11pm to 9am.

TIP use the <> in the editor and then paste your code into this forum so it will look like shown below and it will keep the correct format.

Below is your code, copy paste it in and see how you go,

alias: Automation PC Lampe
description: ""
use_blueprint:
  path: Blackshome/sensor-light.yaml
  input:
    motion_trigger:
      - binary_sensor.wohnzimmer_bewegungsmelder_occupancy
    light_switch:
      entity_id: light.lampepc
    time_delay: 30
    include_light_control: []
    include_light_colour_control: use_colour_temperature
    light_colour_temperature: 4300
    light_rgb_colour:
      - 255
      - 255
      - 255
    include_dynamic_lighting: enable_lux_controled_brightness
    dynamic_lighting_lux_sensor: sensor.wohnzimmer_bewegungsmelder_illuminance_lux
    dynamic_lighting_max_lux: 110
    dynamic_lighting_min_lux: 10
    dynamic_lighting_max_colour_temp: 4300
    dynamic_lighting_min_colour_temp: 2200
    dynamic_lighting_heartbeat: 0.25
    dynamic_lighting_step_value: 100
    dynamic_lighting_dead_zone: 0
    include_ambient: ambient_enabled
    ambient_light_sensor: sensor.wohnzimmer_bewegungsmelder_illuminance_lux
    ambient_light_value: 110
    ambient_light_high_value: 115
    zone: zone.home
    people:
      - person.chris
      - person.rina
    include_time: time_enabled
    night_lights_conditions:
      - time_enabled
    include_night_lights: night_lights_enabled
    night_lights_entity_state: []
    night_time_delay: 140
    night_lights:
      entity_id: light.lampepc
    night_light_brightness: 1
    include_night_light_control:
      - use_brightness
      - if_lights_are_on_adjust_when_crossing_over
    include_night_light_colour_control: use_colour_temperature
    night_light_colour_temperature: 2000
    night_lights_after_time: "19:00:00"
    light_brightness: 100
    dynamic_lighting_max_brightness: 100
    after_time: "09:00:00"
    before_time: "23:00:00"
    include_device_tracker: zone_people_enabled
    dynamic_lighting_min_brightness: 0
    night_lights_before_time: "23:00:00"
    ambient_light_options: ambient_light_option_disabled
    night_light_rgb_colour:
      - 255
      - 201
      - 147
    dynamic_lighting_boolean: input_boolean.helfer_pc_lampe

Blacky :smiley:

1 Like

@grassiekuik

That is because you have selected YES - My Ambient Light Sensor is affected by the Lights in ambient. What that will do is ignore your lux sensor once the light is ON. Untick it and use the Ambient Light - High Lux Value. Then what will happen is your light will work below 15lx but then turn OFF at 45lx. What you might find is your lux sensor wont react fast enough and if your light goes OFF and you trigger it again the light wont come back ON until your lux sensor drops below 10lx. What you can do is when it is dark (night time) turn your light ON and see what the lux value is. then set that level + some for your low and then set your high above that. During the day with natural light the lux value should go very high.

Blacky :smiley:

1 Like

@Blacky Thank you so much. I will give that a go

1 Like

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.

Great. I never used scripts until now. How to get the entity of the used light in the script?

@b_tton

First create a scene.

  1. Go to settings > automation & scenes > scenes tab
  2. Create new scene button > add your light entities in, then click on them and adjust them to the brightness, colours etc you would like.
  3. Once done click save.

Next create a script.

  1. Go to settings > automation & scenes > scenes tab
  2. Create script button > create new script > add action
  3. Type “light” and select turn ON action.
  4. Choose your light entities and set them to 50%.
  5. Next click on the “add building block” button and type “wait”
  6. Select “wait for time to pass” then enter in your time you would like to wait before turning OFF you lights.
  7. Add action button > Type “light” and select turn OFF action.
  8. Choose your light entities.
  9. Save.

Next create a toggle helper.

  1. Navigate to Settings > Device & Services > Helpers tab at the top.
  2. Click the Create helper button.
  3. Select “Toggle” then enter in a name for it.
  4. Once happy click create.

Now you have all you need go into the automation.

  1. Remove all your lights form Lights - Switches - Scenes - Scripts and enter in your scene.
  2. In Scenes & Scripts - Toggle Helper enter in your toggle helper.
  3. In Scenes - Scripts To Turn OFF enter in your script.

Your done, test it out.

Enjoy

Blacky :smiley:

@Blacky thank you so much.

@harryfine No problem, your welcome.

Blacky :smiley:

Hey!

Thanks for the help! I just tried it but sadly it didnt work. I switched away from scenes to just turning the light to a specific colour but after waking up and it being after sunset it still turns on the nightlight somehow.

That works. But now, and maybe this is a feature request, it still turns on the nightlight even when the bypass is on since there are no bypass settings in the nightlight. Maybe I am missing something.

This has helped with the one that had the nightlight issue, thanks!

Now I have another one. This one does not turn the first time per day I trigger the sensor. After the on time has passed for the first time, it will work properly. Even with the nightlight option disabled.

the automation is so simple, I struggle to understand what could we wrong:


alias: Washok - bewegingdetectie
description: ""
use_blueprint:
  path: Blackshome/sensor-light.yaml
  input:
    motion_trigger:
      - binary_sensor.washok_sonoff_snzb_03_motion
    boolean_scenes_scripts: input_boolean.washok_toggle
    light_switch:
      entity_id: scene.washok_lampen_vol_aan
    end_scenes:
      - scene.washok_lampen_uit

Hey, it’s me again. First of all, thanks again for this blueprint and the continuos updates and support! I can’t stress this enough.

I want to achieve something and I am not sure what would be the best way to approach it. I try to be as concise as possible, yet I want to provide context:

  • I use dynamic lighting mode “8” with motion sensors
  • I have a night light enabled, which is only one single bulb on 1% brightness and 2300 K, so veeery dim
  • Night light is only for the middle of the night.
  • Normal lighting allows for max 100% brightness

Now before using this blueprint, I had 4 different lighting modes:

  • Default: A lighting setting that works 95% of the time. Warmer, but not too warm, quite bright, but not too bright
  • Bright: Everything to 100% brightness, 3000 K or even colder light
  • Dim: Warmer than default, and way darker. For chilling in the living room or so
  • Dark: As night mode desribed above, so max. one bulb per room, 1% brightness, 2300 K

After using your blueprint for a while, I started missing this “dim” mode, because the normal mode is way too bright for chilling on the evening. My idea was:

Create a number input helper “maximum brightness percent” and use it as template parameter for “Dynamic Lighting - Max Brightness Value” in the blueprint. Something like this:

    ...
    dynamic_lighting_min_colour_temp: 2700
    dynamic_lighting_max_brightness: "{{ states('input_number.home_sensor_lights_max_brightness') }}"
    dynamic_lighting_dead_zone: 1
    ...

Then I played on the new input helper, and as expected, nothing happened (would be too easy :smile:). But then I just toggled my bypass switch twice and the lights started to dim and converge to the new-set value given the other dynamic lighting parameters (step, heartbeat time, …). So I created an automation:

If value of new number input helper changes, toggle the bypass switch twice (in other words: force the sensor light blueprint automations to update)

Now this works quite well, but it feels very hacky. Additionally, there’s a drawback.The brightness updates veeery slowly, as I said according to the step and heartbeat time parameters of dynamic lighting. So you barely have any feedback after you want the brightness to change. I mean the purpose of these parameters is that you do not perceive any changes in the lighting. So they do what they are supposed to do… I feel like I am almost there, but the lack of feedback makes it hard to use. For example if the lighting is dim to begin with, and you want to eat something in the dim living room, you have to wait for minutes for the lights to come to full brightness with somewhat default settings.

All I would need is some kind of “secondary” trigger I could use for the sensor light automations, that would trigger them and re-evaluate from scratch as if it was triggered by a motion sensor or so, but obviously only if they are already active in the first place. It cannot be part of the “primary” trigger, as this would turn on all lgihts in the house. Is there anything like that I could make use of to achieve this?

I hope I made clear what I’d want to achieve with this. If I can make it work with maximum brightness, I would also roll out slides for light temperatures etc. so I can fine-tune specific lighting settings for specific use-cases, while still maintaining the awesome flexibility of this blueprint with the dynamic lighting capabilities etc. As I said, it feels like everything is there alredy for me to do what I’d like to have, but I cannot fit the pieces together.

Best and thanks for your work again!
Chris

@Blacky thanks for all your blueprints. I use several and plan to use at least one more. They are fantastic.

For the Sensor light one, I have a toggle called Sleep. I put it in the Bypass for the Off option. It is also exposed to Google Home. So, when we go to bed, I tell Google Home to turn Sleep on. It does and any lights that are on go out. Is this a reasonable use case?

If so, I would ask you to consider three additions:

Allow the lights to ramp down rather than go immediately off. It is a little jarring. Turning off over a minute would be great. I see I can delay the turn off but I expect that it is immediate after the delay.

Add an option for quiesce rather than turn off. This would leave lights as they are. But it would not respond to any new motion inputs. It would also turn any on lights off after the timeout.

Add an option for random. I would create a vacation toggle and use it for this. That way, if I was gone for an extended period my lights would turn on and off randomly. There could be additional options for minimum on time, time period to not turn on (e.g., midnight to 6AM), etc.

Thanks again for great blueprints. Happy New Year.

@Wibias

I think you got it working… the bypass settings are global condition for normal lights & night lights / glow lights.

Blacky :smiley:

1 Like

@Limbeck

Just checking why you have a scene for your laundry lights to be full on.

Why use scenes?

  • Lighting Control: Set different colours and brightness levels for your lights, creating the perfect ambiance.

If they are all full ON then just enter the light entities into Lights - Switches - Scenes - Scripts and use the control options. No need for scene, toggle helper and end scene. A lot easier and the automation works so much better.

If you set up your automation / edit it or adjust it and the trigger is ON, the trigger must go OFF and then back ON.

Blacky :smiley: