Last active
August 17, 2021 11:40
-
-
Save reinder83/2afd18c0f9736b045d8db755d6a11bc0 to your computer and use it in GitHub Desktop.
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 Script with Elevation | |
domain: automation | |
source_url: https://gist.github.com/reinder83/2afd18c0f9736b045d8db755d6a11bc0 | |
input: | |
motion_entity: | |
name: Motion Sensor | |
selector: | |
entity: | |
domain: binary_sensor | |
device_class: motion | |
script_on_target: | |
name: Script on | |
description: Script which runs when motion is detected | |
selector: | |
target: | |
entity: | |
domain: script | |
script_off_target: | |
name: Script off | |
description: Script which runs when no motion is detected anymore and the wait time is exceeded | |
selector: | |
target: | |
entity: | |
domain: script | |
no_motion_wait: | |
name: Wait time | |
description: Time to wait until the light should be turned off. | |
default: 120 | |
selector: | |
number: | |
min: 0.0 | |
max: 3600.0 | |
unit_of_measurement: seconds | |
step: 1.0 | |
mode: slider | |
below_elevation: | |
name: Below sun elevation | |
description: Solar elevation. This is the angle between the sun and the horizon. | |
Negative values mean the sun is below the horizon. | |
default: 3 | |
selector: | |
number: | |
min: -90.0 | |
max: 90.0 | |
unit_of_measurement: degrees | |
step: 0.1 | |
mode: slider | |
mode: restart | |
max_exceeded: silent | |
trigger: | |
platform: state | |
entity_id: !input 'motion_entity' | |
from: 'off' | |
to: 'on' | |
variables: | |
below_elevation: !input 'below_elevation' | |
condition: | |
- '{{ state_attr(''sun.sun'',''elevation'') <= (below_elevation | float)}}' | |
action: | |
- service: !input 'script_on_target' | |
- wait_for_trigger: | |
platform: state | |
entity_id: !input 'motion_entity' | |
from: 'on' | |
to: 'off' | |
- delay: !input 'no_motion_wait' | |
- service: !input 'script_off_target' |
I will look into it when I have time later today
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Okay the light blueprint works fine with one of my lights so must be something to do with my script. Do you expect the script to require a variable passing or something? Here is my script and the error message I am getting when I try to create an automation with the blueprint
error message
2021-08-16 17:06:45 ERROR (MainThread) [homeassistant.components.automation] Blueprint Motion-activated Script with Elevation generated invalid automation with inputs OrderedDict([('motion_entity', 'binary_sensor.hall'), ('script_on_target', OrderedDict([('entity_id', 'script.kitchen_light_power')])), ('script_off_target', OrderedDict([('entity_id', 'script.kitchen_light_power')])), ('no_motion_wait', 45)]): value should be a string for dictionary value @ data['action'][0]['service']. Got None
Thanks again for you time and efforts