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

Has the turn off function been updated to work on scenes? I dug through a majority of this thread and the only thing I could find was back in December of '20 indicating that the turn off function only worked for switches and lights. I’m required to use a scene for the turn on function as the light switch is dimmable.

If the turn off function doesn’t work for scenes, what’s the solution in turning off the light switch after the delay has been met?

You can define the wait timer by clicking the settings menu up in the upper right of the number helper dialogue box and select the number of minutes there.

Hello, thanks for this template, it looks great.
There is however something not clear to my by reading the template description. Is it necessary to define a timeout in order to turn off the lights after motion is detected? My use case is: when motion is detected, turn on lights, keep them on as long as motion is detected. When no motion then turn them off.
Is this template suitable for this use case?
Thanks

Another question: why use intermediare input entities rather than picking the raw values on the blueprint configuration? It is a bit annoying to have to create separate entities, display them on lovelace and then go there and setup them on a separate place. Is it a limitation of HA or something?

Is there any chance you could tell me how I could tweak the blueprint to allow for the turn off wait time to work for scenes? I don’t care for illuminance as my motion detectors have their own built in hardware sensor for that.

This blueprint does not support that scenario, unfortunately.

Take another look at the first post in the examples for the helpers. The time limits are input_datetime’s and the wait time before the entity turns of is an input_number.

To turn off entities/lights that are part of a scene, set the entity that you want to turn off as the target_off_entity. If it concerns multiple entities, create a group for them and set this group as the target_off_entity.

I expect if you set the no_motion_wait helper entity to 0, the entity will turn off as soon as no more motion is detected. However, I wonder how useful this is if your motion sensor has a low cooldown time.

The use of helper entities is a design choice I made for this blueprint. However, you do not have to display them on lovelace in order to set them. You can set entity values from the developer tools page in Home Assistant.

In mi case it is because most of my motion sensors are baterry powered, and have a big cooldown time

Maybe I misread something, But I cannot figure out what I’m doing wrong:
I have the most simple automation with a door sensor.
If the door opens, a light should turn on inside the house.
When the door closes the light should stay on for a minute.
My Settings:
Motion sensor: door sensor
Target entity: light inside the house:
(OPTIONAL) Turn off wait time (minutes): 1
everything else is not filled in.

When the door opens my light turns on. But when I close the door the light turns of directly and doesn’t wait for 1 minute.
I can set the turn of wait time to 1, 5 or 10, the light always turns of directly when the door closes.

my automation file:
use_blueprint:
path: freakshock88/motion_illuminance_activated_entity.yaml
input:
motion_sensor: binary_sensor.deur_sensor_houthok_access_control_window_door_is_open
target_entity: switch.sfeerlamp_hoek
no_motion_wait: ‘1’

You probably need to set no_motion as a helper entity. See Input Datetime - Home Assistant

But I am still struggling a bit too to get this blueprint working :wink:

be good to have the option for only turn the lights on when the sun is set/before sunrise. rather than/in addition to a fixed time, for those who don’t have illuminance sensors.

Tried it, didnt’t work. I know use the blueprint from the link below. Also set a no_motion delay and that works. So I think there is something wrong with this blueprint.

@thefunkygibbon I use this one with sunset and sunrise. and there the no_motion delay works fine.
https://community.home-assistant.io/t/turn-light-on-and-off-based-on-detected-motion-with-sun-condition/266013/10

There is not something wrong with this blueprint, otherwise we would have more complaints :wink:

Like @beurdy said, you cannot use hardcoded values for the no_motion_wait variable. You need to use an input_number helper enttity, this is described in the first post.

In the end the automation would then look something like:

  - alias: Turn on hallway lights on motion detected
    initial_state: true
    use_blueprint:
      path: freakshock88/motion_illuminance_activated_entity.yaml
      input:
        motion_sensor: binary_sensor.motion_sensor_hallway_occupancy
        target_entity: switch.shelly_hal_relay_0
        no_motion_wait: input_number.hallway_no_motion_turn_off_delay

I think there are plenty of other blueprints what support the sunrise/sunset scenario.
If I would add it also to this only it would become a bloated mess I’m afraid.

Yes I am sure. I have changed the target entity to multiple things. Originally I made a scene that would do multiple things once activated but when it was activating any time motion was detected I tried simplifying it with a couple different lights and outlets (one after the other, not all at once). But no matter what time I put in the input_datetime I couldn’t get this blueprint to fire correctly. I ended up makeing a automation that triggers a script. The automation is like this (i’ll post the script below it):

alias: Weekday Wakeup
description: ''
trigger:
  - platform: state
    entity_id: binary_sensor.lr_motion
    to: 'on'
condition:
  - condition: time
    after: input_datetime.wake_time
    before: input_datetime.end_wake_time
    weekday:
      - mon
      - tue
      - wed
      - thu
      - fri
action:
  - service: script.wakeup
mode: single

…and the script is below (it turns on various WLED instances, opens youtube on the TV and a few other things but most importantly it turns off the above automation, otherwise additional motion would continue triggering the automation. There is also a 3rd automation which simply turns on the above automation everyday at 4am (it doesn’t trigger it, just turns it on and makes it available for when motion is detected):

sequence:
  - service: media_player.turn_on
    target:
      entity_id:
        - media_player.main_tv
        - media_player.roku_streaming_stick
  - delay:
      hours: 0
      minutes: 0
      seconds: 4
      milliseconds: 0
  - service: media_player.select_source
    target:
      entity_id: media_player.roku_streaming_stick
    data:
      source: YouTube
  - delay:
      hours: 0
      minutes: 0
      seconds: 10
      milliseconds: 0
  - service: remote.send_command
    target:
      entity_id: remote.roku_streaming_stick
    data:
      command: left
      delay_secs: 1
  - service: remote.send_command
    target:
      entity_id: remote.roku_streaming_stick
    data:
      command: select
      delay_secs: 1
  - device_id: 1367990c3a2e022f22f0c40ed01641d0
    domain: select
    entity_id: select.wled_coolclock_preset
    type: select_option
    option: twelve
  - device_id: d0d6487fde13b0088a56e7a1f09d7da0
    domain: select
    entity_id: select.wled_lamp_preset
    type: select_option
    option: Third
  - service: scene.turn_on
    target:
      entity_id: scene.brighter_morning
    data:
      transition: 295
  - service: light.turn_on
    target:
      entity_id: light.cam3_feeder_level_indicator
    data:
      brightness: 165
      transition: 300
  - service: automation.turn_off
    target:
      entity_id: automation.weekday_wakeup
mode: single
alias: wakeup

these were built with the visual editor and could probably be condensed and simplified but it was my work around at the time back in June and has worked reliably since then.

Trying to set-up this Blueprint for the first time. Want to use the illuminance sensor but when I select the picker it shows “No matching entities found”. I have 3 different sensors that all support luminance.

Can someone help. The blueprint works however the sensor I use is a door sensor. Unfortunately the automation runs when I close the sensor/door, when I actually want it to turn on when opening door. So can I get it to work the other way around? Any advice appreciated.