-
Notifications
You must be signed in to change notification settings - Fork 1
/
motion-activated_light_profiles.yaml
180 lines (172 loc) · 6.19 KB
/
motion-activated_light_profiles.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
179
180
blueprint:
name: Motion-activated light profiles based on time and light level and with a grace period.
description: |
This motion-activated blueprint allows you to setup automatic light switching like the Philips Hue motion
sensors do. When motion is detected, the light will be turned on, when the motion is no longer detected,
the lights will go to another state for a given amount of seconds before switching off.
This allows anyone to not be left in the dark, you will be warned before the light switches off.
This automation does require to setup light profiles, a light profile contains the color (in xy), birghtness
and a transition time. This makes the automation much simpler plus it allows you to maintain these states in a
general place. For more information about light profiles, you could check the documentation
https://www.home-assistant.io/integrations/light/
This automation should work with any lights, motion sensors and illuminance sensors.
domain: automation
source_url: https://raw.githubusercontent.com/golles/Home-Assistant-Blueprints/main/motion-activated_light_profiles.yaml
input:
motion_entity:
name: Motion sensor
selector:
entity:
device_class: motion
cool_down:
name: Cool down period
description: Number of seconds before dimming the brightness when motion is no longer detected.
default: 0
selector:
number:
min: 0
max: 120
step: 1
unit_of_measurement: seconds
mode: slider
no_motion_wait:
name: Wait time
description: Number of seconds to leave the light on with turning off profile.
default: 15
selector:
number:
min: 0
max: 120
step: 1
unit_of_measurement: seconds
mode: slider
light_entity:
name: Light
selector:
entity:
domain: light
illuminance_entity:
name: Illuminance sensor
selector:
entity:
domain: sensor
device_class: illuminance
illuminance_below:
name: Minimum illuminance
description: The light will only switch on when the illuminance is bellow this value.
default: 10
selector:
number:
min: 0
max: 1000
unit_of_measurement: lx
mode: box
day_start_time:
name: Day start time
description: From this time the day profile will be used to switch on the light.
default: "07:00"
selector:
time:
day_end_time:
name: Day end time
description: Till this time the day profile will be used to switch on the light.
default: "23:00"
selector:
time:
day_profile:
name: Day time profile name when turning on
description: The default is reading.
default: reading
day_profile_before_off:
name: Day time profile name before turning off
description: The default is concentrate.
default: concentrate
night_profile:
name: Night time profile name when turning on
description: The default is energize.
default: energize
night_profile_before_off:
name: Night time profile name before turning off
description: The default is relax.
default: relax
# If motion is detected within the delay, we restart the script.
# If there is no motion, the brightness drops before turning off.
mode: restart
max_exceeded: silent
trigger:
platform: state
entity_id: !input motion_entity
from: "off"
to: "on"
action:
- choose:
- conditions:
condition: or
conditions:
# The illuminance should be below the given value...
- condition: numeric_state
entity_id: !input illuminance_entity
below: !input illuminance_below
# ...or the light is already on (the illuminance might have gone up when the lights turned on).
- condition: state
entity_id: !input light_entity
state: "on"
sequence:
- choose:
# Day time.
- conditions:
- condition: time
after: !input day_start_time
before: !input day_end_time
sequence:
- alias: Turn on light with day profile
service: light.turn_on
data:
entity_id: !input light_entity
profile: !input day_profile
# Other times
default:
- alias: Turn on light with night profile
service: light.turn_on
data:
entity_id: !input light_entity
profile: !input night_profile
- alias: Wait untill there is no more motion
wait_for_trigger:
platform: state
entity_id: !input motion_entity
from: "on"
to: "off"
for: !input cool_down
- choose:
# Only continue when the light is still on, user might have turned it off manually.
- conditions:
- condition: state
entity_id: !input light_entity
state: "on"
sequence:
- choose:
# Day time.
- conditions:
- condition: time
after: !input day_start_time
before: !input day_end_time
sequence:
- alias: Turn on light with day before off profile
service: light.turn_on
data:
entity_id: !input light_entity
profile: !input day_profile_before_off
# Other times
default:
- alias: Turn on light with night before off profile
service: light.turn_on
data:
entity_id: !input light_entity
profile: !input night_profile_before_off
- alias: Wait for the no motion wait delay
delay: !input no_motion_wait
- alias: Turn off the light
service: light.turn_off
data:
entity_id: !input light_entity