šŸ’” Sensor Light - Motion Sensor - Door Sensor - Sun Elevation - LUX Value - Scenes - Time - Light Control - Device Tracker - Night Lights

Hi,
I’m trying to achieve a very specific logic and I’m not sure if it’s possible with the current version of the blueprint.

Here is the behavior I want:
The light should turn ON only if both my occupancy sensor and my motion sensor are ON.
If the motion sensor turns OFF but the occupancy sensor stays ON, the light should remain ON.
The light should turn OFF only when the occupancy sensor goes OFF.

So the occupancy sensor is the ā€œmasterā€, but motion is required to initially trigger the light.

Since I couldn’t find a way to do this directly in the blueprint, I built a workaround:

  1. Created an input_boolean to store the combined state (ā€œlatchedā€ ON until occupancy is OFF).
  2. Created two automations to manage this logic.
  3. Created a template binary_sensor linked to the input_boolean, because the blueprint only accepts binary sensors.
  4. Used this template binary sensor as the motion trigger inside the blueprint.

It works, but it feels like an overcomplicated setup (ā€œa bit of a factoryā€), just to achieve a simple conditional ON + latched behavior.

My questions are:
Is there a simpler way to do this directly in the blueprint that I might have missed?
If not, is this kind of combined/conditional trigger logic something that could be added as a feature in a future version?

Thanks a lot for your work, this blueprint is great and adding this flexibility would make it even better!

@Brissedgar

Welcome to the community.

Before I get into detail I think this will be the best and easiest way.

Group your sensors: If any sensor is ON the group is ON. We use this when we have a device that provides motion and an occupancy sensor. The reason being is motion is fast to detect motion and occupancy is better for keeping it ON. Once you leave the room both should go OFF and then the time delay starts.

The how to group them FAQ is here. Click here

Blacky :grinning:

Thanks for your reply and for the suggestion.

I did consider grouping the sensors, but unfortunately it doesn’t solve my issue.
The problem is that my occupancy sensor sometimes produces false positives. The bathroom door is located in a hallway, and when someone walks close to it, the occupancy sensor occasionally switches to ON even though nobody is actually entering the bathroom.

I have already tried everything I could to reduce these unwanted triggers, but they still happen from time to time.
Because of this, I really need a strict AND condition:
the light should only turn ON when both occupancy and motion are ON at the same time. But stay ON if one of them are ON.

Edgar

@Brissedgar

Okay. I am getting two scenarios and I not sure what one you would like.

Ether option you will create a template binary sensor helper and use it as the trigger only.

  1. Go to Settings > Devices & Services > Helpers.
  2. Click ā€œ+ Create Helperā€ and choose Template > Binary sensor.
  3. Set a Name for your new binary sensor.
  4. In the State template field, paste the code below.
  5. Replace input_boolean.occupancy with the actual entity ID or your occupancy sensor.
  6. Replace input_boolean.motion with the actual entity ID or your motion sensor.
  7. Tricky Part: Save it to get the entity ID of this helper. Then use that ID and replace binary_sensor.this_helper_id with the actual entity ID or this helper.

First one

This will turn ON when both are ON and only turn OFF when the occupancy sensor goes OFF.

It is a trick one as you have to reference the helper ID and you must create it first.

{% set occ = is_state('input_boolean.occupancy', 'on') %}
{% set mot = is_state('input_boolean.motion', 'on') %}
{% set helper = is_state('binary_sensor.this_helper_id', 'on') %}

{% if not occ %}
  off
{% elif occ and mot %}
  on
{% elif occ and helper %}
  on
{% else %}
  off
{% endif %}

Second One

Turn ON when occupancy and motion are ON but only turn OFF if both occupancy and motion are OFF.

Same as above tricky as you have to reference the helper ID and you must create it first.

{% set occ = is_state('input_boolean.occupancy', 'on') %}
{% set mot = is_state('input_boolean.motion', 'on') %}
{% set helper = is_state('binary_sensor.this_helper_id', 'on') %}

{% if occ and mot %}
  on
{% elif helper and occ or mot %}
  on
{% else %}
  off
{% endif %}

Let us know how you go.

Blacky :grinning:

1 Like
alias: Kitchen Motion Lights
description: ""
use_blueprint:
  path: Blackshome/sensor-light.yaml
  input:
    motion_trigger:
      - binary_sensor.everything_presence_lite_73c3ac_zone_2_occupancy
    light_switch:
      entity_id:
        - switch.relay_kitchen_leds
        - switch.ikea_of_sweden_tretakt_smart_plug_2
    time_delay: 0
    include_bypass:
      - bypass_enabled_turn_on
      - bypass_enabled_turn_off
      - bypass_enabled_stop
    motion_bypass_lights_on:
      - input_boolean.kitchen_lights_bypass_on
    motion_bypass_lights_off:
      - input_boolean.kitchen_lights_bypass_off
    motion_bypass_lights_stop:
      - input_button.kitchen_lights_bypass_keep

Thanks for your help. I had created a new automation from your blueprint but that didn’t fix it

Hi
Fiirst of all, thanks for this blueprint !
I’ve got one question.

When switching from Night mode (let’s say with lights in blue) to Day mode, when lights are already on, they don’t return back to the color (white) defined as per the day mode. Is there a way to force the lights take the settings from day mode when the night mode is disabled (or enabled) ?
Thanks

No, that is exactly what I was asking.
I was not expecting it to be nested, I was looking for it in the top level.
I just set it up, let’s see how it goes.

Thank you very much

1 Like

@Shotty_Gunny

Everything looks good. Just a not is any one of the 3 bypasses are ON the automation will not run and turn your lights ON.

Blacky :grinning:

@looic78

Yes, in Night Light Control under Night Lights - Light Control Options select If lights are ON, adjust the lights when crossing over and you be all good.

Blacky :grinning:

1 Like

Hi @Blacky and all:

First of all appreciate your work and sharing with the community! I have configured the automation for all my hue sensors and it works very well!
I have 2 feature requests hope you can consider:

  1. For ambient light settings would be nice to allow to define the light is above or below threshold for XX minutes. In cloudy days my hue sensor is too sensitive and it just turns the light on and off all the time, and this can hopefully help with the situation (I already have a big gap for my high and low threshold)
  2. One thing I like with Hue motion automation is that it dims the light for 1 minute to remind the user light is about to turn off before it actually turns off the light. This could potentially be useful in some scenarios.

Hope you can consider the feature requests, have a great day!

@maisun

Thanks for you kind words.

  1. This is on my list to do.
  2. Your going to like the next release… this is all done and tested.

Blacky :grinning:

1 Like

Wow, amazing work! Very much look forward!!!

My friend, your blueprints have made such a difference to my home. Donation to follow!

I’ve just discovered this incredible blueprint and am starting to work it into existence in my setup. After reading through the FAQ and enough posts to make my eyes go crossed, wanted to see if I could clarify a few of my understandings so I can get this right.

For the setup, I’ll be using it to control LED strip under cabinet lighting driven by a WLED controller and based on a PIR motion sensor (possibly combined with the lux sensor in it). Might go Presence Sensor later, but to start.

Since it’s WLED and an RGBWWC strip (single zone, not IC), I set 3 Presets for the different colors and brightness depending on time of day (or light level). My understanding from reading is the way to use presets is to set them as scenes and call from the blueprint automation. But what I’m curious about is would there be anything gained from retrieving the RGBW values from my presets and just putting them in the blueprint vs calling scenes? Still pretty new to HA, so wasn’t sure if there would be any performance to be gained by that.

My second question is around triggering the different presets based on the parameters. Would each scenario I’m using be a separate automation, or can it be included in one? Let’s say just using time of day as an easy start. If I want a certain preset to call by time of day (so late night it’s my low glow preset which is a nice Indiglo shade on very low power), do I make a separate automation for each time block, or am I missing a way to define that within the blueprint automation?

In a perfect world, I’ll use light levels and have the power and color/temp of the LEDs base on that, but while I’m still learning things, will probably start with time of day.

@benflux

Thanks so much, Ben, for your generous donation. I truly appreciate it. It means a lot to know that the time and effort put into this blueprint is valued. We all invest in different lights and devices, but without good automations they’re really just simple switches. Thank you again for your support… it genuinely motivates me to keep improving my work.

Blacky :grinning:

@Moebius01

First question
For me I like to use entities and set the RGBW (my led lights with WLED). If all your lights are the same colour and brightness then I would use RGBWW with brightness. If you have lights at are all different colours and brightness then scenes are the way to go. Using entities with the light control works so much better and allows you to use all the options.

Second question
In this blueprint you have Lights (AKA normal lights) and night lights. In night lights you also have a glow light (lights stay ON when night lights are active). What you can do is set up your normal lights you would like during the day. Then enable night lights using the night lights time option. Then set up your night lights for the lower brightness. If you have or want a glow light when night lights are active then enable this option and set up your glow lights. Try using entities first and set all your brightness and colours within the blueprint. One option to select is in Night Lights - Light Control Options and enable If lights are ON, adjust the lights when crossing over.

I use WLED and HA has WLED in the open home foundation now. Maybe I should look at an option to use WLED presets :thinking:

Blacky :grinning:

1 Like

New update 8.5

Your lighting experience, your way – take control and customize it to perfection! :bulb::sparkles:

:new: New Features

This has been a very popular feature request, and now it’s here! :partying_face:

  1. Dim Before OFF Option

    This option allows you to dim the lights as a visual warning before they turn OFF. It gives you time to trigger the motion sensor if you want the lights to stay ON.

    You can find this new option in Light Control and in Night Light Control.

  2. Ambient - Lux Time Delay

    You now have an option to use a Low & High Lux Time Delay.

    Low: Set how long the ambient light level must remain below the Low Lux Value before the condition is met. This helps prevent the lights from turning ON due to brief dips in lux.

    High: Set how long the ambient light level must remain above the High Lux Value before the ambient condition is met. This helps prevent the lights from turning OFF due to brief spikes in lux.


:bug: Bug Fixes

  • Bug in night glow when not using transition and using different lights. Light that where different would stay ON or not turn OFF.

:toolbox: Maintenance

  • Cleaned up the bypass auto OFF conditions.
  • Some descriptions update.

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:

Thanks @Blacky - that seems to do the trick, though sometimes it’s not working - light goes off despite thecroom being occupied. I actually had on my old system a logic that compared the times when the motion sensor was triggered vs the door sensor. This was fool proof and didn’t require me to set a timer. Do you think this would work in HA as well?

Hi Blacky,
Can you add a Night glow start and end time or a helper entity to enable/disable the night glow option?

This is a big update blacky thank you. I think it’s time for another donation. Can you remind me where the link is?