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

I have the same set-up. I want to only turn on two lights when i enter the room. But if i happen to turn on more lights while sitting in the room i want to turn off all lights in the room when I leave.

I managed to do this with two scripts.

Could you share your scripts pls?

Great work as always. Just wondering if is possible to implement making some of the settings collapsable? For example, I’m not using Dynamic lighting in the blueprint, so I can simple collapse all settings related to it, and expand if needed, it should be collapsed by default.

The blueprint is quite powerful and has vast amount of configurations on a single page. which can become overwhelming for some. Hope you understand, thanks.

1 Like

@seblor

Yep a script… example below. A guide on this process can be found Here.

If-Then-Else script into ‘Lights - Switches - Scenes - Scripts’ No toggle helper in ‘Scenes & Scripts - Toggle Helper’

If

Then

Else

Then create a scene with all light OFF and enter into ‘Scenes - Scripts To Turn OFF’

Blacky :smiley:

How can I add an offset for Sunset so lights come on 1 hour before sunset, and 1 hour after Sunrise? I tried tweaking the Sun Elevation either way, but it doesn’t do anything for me for some reason.

You can vote here Collapsible Selector Groups - #2 by Blacky

Blacky :smiley:

1 Like

@iona

Firstly welcome to the community :wave:

Please see the FAQ in this.

Q: Why did you choose sun elevation as the sun option and not sunrise and sunset, I don’t really understand the degrees and elevation, I assume zero is the sun just on the horizon with a + being day time and a - night time.

A: Please read our explanation and how to set it up, it’s easy :slightly_smiling_face: Click Here

Blacky :smiley:

Hi @Blacky first of all your blueprint looks amazing! Thanks you for sharing that with the community. As I am playing around with it, I came to the following issue:

My light gets turned on whenever there is motion and the illuminance is below the lux level I have set. One minute after the last detection of motion it turns off again as it should. However, turning on the light changes the illuminance measured by the sensor, which means the lights do not turn on again when I re-enter the room, because the illuminance is now too high for the automation to trigger. I tried to figure out if I could solve this by using the ambient sensor options your blueprint provides. Unfortunately, I was not successful despite reading the FAQ.

What I guess is missing is a cutoff value for the illuminance in the room, so the automation only runs when the illuminance is below that cutoff value, as well as an illuminance value that is not provided by the motion sensor itself, because then the illuminance would be affected by the light when the light is on. The illuminance value should instead be provided by a number helper which is basically a copy of what the motion sensor’s illuminance would be BUT only changes lux when the light is off (got the idea from here). This way you only get “real” values for the illuminance in the room without any interference when the light is turned on.

I hope I explained this in a way one can understand and am looking forward to your answer. :slight_smile:

@arne.conrad

Is your LUX sensor slow to react?

see ‘Ambient Light - Low Lux Value’

Select ‘YES - My Ambient Light Sensor is affected by the Lights’

If you like then to can create a template helper, then use that for your LUX sensor but when the light is OFF you will need to check LUX at quick intervals as you may close your blinds and the room gets dark. You could get a LUX sensor that reads fast and your problem is solved. See we need data to make things work if you would like it to respond quickly. If you had a LUX sensor that updates fast then everything works. The data is only stored for 10 days so you dont build a big data file thanks to the work from the HA Team.

I think all you need to do is tick the ‘YES - My Ambient Light Sensor is affected by the Lights’.

Blacky :smiley:

1 Like

Hi @Blacky you were of course absolutely right. My bad I got some settings wrong. Thanks for the explanation and your blueprint. This is absolutely amazing!

One final questions: Is there an option to completely block the automation from running at night? As far as I have seen, the night option only makes it possible to have different settings for the lights whenever the night condition is met, but it always means the lights will be ON in some way.

In my old automation, I used a helper that is activated whenever I say Good Night to Siri, resulting in the light automation being blocked. When I say Good Morning, the helper changed its state and the light automation would be active again.

Thanks!

1 Like

This is what the By-pass options can be used for.

I use my ‘Sleep Mode’ helper toggle to turn the lights off and stop the automation until the next morning.

Hope that helps!

2 Likes

Oh great, I did not realize this. I guess I have to read and try out more before asking questions :smiley: Thanks for your help!

Hey, thanks for this work, it’s really awesome especially for new users!
Is it possible to have by-pass inverse option or somehow do a workaround about this?
I’ll explain: i have voice assistant where i want to expose “Auto Kitchen ON/OFF” for example. So if it’s ON - script is working via motion detection, if i ask voice assistant “disable auto on kitchen” - it should work as “by-pass keep current state”.
I’ve tried to mess around with enable/disable automation at all via automation.turn but this one keep stalling or work not as i intended. Very new in this :slight_smile:

Ah great, didn’t realise it was a HA limitation, upvoted.

@Sk1vvy

Firstly welcome to the community and thanks for your kind words.

That is not a good way. If we use the bypass when we turn it ON we can make it do 3 different things and when we turn it OFF it checks the site conditions and tries to preform the correct action. Disabling and enabling and automation will do nothing other than turn it OFF / ON and wont work well.

If you would like the bypass to work in reverse then see templating in the FAQ. See REF - TS-7 and also read REF - TS-9 as this shows you an easy way to make a template.

Blacky :smiley:

Also have a look at this blueprint as it just out an may be what you are looking for.

Blacky :smiley:

@Blacky This is a really awesome blueprint, thanks for sharing!

I’m having one issue and I’m not sure if I’m doing something wrong, or if there is a bug.

My use case is that I want my downstairs lights to be automated at night. I set the start time to be after 8PM and before 6AM. I also used the bypass to keep the lights “as-is” if the TV is on (using a remote entity). The issue I’m having is, every time I turn the TV off, regardless of the time of day, all the lights turn off as well.

I was expecting Bypass Switch - Keep The Lights Current State to keep the lights on instead of turning off after there is no longer motion (this works), but also keep the lights unchanged as soon as I turn the TV off as well. Is this possible?

Here is how I currently have the automation configured.

alias: "Sensor Light - motion automation "
description: ""
use_blueprint:
  path: Blackshome/sensor-light.yaml
  input:
    motion_trigger:
      - binary_sensor.downstairs_motion
    light_switch:
      entity_id:
        - light.left_strip
        - light.right_strip
        - light.right_lamp
        - light.left_lamp
        - light.foyer_lamp
        - light.piano_lamp
        - light.dining_room
    dynamic_lighting_heartbeat: 2.25
    include_time: time_enabled
    after_time: "20:00:00"
    before_time: "06:00:00"
    include_bypass:
      - bypass_enabled_stop
    motion_bypass_lights_stop:
      - remote.harmonyhub

i know, that’s what i mean with not working as intended :wink:
Thank you! I’ve looked into creating helper before for something like inverted sensor, doesn’t know about template. Would read your FAQ about this and look into docs also

@regnare

No problem, glad you like it.

Lets go through some things that may help you to better understand. Thanks for provide your YAML as it helps me to see what is happening.

Bypass - When we turn ON the by pass depending on what option you choose it will do the action. In your case 3 - Enable the Bypass - Keep the lights current state. When we turn OFF any bypass it checks your settings and the site condition and preform the correct action :crossed_fingers:

  • You have asked for the automation to only work between 8pm to 6am when motion is detected.

When you turn your bypass on it will 3 - Enable the Bypass - Keep the lights current state. So if the lights are ON they will stay ON, if the light are OFF they will stay OFF.

When you turn the bypass OFF and it is not between 8pm to 6am and motion can be ON or OFF the lights will turn OFF. If it is between 8pm to 6am and motion is OFF the lights will turn OFF. If it is between 8pm to 6pm and motion is ON depending on light state the lights will stay ON or turn ON. This is what you are asking the automation to do.

I think this is your issue - When we turn the bypass OFF and it is between 8pm to 6am and the motion sensor is OFF we have an bypass option because when you turn the bypass OFF your light will turn OFF instantly and we dont want to be left the the dark. To fix this there is a setting Bypass - Time Delay. Currently you have it set to ‘0’ so your light will turn OFF instantly. If you set this to the same setting as your Time Delay (I think is set on ‘5’) you will have 5 minuets to trigger the motion sensor before your lights will turn OFF. You can adjust this setting to anything you like. I think this is what your are finding, your Bypass - Time Delay is set to ‘0’.

Check this out and let us know if this fixes your issue, remembering what you are asking the automation to do when you turn it OFF. A lot of time and code has gone into making this happen like this and I hope once you understand it will make sense.

Blacky :smiley:

@Sk1vvy

Okay if your not 100% sure I will help you a bit more.

First you create a toggle helper called “Auto Kitchen” as per you example. So when you say Auto Kitchen ON it will turn OFF your template sensor we are about to create below and enable the automation :wink:

To create a toggle helper
Go to Settings / Devices & Services / Helpers Tab at the top / Create Helper / Toggle then enter the name “Auto Kitchen” or anything you like with a icon if you like and click create.

Once done you create a template sensor for the bypass to work inverted to your toggle helper “Auto Kitchen”.

To create a template sensor inverted
Go to Settings / Devices & Services / Helpers Tab at the top / Create Helper / Template / Binary Sensor / Enter in the name you would like to call it and set the device class to lock (You can chose anything you like here) and in “State Template” paste the code below replacing the “input_boolean.auto_kitchen” with your entity ID of your toggle helper you just created. Once done click create.

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

Now enter this template sensor into the bypass. I think your are looking to use 2 - Enable the Bypass - Turn lights OFF but it is totally up to you on what happens here.

Now when you use the voice and say turn ON “Auto Kitchen” it will turn OFF your template sensor making the automation active. When you say turn OFF “Auto Kitchen” it will turn ON your template sensor disabling the automation :wink:

TIP: You could just create a toggle helper called “Kitchen Bypass” and use this as your voice command and all you have to do is enter this toggle helper into the bypass without creating the template sensor. But it is up to you and what you would like to do with your voice commands. Example - you would say “Turn ON kitchen bypass” and it will stop the automation. Then say “Turn OFF kitchen bypass” and it will enable your automation :wink:

Hope this helps you and let us know how you go.

Blacky :smiley: