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

@Wibias

Thanks for reaching out and providing your YAML. It helps me allot.

Just one setting was needed, see below. Please tick this option.

TIP: Scenes can sometimes be tricky to work with, depending on what you’re controlling. When possible, it’s generally better to use entities directly, as this ensures the blueprint functions at its best. That said, scenes are ideal for setting specific colors and brightness levels across different lights. If your scene consistently uses the same brightness or colors, I’d recommend using entities with light control options instead. This approach can also help reduce the chances of light flicker.

Let us know how you go.

Blacky :smiley:

1 Like

@Hugoliv

Do you mean? “Can you explain how to keep the lights on after the delay if the automation has not triggered?”

If so then yes you can use the bypass. I have a FAQ on the bypass that may help you. Have a read of it and if you got any questions just ask. Click Here

@McBenac

Welcome to the community.

You did everything right but I found one thing that I will need time to think about before or if I fix it as it could impact something else.

Your min brightness is 5% and then dead zone is 7%. Because your brightness is lower than your dead zone it is not turning the light ON. I am doing this so it keeps HA working faster (I know it is only a little but every bit helps). So for now you have 2 options. Increase your min brightness to +8% or reduce your dead zone to 4%. You may find from 5% to 8% there is no real difference anyway or your can adjust both like min brightness to 7% and dead zone to 6%.

Let me know what you think and if it worked for you.

Blacky :smiley:

@Novgorod

Welcome to the community.

You can look at the traces and see what triggered it to turn OFF.

Just checking everything as you didn’t provide your YAML.

  1. In the trigger you have one and only entry and that is the group of your 2 occupancy sensors.

Because your are using the ambient as soon as it goes above your High Lux Value the lights will go OFF instantly and that is what I think is happening for you but I could be wrong.

How did you group the ambient sensors and are they effected by the lights? You do have an option to tick called YES - My Ambient Light Sensor is affected by the Lights but then your High Lux Value will not be in use. Check this out and make sure your settings are correct here and monitor your lux values.

If you like 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:

Hi! Is there an example how to use this blueprint with a button like a Sonoff SNZB-01 - for example to turn the light off manually after turned on by the sensor?
I played with the Overrides but always end up with a nonworking setting :slight_smile:

My working steps:

  • Using a zigbee motion sensor to trigger
  • no sun, timer, nightlight whatever to keep it simple in the beginning
  • using a simple light to be automated

→ This works so far as supposed.

Now the non-working steps:

  • Sonoff SNZB-01 Buttons (no switch!) implemented with the blueprint Sonoff SNZB-01
  • as the override needs a state → i added a helper input_boolean that is toggled by that sonoff Button
  • added that input_boolean helper to the override

That works like I can use the button to toggle the light on and off.
BUT: as soon as the sensor is triggered - then the states of the helper is not the same as the light itself → so it seems this breaks the condition to let the automatisation work.

Where is my error in thinking?
Do i have to do some logic with the Scenes & Scripts - Toggle Helper?

@valki

Welcome to the community.

This is an unusual request.

You would like to turn the light ON when motion is detected but turn it OFF manually. What happens when you turn it OFF, can you be out of the way of the motion sensor?

If you look at this blueprint and use Trigger Entity State - ON only it will only turn your light ON.

:high_brightness: Smart Light - Entity - Sun Elevation - Ambient & Time Triggers

Blacky :smiley:

Hi,

i really love your blueprint and use it for every light strip, some rooms and even for the Awtrix3 Matrix.

Since the New config Layout it got even better.

I sometimes (really not often) have the following problem:

If the light time (e. g. 1 Minute) is over and someone triggers a Motionsensor right in the moment where the light goes off it doesn’t turn on until the person triggers the Motion sensor again. But the Motion sensor wont be triggered again until there was no movement for 10 seconds (cooldown time).

Is there a way to fix this? Maybe it’s related to my setup.

Home Assistant VM <—> MQTT LXC <—> Z2M LXC

There is a delay of maybe some milliseconds.

I think the problem could be the following sequence:

  1. Motion sensor gets’s triggered. Light turns on
  2. Motionsensor is not triggered anymore. 1 Minute Timer starts
  3. At 59, 9 seconds (example) someone triggers the motionsensor again. And sends a call to the automation to reset the timer.
  4. The automation turns off the light because the reset call comes too late.
  5. The automation does not check anymore if the light is really on

Maybe a forced “turn on call” would be better instead of just resetting the timer? I’m really no developer and this are just some thoughts about it.

As i already said, it doesn’t happen really often, but it mostly happens to my wife and this is really bad for the Woman Acceptance Factor of our smart home. :smiling_face_with_tear::joy:

Thank you very much for your work.

Thanks for the elaborate reply! You were exactly right - one of the lamps was shining into one of the motion detector’s ambient light sensor resulting in a high lux value after the light turned on, which causes it to turn off right away. I have 2 motion detectors and I grouped their ambient light sensors to return the mean value - which is an issue if one of them gets blinded by a lamp. Now I changed the group to report the minimum value instead of the mean and everything is fine now because only one of the motion detectors is affected by stray light.

The mitigation in the script (“YES - My Ambient Light Sensor is affected by the Lights”) prevents the lamps from turning off immediately, but there’s potentially a second issue with stray light: When the lamps turn off normally after the timer expires, the (currently high) lux value may not get updated for up to a minute or so due to the slow zigbee polling rate, causing the automation not to trigger during this time. I don’t know whether your script accounts for that - I only tested it with a simple test automation and then I fixed my lux sensor value so I don’t have the problem in the first place.

I guess the lesson is to be careful with stray light :slight_smile: …

@luck3rhoch3

Thanks for your kind words.

Good analogy, your close.

I think what happens is when the automation turn your light OFF sometimes the light status takes some time to update in HA. In this time the automation triggers again but it thinks the light is still ON so it leaves it alone.

See how I have written the code is that if your light is ON and the automation get’s triggered then it wont send a signal to turn the light ON again as it knows the light is already ON. There are a few reasons for this.

  1. This stops your network from receiving extra data that is not required. Better performance over your network with less congestion.
  2. You light doesn’t get call after call to do something, it just runs nicely not getting bombarded with calls. Could extend the life of your light.
  3. You can adjust the lights once they are ON if needed and they don’t change on you.

So you may find it is the speed in witch your light reacts (status change) when it is turned OFF in HA.

If this bothers you, try creating a scene and use the scene instead of your light entities. You will also need a toggle helper for Scenes & Scripts - Toggle Helper. Now the automation will look at the toggle helper for the light status. Because this is within HA hub, it is fast reacting and you just may find that this resolves you problem.

Remember you will need to create an OFF scene as well and enter it into the automation and I would only do it to the automation that you have a problem.

Try it and let me know if it works, this way I know my theory is correct and can help others.

Blacky :smiley:

@Novgorod

You could just try and use the LUX sensor that is not effected by the light as this is the one reporting the low value anyway. Then there is no need for the group.

You may have to adjust your min LUX value to the value the LUX sensor reading + some when the light is ON and it is dark (night time no natural light). This way it will always turn ON but if it ever goes higher than that value the light will stay OFF and it should be bright enough anyway. Then you wont need to use the (“YES - My Ambient Light Sensor is affected by the Lights”) and just set a high LUX value. Now you wont have a problem with the slow zigbee polling rate.

Blacky :smiley:

You could just try and use the LUX sensor that is not effected by the light as this is the one reporting the low value anyway. Then there is no need for the group.

Well, I grouped them for more reliability, but alas… At least the “dark” value (lamps off for a long time) is reliable and consistent, but in practice it won’t make any difference to use the “min” value or just the unaffected sensor alone.

You may have to adjust your min LUX value to the value the LUX sensor reading + some when the light is ON and it is dark (night time no natural light).

Yeah, that should be fine for a small offset. In my case it would be a bit too extreme though because the stray light comes from a floor lamp that’s hitting the motion detector from below where it has the lux sensor, so it gets something like 140 lux at night when the lamp is on. That’s the ambient brightness around 9-10am here (in Winter), so it would be kind of wasteful. In any case, my problem was solved by being mindful of the lux sensor readings, but it’s good advice when stray light is unavoidable.

1 Like

Hello Blacky,

i am using youre bleuprint with great joy, but i have question.

is it possible to use the device tracker to turn off the lights when nobody is home during the day, and that the nightlights work normally, even when nobody is at home.

at the moment the lights stay on or off when nobody is home, depending on current state. the state doesn’t change when nobody is home.

or am i doing something wrong in the configuration?

would be great to get it working like that.
thanks in advance

Hello, Blacky. Thanks for your blueprint!
I’m trying to use it to control the light in the bathroom, but I’ve a problem. I have two lamps, a double switch, each switch controls one lamp, and a presence sensor. The trigger for automation is the presence sensor, which turns on one of the lamps with the first switch. I wanted to set it up so that if the second switch is on, the first switch doesn’t turn on automatically. Using a bypass didn’t help in solving the problem, as soon as I turn off the second switch, the first one immediately triggers, and I have to turn it off manually. Unfortunately, the list of conditions does not allow me to enter my own additional condition, which simply does not allow the automation to work, such as time, sun height or illumination.

@Frank78

No, Device tracker is a global condition.

What is your trigger? as motion sensors normally clear when no one is home.

Blacky :smiley:

@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: