Last active
December 8, 2022 18:36
-
-
Save garanda21/4c92851772204d3dfdb777b6832743a2 to your computer and use it in GitHub Desktop.
Turn a light or switch on based on detected motion when sunrise or sunset conditions are meet and turn light or switch off after a delay
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
blueprint: | |
name: Motion Light with sunrise and sunset conditions (after or before) | |
description: Turn a light on based on detected motion when sunrise or sunset conditions | |
are meet and turn light off after a delay | |
domain: automation | |
input: | |
motion_sensor: | |
name: Motion Sensor | |
description: This sensor will be synchronized with the light. | |
selector: | |
entity: | |
domain: binary_sensor | |
device_class: motion | |
multiple: false | |
target_light: | |
name: Lights or Switchs | |
description: The lights or switch to keep in sync. | |
selector: | |
target: | |
entity: | |
domain: | |
- light | |
- switch | |
offset_sunrise: | |
name: Sunrise offset | |
description: 'Offset time until sunrise triggers. | |
For trigger before sunrise use negative values eg: "00:-30:00" meaning 30 | |
minutes before sunrise. | |
For trigger after sunrise use positive values eg: "01:00:00" meaning 1 hour | |
after sunrise.' | |
selector: | |
duration: {} | |
offset_sunset: | |
name: Sunset offset | |
description: 'Offset time until sunset triggers. | |
For trigger before sunset use negative values eg: "00:-30:00" meaning 30 minutes | |
before sunset. | |
For trigger after sunset use positive values eg: "01:00:00" meaning 1 hour | |
after sunset.' | |
selector: | |
duration: {} | |
delay_off: | |
name: Delay | |
description: 'Time to wait before turn lights off after motion stops detection. | |
Keep in mind that some motion sensor has it''s own time to change from ''on'' | |
to ''off'' mostly 90 seconds, so maybe you wanna to add the delay to this | |
time' | |
default: 120 | |
selector: | |
number: | |
min: 0.0 | |
max: 3600.0 | |
unit_of_measurement: seconds | |
mode: slider | |
step: 1.0 | |
source_url: https://gist.github.com/garanda21/4c92851772204d3dfdb777b6832743a2 | |
mode: restart | |
max_exceeded: silent | |
trigger: | |
- platform: state | |
entity_id: !input motion_sensor | |
from: 'off' | |
to: 'on' | |
condition: | |
- condition: or | |
conditions: | |
- condition: sun | |
before: sunrise | |
before_offset: !input offset_sunrise | |
- condition: sun | |
after: sunset | |
after_offset: !input offset_sunset | |
action: | |
- service: homeassistant.turn_on | |
target: !input target_light | |
- wait_for_trigger: | |
platform: state | |
entity_id: !input motion_sensor | |
from: 'on' | |
to: 'off' | |
- delay: !input delay_off | |
- service: homeassistant.turn_off | |
target: !input target_light |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment