-
Notifications
You must be signed in to change notification settings - Fork 0
/
motionlight.yaml
178 lines (170 loc) · 5.64 KB
/
motionlight.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
blueprint:
name: Gibbon's Advanced Motion Sensor
description: Turn on a light when motion is detected On due to a number of factors. Time of day, sun elevation, light binary sensor or a illuminance (lux) sensor (v1.1)
domain: automation
input:
test0:
name: "*** Trigger Motion Sensor ***"
default: The following section is simply the motion entity you want to trigger the lights turning on.
selector:
text:
multiline: true
motion_entity:
name: Motion Sensor
description: The entity which you want the motion to based on.
selector:
entity:
domain: binary_sensor
test1:
name: "*** Condition variables ***"
default: The following section are methods of determining if the automation should proceed. If either of them are true then the lights will turn on.
selector:
text:
multiline: true
ilum_entity:
name: Light Binary Sensor (optional)
description: The optional entity for a binary sensor (which should report ON for brighter than specified light level or OFF for darker than specified light level)
default:
selector:
entity:
domain: binary_sensor
lux_entity:
name: Light Iluminance Sensor (optional)
description: The optional entity for any entity which reports a lux value.
default:
selector:
entity:
domain: sensor
lux_value:
name: Desired Lux value (optional)
description: if you are using the illuminance entity above, automation will trigger if lux value is less than this value.
default:
selector:
number:
min: 00
max: 100
mode: slider
step: 1
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:
selector:
number:
min: -20
max: 20
mode: slider
step: 1
use_time:
name: 'Use timeslot only'
description: 'Enable this to ONLY use the timeslot in the automation (this overrides all other conditions)'
default: false
selector:
boolean:
time_from:
name: 'Time from'
description: 'Automation only activates after this time'
default: "00:00:00"
selector:
time:
time_to:
name: 'Time to'
description: 'Automation only activates before this time'
default: "23:59:59"
selector:
time:
test2:
name: "*** Action variables ***"
default: The following section are lights which you want turning on and to what brightness, temperature and how long you wish to wait until they turn off again when there is no motion detected.
selector:
text:
multiline: true
target_light:
name: Lights
description: This is the light(s) that will be activated at sunset (use helper to change to a light if its a switch)
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: Temperature of the light(s) when they're activated
default: 280
selector:
color_temp:
min_mireds: 153
max_mireds: 500
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
# If motion is detected within the delay,
# we restart the script.
mode: restart
max_exceeded: silent
variables:
motion_entity: !input motion_entity
ilum_entity: !input ilum_entity
lux_entity: !input lux_entity
lux_value: !input lux_value
elevation_shift: !input elevation_shift
use_time: !input use_time
time_from: !input time_from
time_to: !input time_to
target_light: !input target_light
target_brightness: !input target_brightness
target_color_temp: !input target_color_temp
no_motion_wait: !input no_motion_wait
within_time: >
{{ not use_time or time_from | today_at < now() < time_to | today_at }}
within_time_use: >
{{ time_from | today_at < now() < time_to | today_at }}
sun_elevation_below_shift: >
{{ elevation_shift is not none and (state_attr('sun.sun', 'elevation') < elevation_shift) }}
lux_check: >
{{ lux_entity is not none and lux_value is not none and states(lux_entity) | float < lux_value }}
ilum_check: >
{{ ilum_entity is not none and is_state(ilum_entity, 'off') }}
trigger:
- platform: state
entity_id: !input motion_entity
from: "off"
to: "on"
condition:
- condition: template
value_template: >
{% if use_time %}
{{ within_time_use }}
{% else %}
{{ within_time and ( ilum_check or lux_check or sun_elevation_below_shift) }}
{% endif %}
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