Last active
September 14, 2021 17:57
-
-
Save anarro/512138f39ebc579f821195449b15d833 to your computer and use it in GitHub Desktop.
blueprint light motion sunset plus
This file contains 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-activated Light On at Sunset Plus | |
description: Turn on a light when motion is detected On At Sunset. | |
domain: automation | |
source_url: https://gist.github.com/anarro/512138f39ebc579f821195449b15d833 | |
# Blueprint Inputs | |
input: | |
motion_entity: | |
name: Motion Sensor | |
selector: | |
entity: | |
domain: binary_sensor | |
device_class: motion | |
elevation_shift: | |
name: Elevation Shift | |
description: Using an elevation offset (height of sun relative to the horizon) to shift the sunset trigger, either earlier or later. Positive values bring the automation start time forward, whilst negative values delay the start time. | |
default: 0.0 | |
# Use a selector, to set the time shift or offset | |
selector: | |
number: | |
min: -10.0 | |
max: 10.0 | |
mode: slider | |
step: 1.0 | |
target_light: | |
name: Lights | |
description: This is the light (or lights) that will be activated at sunset | |
selector: | |
target: | |
entity: | |
domain: light | |
target_brightness: | |
name: Brightness | |
description: Brightness of the light(s) when they're activated | |
default: 50 | |
selector: | |
number: | |
min: 5.0 | |
max: 100.0 | |
mode: slider | |
step: 5.0 | |
unit_of_measurement: '%' | |
target_color_temp: | |
name: Temperature | |
description: Termperature of the light(s) when they're activated | |
default: 280 | |
selector: | |
number: | |
min: 153 | |
max: 454 | |
mode: slider | |
step: 1 | |
no_motion_wait: | |
name: Wait time | |
description: Time to leave the light on after last motion is detected. | |
default: 120 | |
selector: | |
number: | |
min: 0 | |
max: 3600 | |
unit_of_measurement: seconds | |
condition_state: | |
name: Previous Light condition. | |
description: Previous state of the light to run the scheduled. | |
action | |
default: 'off' | |
# If motion is detected within the delay, | |
# we restart the script. | |
mode: restart | |
max_exceeded: silent | |
variables: | |
target_brightness: !input 'target_brightness' | |
target_color_temp: !input 'target_color_temp' | |
target_id: !input 'target_light' | |
condition_value: !input 'condition_state' | |
trigger: | |
platform: state | |
entity_id: !input motion_entity | |
from: "off" | |
to: "on" | |
condition: | |
- condition: numeric_state | |
entity_id: sun.sun | |
attribute: elevation | |
below: !input elevation_shift | |
- condition: template | |
value_template: "{{ is_state(target_id, condition_value) }}" | |
action: | |
- service: light.turn_on | |
target: !input target_light | |
data_template: | |
brightness_pct: '{{ target_brightness | int }}' | |
color_temp: '{{ target_color_temp | int }}' | |
- wait_for_trigger: | |
platform: state | |
entity_id: !input motion_entity | |
from: "on" | |
to: "off" | |
- delay: !input no_motion_wait | |
- service: light.turn_off | |
target: !input target_light |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Blueprints for Home Assistant
This repository contains some blueprints for Home Assistant.
Home Assistant is an amazing home automation software that gives you full control over all your smart devices and allows you to integrate different platforms. To learn more about it check the Home Assistant Website .
Blueprints are used, in Home Assistant, as templates for building automation quickly. If you want to learn more about it and start writing your own automation check the Creating blueprints page.