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

@makksi

It works… and the by-pass has so many options.

I have no idea what you are trying to do, so first you will need to explain it clearly so I can understand.

then

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.

No that is not correct. Even if it was correct the time from the trigger and the light turning ON is milliseconds.

I have no idea what you are saying here but if you preferred your previous automation then why don’t you just use that?

Blacky :smiley:

Sorry for misunderstanding. I like your automation because is very flexible and has so many options. I appreciate a lot your work and for that reason I’m asking you because, due to the great and big work you did I’m sure you have also considered the case I described.

So my main question was if in the automation, when you bypass the ON trigger the off timer is still counting not from the ON trigger, but from the light ON, otherwise this could be the reason why the off automation is not working.

I guess my explanation is clear, anyway just summarize here to be more clear.

I just want to set your automation in this way:

a)

  1. Turn light on on trigger
  2. Turn lights off after 2 minutes the light is on (regardless it was activated by a trigger or manually)

b)

  1. Set “Enable the By-pass - Turn lights ON”
  2. Switch ON light manually
  3. Wait 2 minutes then the light should switch off automatically

The case b3 is not working in my automation.

This is the YAML I’m referring to:

alias: Lampada bagnetto
description: ""
use_blueprint:
  path: Blackshome/sensor-light.yaml
  input:
    motion_trigger:
      - binary_sensor.sonoff_bagnetto
    light_switch:
      entity_id:
        - light.sonoff_bagnetto_lamp
    include_light_control: []
    include_bypass:
      - bypass_enabled_stop
      - bypass_enabled_turn_on
    motion_bypass_lights_on:
      - input_boolean.bypass_bagnetto_sensors_lampada_on
    motion_bypass_lights_stop:
      - input_boolean.bypass_bagnetto_sensors_all
      - input_boolean.bypass_all_light_sensors
    light_transition_on: 0
    after_time: "00:00:00"
    time_delay: 2

@makksi

It will only turn the light OFF if the trigger is triggered. If you manually turn the light ON the light will stay ON until the trigger is triggered and the automation runs. But you are happy with “A”.

I can see you have one by-pass for option 1 and 2 by-passes for option 3. By-pass option 1 is the question you are asking.

Note: When the by-pass is turned OFF it will evaluate the site conditions. If the trigger is OFF it will go through the settings to turn OFF. If the trigger is ON it will start the automation and it will not turn OFF until the trigger is cleared and then time delay has passed, like case “A”. It is something to be mindful of when testing… you may expect it to turn OFF and it is not turning OFF because the trigger is ON when you turn the by-pass OFF.

Looking at your YAML it is not working because you haven’t enabled the auto turn OFF option for the by-pass. I will show you 3 ways you can do this so it will help you understand the settings… it is totally up to you on what you choose and you can set any time you like. I will recommend 2 ways as it will work better because the automation is waiting to see if the trigger gets triggered in this time period. Remember we are just working on option 1 for the by-pass.

Recommended; This option will turn the by-pass off in 6 seconds and wait for 2 min to see if the trigger is triggered before turning light OFF. If the trigger is triggered in this 2 min time the automation will run. In the By-pass Auto OFF - Time Delay just type the value in “0.1”.

Recommended; This option will turn the by-pass off in one minute and wait for 1 min to see if the trigger is triggered before turning light OFF. If the trigger is triggered in this 1 min time the automation will run.

Not Recommended; This next option will turn the light OFF instantly if the trigger is OFF in 2 min. So for some reason if you are in the room and at that exact point when the by-pass turns OFF and your trigger is OFF the lights will turn OFF leaving you in the dark. Not realy a good idea.

Hope this helps you.

Blacky :smiley:

@makksi

Another option you can do if you use option 2 in the by-pass “2 - Enable the By-pass - Turn lights OFF”

Then you would just select the by-pass time delay to 2 min. Then if the light is ON when you turn the bypass ON it will turn the light OFF in 2 min and the by-pass will stay ON.

If you would like the by-pass to turn OFF then you would need to select the auto OFF for option 2 and your time. This option will turn the by-pass OFF in one minute and if the trigger is ON it will turn the light ON. If the trigger is OFF the light will stay OFF.

So many options.

Blacky :smiley:

This seems to be the way to go for at least one special mode. I’ve got Movie Mode working. Now I need to see if I can also implement TV mode for the same room.

The lights are not turning off at the end of the Time Options End Time. I set the Time Delay to the number of minutes required for it to coincide with the End Time. Not sure why that is…?

I also have the issue of the lights not changing to the Night Lights settings at the prescribed time. They just stay at the day time settings.

This is my config.

alias: Lounge Lights
description: >-
  Automation of Lounge Washers and Lamp. Links to Sensor Light Add-on for Movie
  & TV Modes
use_blueprint:
  path: Blackshome/sensor-light.yaml
  input:
    motion_trigger:
      - binary_sensor.evening
    light_switch:
      entity_id: scene.lounge_lights_evening
    time_delay: 165
    include_light_control: []
    light_brightness: 50
    light_transition_on: 3
    light_transition_off: 5
    include_sun: sun_enabled
    sun_elevation: 13.5
    include_time: time_enabled
    include_night_lights: night_lights_enabled
    night_lights:
      entity_id: scene.lounge_lights_night
    night_time_delay: 210
    include_night_light_control: []
    night_light_transition_on: 3
    night_light_transition_off: 5
    night_lights_conditions:
      - time_enabled
    night_lights_after_time: '20:45:30'
    night_lights_before_time: '00:15:00'
    after_time: '17:00:00'
    before_time: '00:15:00'
    include_bypass:
      - bypass_enabled_turn_off
    motion_bypass_lights_off:
      - input_boolean.lounge_sensor_light_bypass
    bypass_time_delay: 1
    bypass_auto_off_delay: 1
    include_bypass_auto_off: []
    night_lights_entity_state: []
    end_scenes:
      - scene.lounge_all_off

@clowgg

I have had a look at this… they will turn OFF but it is not the way I would like it… this has been fixed and will be in the next release. The update will be out soon.

I have tested it here it works but because you are using a scene we need to enter in one entity that is in your scene into “Lights - Switches - Scenes” and “Night Lights”. If you can enter in a switch from the scene that has no light control that would be the preferred entity but if you can’t then just enter in one light entity. The automation needs to see it and it can’t see scenes that is why we need just one entity.

So you will have your scene + one entity that it included in the scene. Example below.

Hope this helps.

Blacky :smiley:

1 Like

Thanks for the reply @Blacky
I have added the Lounge Lamp to “Lights - Switches - Scenes” and “Night Lights” just now. The automation will trigger when the sun sets in about 1.5 hrs, and we’ll see how it goes tonight.

Okay, keep an eye out for the update so the OFF will work as intended.

This worked @Blacky. I added one entity that was included in the Scene and it worked - the Night lights turned on with the configured scene. I noticed in the room & in the automation trace that the initial configured “Lights - Switches - Scenes" scene turned off before the “Night Lights” scene turned on - so there was a momentary ‘lights off’ event.

The lights also turned off at the end of the automation time - but I havent figured out if that was the delay timer expiring or the end of the automation timer.

@clowgg

Nice one.

It is delay timer expiring, but that is not what I would like so this has been fixed to turn off at end of condition.

I think you will like the update… sorry I didn’t want to say anything until it was fully tested, working and ready to be released :pensive:… sometimes it doesn’t make it. If you are just controlling brightness and or colour temp then you can remove your scenes now, enter in the entities, adjust the lights using light control options and tick the new feature box.

Blacky :smiley:

New update 5.1

New Feature :new:

  1. Night Lights - Use The Light Control Options - Now you have the option to select “If lights are ON, adjust the lights when crossing over” option. It will apply the light control settings to any light that is already ON when crossing over from normal lights to night lights and from night lights to normal lights.

    Without selecting this option, if the light are already ON and a night light condition crosses over, then they will keep the current state assuming you are up a bit latter at night or have some friends over and you don’t want the lights to go into night mode. Once the lights turn OFF, night mode settings will be applied the next time they turn ON. That is not always the preferred option in every area… so you get to choose what scenario you would like by just ticking a box

    If any lights are different from normal lights to night lights and are OFF, they will turn ON to the light control settings or OFF if required regardless if you tick the option or not.

Bugs Fixes :bug:

  1. Light not turning OFF instantly at end of global conditions.
  2. Crossover lights.

If you like this blueprint? Consider hitting the :heart: button in the top post :+1:

If you like my blueprints, and would like to show your support or just say thank you? Click Here :smiling_face_with_three_hearts:

Enjoy

Blacky :grinning:

3 Likes

Thanks for the update! I want to try this out. Silly newb question, but how to I update the blueprint and all the automation that are built on that blueprint?

Thanks.
–pat

Hi @PatWasHere

Firstly welcome to the community :wave:

For now see below but keep an eye out for this months HA release…

Q: How do you update the blueprint and not delete / recreate existing automations?

A: Please follow these steps Click Here.

Blacky :grinning:

1 Like

Thx for this excellent blueprint!
I’m discovering HA at the moment. As soon as I start to move all of my home automation from Fibaro HC2 to HA, this blueprint is definitely worth a donation!!!

1 Like

cool thanks for the tips. Tho I just watched a video of what’s coming up in the December HA release and they said there is a new update blueprint options being implemented. I will wait for that release.

I have a question regarding Night lights and Motion sensors.

What I want to achieve for my garden lights is:

  • My lights turn always On between 6:00h and turn Off at Sunrise
  • My lights Turn always On between Sunset and turn Off at 23:00h
  • During night time (23:00h and 6:00h) my lights turn on for a few minutes based on my motion sensor.

My setup:

  • My “Trigger Sensor - Binary Sensors - Schedule” is a Scheduled Helper (daily 6:00h to 11:00h and 15:00h-23:00h).
  • “Lights - Switches - Scenes” is a light scene to turn my lights ON
  • “Scenes To Turn OF” is a scene with the lights that have o be turned OFF
  • “Use The Light Control Options” is turned ON
  • “Use The Sun Option” is turned ON
  • “Use The Night Lights Options” is turned ON
  • “Night Lights” Is the same scene as the Lights - Switches - Scenes
  • “Night Lights Conditions (Required For Night Lights)” is turned ON
  • “Night Lights - Entity State” is the status of my motion sensor.
  • “Night Lights - Start Time” 23:00h
  • “Night Lights - End Time” 6:00h

Maybe I am doining something wrong, but my lights don’t turn on based on my motion sensor.
What am I doing wrong?

Hi @Blacky, thanks so much for this blueprint! It’s amazing and I’m using it already in a couple of places.

I have 2 questions about more implementation:

  1. How can I set the trigger to be both motion sensor 1 and 2 (not or). In this case I’m trying to setup a specific area by the door that won’t get triggered when people pass nearby.

  2. Similar but a bit different in another room: Can I setup where motion sensor 1 turns on the light, and the light stays on with either motion sensor 1 or motion sensor 2? (So the light doesn’t turn on from motion sensor 2, just using that one to keep the light on).

Thanks :slight_smile:

@mars2020

Let look at this

  1. My lights turn always On between 6:00h and turn Off at Sunrise
  2. My lights Turn always On between Sunset and turn Off at 23:00h
  3. During night time (23:00h and 6:00h) my lights turn on for a few minutes based on my motion sensor.

Lights are ON with 1 but 2 you would also like it OFF at 23:00??? is it ON or OFF?
3 between 23 and 6 = motion.

So
Schedule from 6 to 23 = your motion sensor, then group them but there is a but. The tricky part is the group so you will have to create a template binary sensor for your schedule. So when your schedule is ON your template binary sensor is ON. Then you can group your template binary sensor and your motion sensor and add this group to the trigger. Your done. :wink:

I have some examples for template sensors, look at REF - TS-5 Click Here

Blacky :grinning:

@Doodle6598

Thanks for your kind words :smiling_face_with_three_hearts:

Not sure what item 1 is, I am not understanding :pensive:

Item 2 I understand… so you will need to crate a trigger binary sensor… I dont have an example in my template sensors and not sure if you know what to do so the code is below. More information on what to do with this code is in my examples of the binary sensor. Click Here. Once you create it then you add this binary sensor (only this one) into the trigger.

Things you need to change are:

  • “binary_sensor.motion_sensor_1_here = This is your motion sensor 1 entity name.
  • “binary_sensor.motion_sensor_2_here” = This is your motion sensor 2 entity name.

The things you can change to your liking are:

  • “2 Motion Sensors” = This is the name you would like to call your new sensor.
  • device class “motion” and icon “motion-sensor”. = Change to your liking but is should be okay.
template:
  - trigger:
      - platform: state
        entity_id: binary_sensor.motion_sensor_1_here
        to: "on"
      - platform: state
        entity_id: binary_sensor.motion_sensor_1_here
        to: "off"
      - platform: state
        entity_id: binary_sensor.motion_sensor_2_here
        to: "off"

    binary_sensor:
        - name: "2 Motion Sensors"
          device_class: motion
          icon: mdi:motion-sensor
          state: >
            {% if is_state('binary_sensor.motion_sensor_1_here', 'on') and is_state('binary_sensor.motion_sensor_2_here', 'off')  %}
              on
            {% elif is_state('binary_sensor.motion_sensor_1_here', 'on') and is_state('binary_sensor.motion_sensor_2_here', 'on') %}
              on
            {% elif is_state('binary_sensor.motion_sensor_1_here', 'off') and is_state('binary_sensor.motion_sensor_2_here', 'on') %}
              on
            {% elif is_state('binary_sensor.motion_sensor_1_here', 'off') and is_state('binary_sensor.motion_sensor_2_here', 'off') %}
              off
            {% endif %}

Hope this helps you… let us know how you go

Blacky :grinning:

2 Likes