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

It looks like the Scenes work fine now (they turned off during day-time), but the entities did not turn off.

I will keep an eye on it and give you an update coming day’s about how it goes.

1 Like

Blacky,
I just wanted to say thank you, I was trying to figure out how to turn on a set of lights based on 2 occupancy sensors detecting presence, and found this post, and figured it out. Kudos Sir, should definitely add this in the FAQ, I would guess other people using MMwave sensors with multiple zones this information will come in handy! Once again Thank you!!

1 Like

No problem at all and thanks for your kind words :smiling_face_with_three_hearts:

Blacky :smiley:

I had the same issue until I stumbled across this post. I tried it out and it works great!

Thanks for the blueprint and posting this easy fix.

One thing I noticed when I open the shower door the lights turn off and turn back on again when motion sensor picks up movement. Any idea how to fix it?

Actually I spoke too soon, the wife wants me to make a change. I currently have it where if Sensor 1 and Sensor 2 are triggered to on, the light turns on. Now She wants me to change it where if the above logic gets triggered, and if Sensor 2 is cleared (No occupancy) to keep the light on until Sensor 1 and Sensor 2 are clear
So in other words
S1 =on, S2 = Off Then the light is off
S1 =on, S2= on, Then the light is on Now because of this trigger, if S1 =on, S2=off then to stay on until S1=off & S2 = Off

Is that Possible?
Here is my Template sensor currently:

template:
  - trigger:
      - platform: state
        entity_id: binary_sensor.kitchen_presence_sensor_presence_sensor_1
        to: "on"
      - platform: state
        entity_id: binary_sensor.kitchen_presence_sensor_presence_sensor_1
        to: "off"
      - platform: state
        entity_id: binary_sensor.kitchen_presence_sensor_presence_sensor_5
        to: "on"
      - platform: state
        entity_id: binary_sensor.kitchen_presence_sensor_presence_sensor_5
        to: "off"

    binary_sensor:
        - name: "Kitchen Stove and main Occupancy Sensors"
          device_class: occupancy
          icon: mdi:motion-sensor
          state: >
            {% if is_state('binary_sensor.kitchen_presence_sensor_presence_sensor_1', 'on') and is_state('binary_sensor.kitchen_presence_sensor_presence_sensor_5', 'off')  %}
              off
            {% elif 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 is_state('binary_sensor.kitchen_presence_sensor_presence_sensor_1', 'off') and is_state('binary_sensor.kitchen_presence_sensor_presence_sensor_5', 'off') %}
              off
            {% endif %}

@ruaandeysel

No problem, your welcome.

Just put in a delay. ON or OFF. Below is an example with the ON delay @ 10 seconds. Change to your liking.

binary_sensor:
  - platform: template
    sensors:
      shower_door:
        friendly_name: "Shower Doors"
        device_class: door
        icon_template: mdi:door
        value_template: >-
          {{ is_state('binary_sensor.your_shower_door_sensor_here', 'off')
        delay_on:
          seconds: 10

You can also look at this blueprint :shower: Bathroom Humidity Exhaust Fan it will do what you are trying to do and more. Have a look at the FAQ - My set up.

Blacky :smiley:

1 Like

Try this

template:
  - trigger:
      - platform: state
        entity_id: binary_sensor.kitchen_presence_sensor_presence_sensor_1
        to: "on"
      - platform: state
        entity_id: binary_sensor.kitchen_presence_sensor_presence_sensor_1
        to: "off"
      - platform: state
        entity_id: binary_sensor.kitchen_presence_sensor_presence_sensor_5
        to: "on"
      - platform: state
        entity_id: binary_sensor.kitchen_presence_sensor_presence_sensor_5
        to: "off"

    binary_sensor:
        - name: "Kitchen Stove and main Occupancy Sensors"
          device_class: occupancy
          icon: mdi:motion-sensor
          state: >
            {% if 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 is_state('binary_sensor.kitchen_presence_sensor_presence_sensor_1', 'off') and is_state('binary_sensor.kitchen_presence_sensor_presence_sensor_5', 'off') %}
              off
            {% endif %}

Unfortunately it’s not working. Scenes work fine now (they turned off during day-time), but the entities did not turn off.
Looks like a bug……

Afraid it’s not working, when Sensor 5 clears it still turns off the light :frowning: :face_holding_back_tears:

Hello everyone this is a very powerful tool. I would still be missing the ability to control RGB devices. I would be happy if this was taken into account in one of the next updates

@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