-
Notifications
You must be signed in to change notification settings - Fork 0
/
motion_switch_elevation_and_state.yaml
75 lines (75 loc) · 1.9 KB
/
motion_switch_elevation_and_state.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
blueprint:
name: Motion-activated Switch with Sun Elevation
domain: automation
source_url: https://github.com/pepsonEL/HAblueprints/blob/main/motion_switch_elevation_and_state.yaml
input:
motion_entity:
name: Motion Sensor
selector:
entity:
domain: binary_sensor
device_class: motion
switch_target:
name: Switch
selector:
target:
entity:
domain: switch
switch_entity:
name: Switch with state OFF
description: Switch which must be off to run automation.
selector:
entity:
domain: switch
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: 1.0
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:
- condition: state
entity_id: !input 'switch_entity'
state: 'off'
- condition: and
condition: numeric_state
entity_id: sun.sun
attribute: elevation
below: !input 'below_elevation'
action:
- service: switch.turn_on
target: !input 'switch_target'
- wait_for_trigger:
platform: state
entity_id: !input 'motion_entity'
from: 'on'
to: 'off'
- delay: !input 'no_motion_wait'
- service: switch.turn_off
target: !input 'switch_target'