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

Hi @sourceminer

No problem, thanks for your kind words. :+1:

I think I am following you but not 100% sure, but this is what should happen.

  1. During the day your light will turn on and off as per your settings (lets call this normal lights). If you use a scene you need to create another identical scene with everything off and put it into the “Scenes To Turn OFF”. Scenes will allow you to set colour, temp and brightness, so if using a scene then I wouldn’t use “Light Control” for setting the brightness. Do everything in the scene. All your lights will turn off if the trigger condition is met and after time delay.
  2. Night lights work the same a normal lights but will only run in the night light time period. If your normal lights are on and you transition to night lights, all your normal lights will turn off (entities & scenes) and your night lights will turn on. You may notice a flicker in your lights when this happens. This is because everything goes off and on instantly.

Some smart lights will / could have a setting to remember its last setting when you turn them off so when you turn them on again it will return to its last setting when it was off. Sometimes you can set a default setting so that it will return to default setting every time it is switched on regardless of what it was set on when it was turned off.

I think your using entities during normal lights and a scene in night lights that sets your colour, temp & brightness. Then when you go back to normal lights all your colour, temp & brightness returns because this was the last setting when they were turned off. There are 2 things you could check or possibility do.

  1. Check to see if there is a default setting in your smart lights. Or do they just return to there last setting from when they were turned off.
  2. Once you know how your lights work in the above, then you may consider to set a scene for normal lights so your lights will be reset to what you would like when they are turned on.

Just checking you have created a identical scene with everything off and you have entered that scene in “Scenes To Turn OFF”.

This is on my list to do but currently all my lights are dumb lights controlled by Shelly dimmers. They are dimmable with a physical switch to manual control of colour temp on the top. When I get or can find a light that is smart and only local controlled not Tuya or cloud based (not a fan of Tuya or the cloud) I will develop this. For now scenes are the best option if you would also like to set colour and or temp.

Hope this is on track of what you have asked and helps you.

Blacky :smiley:

Thank you for your Blueprint I really like it. Before using this blueprint Idid it with two automations. One was switching off the light after the sensor was going off.
With this automation the light was also switched out if I turned it on with a switch.

Am I right that this blueprint only switched the light off if it switched it on?

Hey !
Thanks for the blueprint ! It works great !
P.S: i may have miss it, no “transition” option ? I do prefer my lights to light in 2-3 sec it’s softer for the eyes

1 Like

Hi, I’ve been using your blueprint for a while. It’s great but at night, I can’t get my lights to turn on :frowning:

Do you have any idea why? Here is a copy of my automation…

alias: "Hallway "
description: ""
use_blueprint:
  path: Blackshome/sensor-light.yaml
  input:
    motion_trigger:
      - binary_sensor.lumi_lumi_sensor_motion_aq2_occupancy
      - binary_sensor.hallway_sensor_motion
      - binary_sensor.lumi_lumi_sensor_motion_aq2_iaszone
    light_switch:
      device_id:
        - 5457d2f04f61d9eb2df3f19664c6131c
        - 58ca05547b9ee4845224609aabbabc6d
        - 99b320abbbb2254319fdc418b5a5effe
        - 92dfccfca07bec025b9209467621f036
    time_delay: 3
    after_time: "06:00:00"
    before_time: "22:30:00"
    end_scenes: []
    include_light_control: use_brightness
    light_brightness: 70
    include_ambient: ambient_enabled
    ambient_light_sensor: sensor.lumi_lumi_sensor_motion_aq2_illuminance
    ambient_light_value: 45
    include_night_lights: night_lights_enabled
    night_lights:
      device_id:
        - 99b320abbbb2254319fdc418b5a5effe
        - 92dfccfca07bec025b9209467621f036
    night_time_delay: 1
    include_night_light_control: use_night_brightness
    night_light_brightness: 5
    night_lights_after_time: "22:30:01"
    night_lights_before_time: "05:59:59"
    ambient_light_options: ambient_light_option_enabled
    include_time: time_enabled

@Bibabutzi

Thank you :+1:

No the blueprint will switch your light on and off with a trigger. The trigger can be any binary sensor. Normally people will use a motion sensor as the binary sensor.

Note: If you turn the light on manually and the motion sensor detects motion the light will turn off automatically. It is recommended to use the “Trigger Sensor By-pass” option if you would like to keep the lights ON or OFF for extended time periods.

1 Like

@McKazou Firstly welcome to the community :+1:

You correct, currently there is no transition. This is on my list to develop and will be done. What lights are you using?

@3earnshaw

Thanks for providing your YAML. Your time option is 24/7 if you add your 6 to 22:30 & 22:30:01 to 5:59:59 less 2 seconds. The “Use The Time Options (Optional)” is global and will also include you night light time, so it stops when you would like to have you night lights work. Because you are not using any weekdays and you would like 24/7 just select “Disable the time options” in "“Use The Time Options (Optional)”. and you will be good to go.

I have also noticed you are using devices and you have selected “YES - My Ambient Light Sensor is affected by the Lights”. This option will only work if you have at least one entity selected. In you devices do you have multiple entities? Click on the “<>” and expand your devices out. You must have at least one entity selected for this option to work in “Lights - Switches - Scenes” and in “Night Lights”.

This is where the “<>” expand button is.

This shows it expanded into entities. Now the “YES - My Ambient Light Sensor is affected by the Lights” option will work. If I click on the “X” I can remove an entity if I like.

This shows entity removed.

HA has also colour coded them for us so we can see them easier.

Blacky :+1: :smiley:

2 Likes

Ah no, I want to turn off the light even if I turned it on manually. Because everyone forgets to turn it off :slight_smile:
Than everything works as I need it. Thanks

You can turn it in manually but for this blueprint in order for it to turn off after you have turned it on the trigger must be triggered (motion sensor) after it was turned on.

If you are looking for other options then you may want to consider some other blueprint I have created. It is realy up to you and what your trying to achieve. Below are 2 links to some other blueprints of mine.

Entity - Run ON Timer
Turn Light, Switch or Scene On & Off with Trigger Conditions

No it is totally what I was looking for. But never was patient enough to check if it works like this.
Use case is:

Someone is going to the toilet but the light is to bright to trigger the automatic light even when the motion sensor is triggered when you enter the toilet.
Then you switch on the light manually. But then no one is turning the light off because why :slight_smile: But when you then leave the toilet the motion sensor will go off and turn the light off. Even the automation did not turned it on.

So thats what I need. Totally fine. You saved me at least 50% of the motion automation I did before and with the time and the lux sensor it is even more configurable.

1 Like

Thanks for the detailed reply, between changing the device to green and adjusting the timers, it’s now working!

1 Like

No problem, glad you got it all working :+1:

Thanks for your reply :heart:

I don’t know why, but the blueprint doesn’t get triggered sometimes…? Could you check on something

Here;s my yaml

alias: Main Door 2 Motion description: "" use_blueprint: path: Blackshome/sensor-light.yaml input: motion_trigger: - binary_sensor.100148d374_4 light_switch: entity_id: switch.4_switch_kamonk_47_switch_3 time_delay: 1 include_time: time_enabled after_time: "18:00:00" before_time: "21:00:00" include_zone: zone_disabled include_night_lights: night_lights_enabled night_lights: entity_id: switch.4_switch_kamonk_47_switch_4 night_time_delay: 1 night_lights_after_time: "20:59:00" night_lights_before_time: "07:00:00"

and its 23:30 in India right now.

@technokul firstly welcome to the community :+1:

TIP: When pasting code into this forum use the “</>” button as it will then display correctly and be much easer to read.

When using the “Use The Time Options (Optional)” this is a global time, so it also has to include your night light time.

So currently you have your time set to “18:00:00” to “21:00:00” so the automation will only work between this time period. You will need to include your night light time and set it to “18:00:00” to “07:00:00”. Then your night light time can be “21:00:00”(or “20:59:00”) to “07:00:00”

Blacky :smiley:

Hello,

I have in-wall smart switch module wired to regular switch for my kitchen. Lights are also normal spot lights. I use motion sensor as binary sensor. Can I use by-pass feature of this blueprint with that setup? It kind of works but not perfect. Switch toggles itself off than on immediately after time delay if I am still in the kitchen. If I am not, it turns off normally. I hope I explained clear enough. Is there anything I should consider? Such as my smart switch settings? Currently it is set to “state” mod of operation. Other 2 options are toggle and momentary. Thanks in advance.

alias: Kitchen Motion Sensor
description: ""
use_blueprint:
  path: Blackshome/sensor-light.yaml
  input:
    motion_trigger:
      - binary_sensor.kitchen_motion_sensor_occupancy
    include_sun: sun_enabled
    sun_elevation: 3
    time_delay: 1
    include_bypass: bypass_enabled
    motion_bypass: switch.kitchen_lights_l2
    bypass_time_delay: 2
    light_switch:
      entity_id: light.kitchen_light

Just to add, “switch.kitchen_lights_l2” and “light.kitchen_light” are basically the same thing. I used HA change device type and defined switch as light. That might be the reason why it wont work correct as I have to choose different entities. Hope there are some workarounds…

One problem I have is that it doesn’t seem to work with the adaptive lighting component,
When the lights turn on, they flash to full brightness white, then turn to the correct intensity and colour temperature. I can’t work out why this happens.

My old automations that I made used the turn on command and adaptive lighting turned the bulb immediately to the correct brightness and colour temperature.

@inancatl

Yes, I have the same setup here.

:thinking: In order for it to get to the end of the time delay there must be no motion detected or by-pass setting causing this.

This normally relates to what type of physical switch you are using. If you can see your switch turning ON and staying ON until you turn it OFF then that is a good start.

Below is a screen shot from a Shelly 1PM. This is how Shelly has set it up. I use toggle but you realy need to know what type of switch you have, how it works and follow the manufacture instructions of your smart switch.

Yep you cant do that. This is you problem “by-pass”. The by-pass entity cannot be used in “Lights - Switches - Scenes” and or “Night Lights” selections. So looks like you piggybacked the “light.kitchen_light” and created another entity called “switch.kitchen_lights_l2”. If you would like a physical switch it must be totally separated or you can crate a by-pass without having a physical switch. To do this see our FAQ on " Q: How to use the “Trigger Sensor By-pass” without having a physical switch?".

I would remove your “switch.kitchen_lights_l2” and create a “Trigger Sensor By-pass” without having a physical switch and you should be good to go.

Let us know how you go.

Blacky :smiley:

Hi @woowoo we should be able to sort this out. Could you provide us your YAML of the automation. To do this go into your automation, top right 3 dot, Edit in YAML, copy all the code, back to the forum and in your reply at the top tool bar click on “</>” and paste code.

I see that I had put a transition in my old automations to cover up the flash.

These three were using adaptive lighting:

  action:
  - service: light.turn_on
    entity_id:
    - light.bathroom_light
    data:
      transition: 1

 - service: light.turn_on
   entity_id: light.pantry_light
   data:
     transition: 1

  action:
  - service: light.turn_on
    entity_id: light.tv_room_light
    data:
      transition: 2

While this light freaks out with adaptive lighting and so it was set without a transition:

 - service: light.turn_on
   entity_id: light.kitchen_sink
   data:
     brightness: 50

The motion sensor turns on three lights each with different capabilities.

Is it possible to add some logic so that when Home Assistant gets restarted or the automations get reloaded, lights that were on when the event happened will be turned off? I’m asking because I’ve had the situation that a light in my shed happened to be on at the time i did a reload of my automations and as a result of the reload this light wasn’t turned off automatically anymore. It was a few days later before I saw it was still on and turned it off manually.

I know that the both below triggers can be used for triggering the automation. Adding these triggers can however have the -for some possibly unwanted- side effect that a light may get switched off after a reload or restart even though that light wasn’t switched on by the automation, so maybe if you add these triggers, we also need another setting to enable or disable this feature.

trigger:
  - alias: When Home Assistant starts
    platform: homeassistant
    event: start
  - alias: When automations are reloaded
    platform: event
    event_type: automation_reloaded