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

@Blacky Thanks for helping. I tried it today with delay_on and 10 seconds.

Basically, I walked into my ensuite bathroom then lights turn on then I jump into the shower and close the door then Lights stays on then I open shower door and lights momentarely goes off and comes back on again. Weird!

How does the delay_on fix the issue?

I looked at your Bathroom Humidity Exhaust blueprint. It looks good but not sure how I can use it. I still have a dumb exhaust fan that I need to turn on by the wall. I think I will have to get into the roof and connect a smart plug to be able to control it with HA. I do have an Aqara Temp / Humidity sensor I can stick to the ceiling above shower head.

Hi Blacky,

Any idea why it doesn’t work?
After adding an entity the behavior of the Scenes is ok, but not for the entities that I added.

See also my previous post:

Curious what control would you need? Just use scenes

@mars2020

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.

Can you also provide us the entities that are in each scene you are using.

Blacky :smiley:

@DaAliG

This will make it that both must be ON for it to be ON and both must be OFF for it to be OFF. I think that is what you are after :crossed_fingers:

template:
  - trigger:
      - platform: state
        entity_id: binary_sensor.kitchen_presence_sensor_presence_sensor_1
        to: "on"
        id: "t1"
      - platform: state
        entity_id: binary_sensor.kitchen_presence_sensor_presence_sensor_1
        to: "off"
        id: "t2"
      - platform: state
        entity_id: binary_sensor.kitchen_presence_sensor_presence_sensor_5
        to: "on"
        id: "t3"
      - platform: state
        entity_id: binary_sensor.kitchen_presence_sensor_presence_sensor_5
        to: "off"
        id: "t4"
    binary_sensor:
      - name: "Kitchen Stove and main Occupancy Sensors"
        device_class: occupancy
        icon: mdi:motion-sensor
        state: >
          {% if (trigger.id == 't1' or trigger.id == 't3') and is_state('binary_sensor.kitchen_presence_sensor_presence_sensor_1', 'on') and is_state('binary_sensor.kitchen_presence_sensor_presence_sensor_5', 'on')  %}
            on
          {% elif (trigger.id == 't2' or trigger.id == 't4') and is_state('binary_sensor.kitchen_presence_sensor_presence_sensor_1', 'off') and is_state('binary_sensor.kitchen_presence_sensor_presence_sensor_5', 'off') %}
            off
          {% elif trigger.id == 't4' and is_state('binary_sensor.kitchen_presence_sensor_presence_sensor_1', 'on') and is_state('binary_sensor.kitchen_presence_sensor_presence_sensor_5', 'off') %}
            on
          {% elif trigger.id == 't2' and is_state('binary_sensor.kitchen_presence_sensor_presence_sensor_1', 'off') and is_state('binary_sensor.kitchen_presence_sensor_presence_sensor_5', 'on') %}
            on
          {% endif %}

Blacky :smiley:

1 Like

@ruaandeysel

I have updated the template sensor to a more modern one for you.

What will happen is when the door is open it will be clear and when the door is closed it will be detected. When the door opens it will take 10 seconds for it to show clear allowing you time to trigger your motion sensor. You need to group this sensor with your motion sensor.

The only thing is, if you are using the delay in this blueprint for your light/s to turn OFF then you will not need the delay in this template sensor. Maybe your not using this blueprint :thinking:. Maybe try using this blueprint or maybe you haven’t groped them :thinking:. Groping them is critical for it to function correctly. So if you didn’t have them grouped before then first try it without the delay but grouped.

Below is without delay. You need to group this sensor with your motion sensor.

template:
  - binary_sensor:
      - name: 'Shower Doors'
        device_class: motion
        icon: mdi:door
        state: >
          {{ is_state('binary_sensor.your_shower_door_sensor_here', 'off')}}

Below is with a delay, but if you use this blueprint this is not required.

template:
  - binary_sensor:
      - name: 'Shower Doors'
        device_class: motion
        icon: mdi:door
        state: >
          {{ is_state('binary_sensor.your_shower_door_sensor_here', 'off')}}
        delay_off:
          seconds: 10

Blacky :smiley:

@Blacky Thanks a lot for looking into this and helping out.

This is what my config looks like now for the blueprint

I have created this sensor now and added to helper

template:
  - binary_sensor:
      - name: "Ensuite Shower Door"
        device_class: motion
        icon: mdi:door
        state: >
          {{ is_state('binary_sensor.shower_door', 'off')}}

And my helper group looks like this.

@ruaandeysel

Getting closer, but can you change a few things.

  1. Remove your trigger “Ensuite Motion Occupancy”
  2. Remove your group from the by-pass and untick option 1.
  3. Add your group to the trigger.

Click save and test it out. It should work.

Let us know how you go.

Blacky :smiley:

@Blacky Thank you. :pray: I just made the changes and it’s working.

Now I and the wife just need to remember to leave the shower door open to let the lights turn off automatically.

I wonder if there’s a way to get the shower door sensor to work in such a way that when the door is closed, opened and closed once you are in the shower that it will then keep the lights on. When you are finished in the shower, open the door and close the door, the motion sensor will trigger and work as normal and lights turn off as normal after time delay. :thinking:

@ruaandeysel

Looks like you would like a safe guard that if the door was closed after a shower the light will turn OFF in X amount of time.

You can do this but you will need a trigger-based template binary sensors. The below code will work the same as before but has a 15 minute auto OFF . Just change the minutes to a time longer than you would have a shower for. This way if you accidentally close the door and go to work the light will turn OFF in 15 min + your delay time set in the blueprint :wink: It will probably work well anyway as by the time you get out of the shower, dry and XYZ you would probably consume most of this time anyway.

template:
  - trigger:
      - platform: state
        entity_id: binary_sensor.shower_door
        to: "on"
      - platform: state
        entity_id: binary_sensor.shower_door
        to: "off"
    binary_sensor:
      - name: 'Ensuite Shower Door'
        device_class: motion
        icon: mdi:door
        state: >
          {{ is_state('binary_sensor.shower_door', 'off')}}
        auto_off:
          minutes: 15

Blacky :smiley:

1 Like

Hi there.

Is there a way to have the off condition to not actually turn the lights off but to set them to a lower brightness?

I have several hallways in the house that are always dark so I leave the lights on 20% and then increase to 80% on motion - after 5 minutes i put them back down to 20%. Overnight (11pm-6am) I shut them off completely.

Is there an easy way to manage this?

Sure…

First of all thanks for your great support, never seen anyone being so supportive on a forum…

My motion trigger is a grouped helper and is a combination of:

  • Scheduled helper (6:00 to 23:00) that is transferred to a binary sensor by using the Template sensor.
  • My motion sensor.
    This combination seems to work ok.

My Yaml:

alias: "Light: Blueprint Tuin Voor"
description: Verlichting Tuin Voor
use_blueprint:
  path: Blackshome/sensor-light.yaml
  input:
    motion_trigger:
      - binary_sensor.light_buiten_voor_schedule_and_motion
    light_switch:
      entity_id: scene.ha_scene_tuin_v_aan
    end_scenes:
      - scene.ha_scene_tuin_v_uit
    include_sun: sun_enabled
    time_delay: 2
    include_light_control:
      - use_transition
    light_transition_on: 5
    light_transition_off: 15
    sun_elevation: -1
    sun_elevation_rising: -4
    night_lights_sun_elevation: -1
    include_night_lights: night_lights_enabled
    night_lights:
      entity_id:
        - scene.ha_scene_tuin_v_aan
        - light.hue_1e_werkkamer
    include_night_light_control:
      - use_transition
    night_light_transition_on: 4
    night_light_transition_off: 10
    night_time_delay: 3
    night_lights_after_time: "23:00:00"
    night_lights_before_time: "06:00:00"

My Scene that needs to be turned On: “HA-Scene-Tuin-V-Aan”
My Scene that turns the lights Off “HA-Scene-Tuin-V-Uit” has the same setup and devices, but set to Off in the scene.

For the Nightlights I included 1 Hue Entity (light.hue_1e_werkkamer)

This Scene’s are a combination of 6 Hue outdoor spots added as Device (all like: “light.hue_tuin_v_spot_2” in the scene and 2 Entities, both Fibaro z-wave modules (like: " light.fib_dim_koof_voor_3".

Hope this will help. Let me know if you need more info…

For some weird reason the blueprint randomly stopped turning off lights, after turning them on.I have a motion sensor and light hooked up with sun elevation, but it never turns the light off.

Any ideas?

@madasus1

Currently the way you could achieve this is to have 2 automations and use the global time (Use The Time Options (Optional)).

One automation will run from 11 to 6 and the other one will run from 6 to 11. Both automations will have your light entities entered into “Lights - Switches - Scenes - Scripts” but the one that runs between 6 to 11 you would create a scene with your lights at 20% and put that scene in the “Scenes - Scripts To Turn OFF”.

Hope this helps you.

Blacky :smiley:

@mars2020

Thanks for your kind words :smiling_face_with_three_hearts:

I can see a problem in your YAML and I will explain scenes so anyone reading this may also benefit from it.

Use Of Scenes

When we add a scene into “Lights - Switches - Scenes - Scripts” and or “Night Lights” and don’t have any entities added then the automation can’t determine if the light is ON or OFF for that input. Scenes don’t have an ON or OFF state, HA just calls the scene to your settings. To combat this behaviour adding just one entity from the scene into the input allows the automation to function correctly as it can see entities and then knows what is happening. This applies to each input (“Lights - Switches - Scenes - Scripts” and or “Night Lights”).

Example;

  1. If we add a scene into “Lights - Switches - Scenes - Scripts” and have no entities entered then we can add one entity from the scene into this input. Now the automation knows what is happening in this input. If you have entered in an entity into this input regardless if it is in the scene or not then that is okay as well.
  2. If we add a scene into “Night Lights” and have no entities entered then we can add one entity from the scene into this input. Now the automation knows what is happening in this input. If you have entered in an entity into this input regardless if it is in the scene or not then that is okay as well.

Back to your automation

Before I go down a rabbit hole testing can you do something for me and test it please.

  1. In your “Lights - Switches - Scenes - Scripts” input can you add one entity from your scene into this input.
  2. In “Night Lights” I can see you have already inputed an entity into this input “light.hue_1e_werkkamer”. If you would like to turn that light ON and OFF then that is all good, that input is all set up correctly. I am not sue if that light is in the scene or not but ether way it will work. If the light is not in the scene and you don’t realy want to turn that light ON and OFF you can remove it and add a light or switch entity that is used in the scene.

Let us know how you go.

Blacky :smiley:

@hazio

This sounds like a lack of communication between your motion sensor and HA. If you would like me to check your settings then can 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:

Thanks for your prompt reply and support.
I will add one of my Hue lights that is part of the scene as a separate entity on top of the scene. I will let you know if it works…

Don’t forget it is also Christmas Holliday for you :christmas_tree:, so no problem if you will not respond coming day’s :slightly_smiling_face:

Find it strange that it worked perfectly fine for the past 2 months without modifying it, then randomly stopped functioning properly. It could be my motion sensor giving way (battery seems fine), which I hope it isn’t the case. ;(

Here’s the code:

alias: Sensor - WC Light
description: ""
use_blueprint:
  path: Blackshome/sensor-light.yaml
  input:
    motion_trigger:
      - binary_sensor.wc_motion
    light_switch:
      entity_id: light.wc_light
    time_delay: 2
    include_light_control:
      - use_transition
    include_dynamic_lighting:
      - enable_dynamic_lighting_brightness
    include_sun: sun_enabled
    people: []
    include_night_lights: night_lights_enabled
    night_lights:
      entity_id: light.wc_light
    include_night_light_control:
      - use_transition
    night_light_brightness: 50
    night_lights_conditions:
      - sun_enabled
    night_lights_before_time: "07:00:00"

Thanks

@Blacky Legend! Seems to be working.

@mars2020

Thanks Mars :crossed_fingers: hope is works for you now.

Blacky :smiley: