Turn on light, switch, scene, script or group based on motion, illuminance, sun (+ more conditions)

@MrRodz and @andyz I figured out a quick way to make the blueprint work by calling it from another automation. Here’s the sample yaml:

alias: Bathroom Lights Motion Trigger
description: ''
trigger:
  - platform: state
    entity_id: binary_sensor.lumi_lumi_sensor_motion_aq2_7cb4b706_ias_zone
    from: 'off'
    to: 'on'
    for: '.5'
condition: []
action:
  - service: automation.trigger
    data: {}
    target:
      entity_id: >-
        automation.turn_on_light_switch_scene_script_or_group_based_on_motion_and_illuminance
mode: queued
max: 10

In plain english, I created a script based on this blueprint with my Aqara motion sensor and set up the obvious logic. I called this first one “Bathroom Light Motion Actions” and then created a second automation called “Bathroom Light Motion Trigger” (above) that triggers the blueprint automation after .5 seconds of motion. Might can get away with less than that even.

This gives the Aqara sensor a brief moment to get an illuminance reading before doing the “less than” logic.

For reference my “Bathroom Light Motion Actions” below:

alias: Bathroom Light Motion Actions
description: ''
use_blueprint:
  path: freakshock88/motion_illuminance_activated_entity.yaml
  input:
    motion_sensor: binary_sensor.lumi_lumi_sensor_motion_aq2_7cb4b706_ias_zone
    target_entity: light.brass_lamp_level_light_color_on_off
    illuminance_sensor: sensor.lumi_lumi_sensor_motion_aq2_7cb4b706_illuminance
    illuminance_cutoff: '22'
    no_motion_wait: '10'

1 Like

In the YAML example code you have " Bedroom lights no longer turn of before this time"

Shouldn’t it be “lights turn on” ?

1 Like

this does not work for me. Trying to set a simple automation that activates a script which turns on the main tv and turns off a nightlight if motion is detected between 4:15am and 6:00am. I set the input helper times but the automation turns on the tv no matter what time it is. what am i doing wrong? i tried removing the script and just added the tv device but that also turns on anytime motion is detected, no within the timeframe set by the input helpers

alias: weekday wakeup
description: ''
use_blueprint:
  path: freakshock88/motion_illuminance_activated_entity.yaml
  input:
    motion_sensor: binary_sensor.lr_motion
    time_limit_after: input_datetime.wake_time
    time_limit_before: input_datetime.end_wake_time
    target_entity: script.wakeup`

Are you sure you dont have any other (old) automations to turn on the tv of run the script when the binary_sensor.lr_motion turns on? You can check your home assistant Logbook to see if any automations are triggering when the motion sensor is tripped.

I have the same issue. Did you solve it?

Hi @freakshock thanks so much for your blueprint. Are you able to add a way to delay turning on the entity?

Top blueprint!
I try to set lux value but it seems it doesn’t work. Do you have any idea ?

I’m having a problem with this blueprint. If the light is turned off by another means the automation stops working.

is there a way to set Turn off wait time less that a minutes?

I think I could use a little help with this. I imported this blueprint, and ran actions, and out of all of the several here, this is the ONLY one that turned on my GE zwave light switch.
I have a smartthings motion sensor, and it shows up on cards as Clear and Detected for motion. So for the life of me I can’t get the BP to register the motion sensor telling the switch to come on. I’m no coder, but it seems like the BP is looking for diff input.
Thanks in advance!

You can try defining the input number with a lower minimum value than 1.
For instance, if you want the turn off wait time to be 30 seconds, the value of the input number should be 0.5.

The blueprint expects the triggering entity to have a state ‘on’ when there is motion.

You can check the exact state in the developer tools in Home Assistant, when motion is detected. This state is not the same as what the lovelace frontend says (like ‘Detected’).

The developer tools can be found in the left menu of Home Assistant, when go to the states page and find the entity that you want to be your triggering entity. And see what the state is the moment that motion is detected. If it is ‘on’, then that entity should be compatible with this blueprint.

Ok, I actually got it working. Sorry, Just pretty new to this, so big learning curve. Question: Can a certain helper, I have one that set the delay time in minutes input_number.waittime. Can this exact helper be used elsewhere in another automation/blueprint, or does this helper in this automation(yours) only work here?
I’m wondering if I set it in another different automation, if its possible the value in one automation becomes the same across all automations. Or is that not how it works. Thanks!

No worries!

If you define an input_number helper entity, it can be used anywhere.
It is an independent entity not bound to this blueprint/automation.
So you can reuse it, if you want to use the same value also in other automations/scripts etc.

Great. Thanks for the info. It’s been a job so far, building back the automations I had in smartthings, so I can wean off of it. Only a few more to go :slight_smile: Thanks again for the work on the blueprint! … it’s taught me quite a bit so far, and easier for me to learn by working with whats there and expanding from there. :slight_smile:
I still don’t know why yours is the only one out of maybe 3-4 others here, similar, that will turn on my light. Oh well.

Another question as well. In the blocking entity, can I use another motion sensor, and as I think that as that 2nd motion sensor picks up motion, it will -not- allow the automation to turn the light off after wait time. However, if the blocking entity clears, (off), will the automation then start the waittime countdown, or just shut it off immediately after the blocker clears, or does clearing the blocker start the waittime counter ?
Thanks!

Just as a note, at least in the lovelace dashboard, if I used the same entity in 2 diff cards, when i built the second card, if I changed that entity in one card, it changed -both- entries in both cards…, so changing
input_datetime.add_time_after in one card, changed it in the second card.

Won’t work as you are casting it to int so it will be converted to floor value 0.

Answered my own question. Added a second motion detector IN the kitchen, so after motion clears that one, the automation starts the timer. :slight_smile:

How to open multiple light entities ?Motion sensing triggers multiple entities