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

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

I had the same problem as someone above… for whatever reason, automations won’t span past midnite. I ended up making on for before 23:59 and then another starting after 00:01. I read somewhere else that HA won’t run through the midnight hour, on time alone.
I don’t know if you’d be interested in expanding the blueprint, but what about adding in an option for starting before sunrise and after sunset?
Thanks!

I’m a bit confused. Can someone tell me how I can set the lights to auto turn off after 10 seconds? Motion sensor will trigger it on again, but the automation should always try to turn off light when no motion is detected.

Thanks

Same issue here, cant get past midnight with this blueprint. ie on from 07:00 till 01:00 (the next day),
I think it has nothing to do with HA, the below automation part works flawlessly:

  - condition: and
    conditions:
    - condition: time
      after: 07:30:00
      before: 02:30:00
  action:
  - type: turn_on

must be some compare issues in the blueprint.

Regards Frank.

Ok, for the middle night time, after sunset and before sunrise, I did the timer thing. I think it was bearded tinkerer, but here’s something that works for me. The motion sensor, being activated while the timer is running, resets the timer, and the timer will continue as long as there is no more motion, and finish off (turn light off) after the required time. Only thing here that doesn’t play nice, if 2 timers are running, both fire off the automations, even if the longer scheduled timer hasn’t finished. Haven’t looked into that yet. But here’s one :slight_smile:

After light is triggered on -

alias: Front Door Lamps timer starts after turning on
  description: Front Door Lamps timer starts after turning on
  trigger:
  - platform: state
    entity_id: switch.fluorescent_light_appliance_module
    to: 'on'
  condition: []
  action:
  - service: timer.start
    data:
      duration: '0'
    target:
      entity_id: timer.front_door_open
  mode: single

And then, to turn off after timer is done -

alias: New Door lamps off after 4 minute timer
  description: New Door lamps off after 4 minute timer
  trigger:
  - platform: event
    event_type: timer.finished
    id: timer.front_door_open
  condition: []
  action:
  - type: turn_off
    device_id: 394d5d8b79e6712205801db1626790c5
    entity_id: switch.fluorescent_light_appliance_module
    domain: switch
  mode: single

and in configuration.yaml, must set a timer duration -

timer:
  front_door_open:
    duration: 00:04:00
    name: Front Door Timer 4mins
    icon: mdi:door-open

This works for me, at least to turn off the light after the light is triggered on.
I just realized that this is not what we were originally talking about, so here’s the motion timer code -
This turns the lights on, at the window of time, it works prior to and then after midnight -

Timers for kitchen light-

alias: Kitchen Light timer starts
  description: Kitchen Light timer starts
  trigger:
  - platform: state
    entity_id: binary_sensor.front_room_motion_sensor
    to: 'on'
  - platform: state
    entity_id: binary_sensor.kitchen_motion_zone
    to: 'on'
  condition:
  - condition: or
    conditions:
    - condition: time
      after: '21:00'
    - condition: sun
      before: sunrise
  action:
  - service: timer.start
    data: {}
    target:
      entity_id: timer.kitchen_light_timer
  - type: turn_on
    device_id: 4856f51b9d4f30ebc0d25c555496a473
    entity_id: switch.kitchen_light
    domain: switch
  mode: single
  max: 10

################################################

  alias: Kitchen timer ends-light off 7 mins
  description: Kitchen timer ends-light off 7 mins
  trigger:
  - platform: event
    event_type: timer.finished
    id: timer.kitchen_light_timer
    event_data: {}
  condition: []
  action:
  - type: turn_off
    device_id: 4856f51b9d4f30ebc0d25c555496a473
    entity_id: switch.kitchen_light
    domain: switch
  mode: single

I am using this blueprint for an automation to turn a (Lutron Caseta) switch on whenever motion is detected (via a Philips Hue Motion Sensor) and while turning on works, the “(OPTIONAL) Turn off wait time (minutes)” appears to have no effect at all.

Basically I set its value for my automation to 5 and yet, after a few seconds the light is turned off again by the automation. There is no concurrent automation using the motion sensor and I am a bit confused what I might be doing wrong here?

The settings look like this & any hints / suggestions are highly appreciated!

You need to create an input_number entity with the value of your timeout for it to work.

nice blueprint

Since a few people have complained about issues with the blueprint not triggering when time window spans midnight, I tried to rewrite the time condition to see if this helps.

I myself could never reproduce this however with the old version of the blueprint, so I’m not sure if this new version makes any difference.

Please test it out if you like.

Thank you, will do,

Maybe it has to do with 12 or 24 hour settings?
I my self use the 24h mode.

Regards Frank

Thanks for this, it’s been running quite nicely except the same time issues people had.
I anyhow decided to run my hours by modes Day/Evening/Night toggled by a set time or manually (typically by the gf), instead of Time Start and End.
So I modified a copy of your code with an extra optional “Day / Evening / Night” mode requring it’s state to be on to run.
#happyuser

Hai freakshock,

I can confirm that the midnight spanning is now working.
Great Job, Thank you…!!

Regards
Frank

1 Like

Hi, Frank,
Could you please add a brightness slider for those who have dimmer switches?
Thank you!
I added this line manually to the bluebrint, but thats the best I could do

action:
- service: homeassistant.turn_on
  data:
    brightness_pct: 10
  entity_id: !input 'target_entity'
- condition: template

See this post for a solution.