-
Notifications
You must be signed in to change notification settings - Fork 185
/
Copy pathadaptive_lighting.yaml
94 lines (90 loc) · 3.54 KB
/
adaptive_lighting.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
---
#-
# _ _ _ _ _ _ _ _
# __ _ __| | __ _ _ __ | |_(_)_ _____ | (_) __ _| |__ | |_(_)_ __ __ _
# / _` |/ _` |/ _` | '_ \| __| \ \ / / _ \ | | |/ _` | '_ \| __| | '_ \ / _` |
# | (_| | (_| | (_| | |_) | |_| |\ V / __/ | | | (_| | | | | |_| | | | | (_| |
# \__,_|\__,_|\__,_| .__/ \__|_| \_/ \___|___|_|_|\__, |_| |_|\__|_|_| |_|\__, |
# |_| |_____| |___/ |___/
#
#- from github.com/basnijholt/home-assistant-config
- alias: "Adaptive lighting: turn on and off switches"
triggers:
- trigger: state
entity_id: input_select.sleep_mode
- trigger: homeassistant
event: start # in case the states aren't properly restored
variables:
sleep_mode: "{{ states('input_select.sleep_mode') }}"
actions:
choose:
- conditions: "{{ sleep_mode == 'off' }}"
sequence:
- action: switch.turn_off
entity_id:
- switch.adaptive_lighting_sleep_mode_bedroom
- switch.adaptive_lighting_sleep_mode_bedroom_led
- switch.adaptive_lighting_sleep_mode_living_room
- switch.adaptive_lighting_sleep_mode_baby_room
- conditions: "{{ sleep_mode == 'half' }}"
sequence:
- action: switch.turn_off
entity_id:
- switch.adaptive_lighting_sleep_mode_living_room
- action: switch.turn_on
entity_id:
- switch.adaptive_lighting_sleep_mode_bedroom
- switch.adaptive_lighting_sleep_mode_bedroom_led
- switch.adaptive_lighting_sleep_mode_baby_room
- conditions: "{{ sleep_mode == 'total' }}"
sequence:
- action: switch.turn_on
entity_id:
- switch.adaptive_lighting_sleep_mode_bedroom
- switch.adaptive_lighting_sleep_mode_bedroom_led
- switch.adaptive_lighting_sleep_mode_baby_room
# The living room is set by another automation which
# only executes when no-one is in the living room.
# See the automations in `sleep_mode.yaml`!
- alias: "Adaptive lighting: reset manual_control after 1 hour"
mode: parallel
max: 200
triggers:
- trigger: event
event_type: adaptive_lighting.manual_control
variables:
light: "{{ trigger.event.data.entity_id }}"
switch: "{{ trigger.event.data.switch }}"
conditions: "{{ 'hall' not in light and 'stairs' not in light }}"
actions:
- delay: "01:00:00"
- condition: template
value_template: "{{ light in state_attr('switch', 'manual_control') }}"
- action: adaptive_lighting.set_manual_control
data:
entity_id: "{{ switch }}"
lights: "{{ light }}"
manual_control: false
- action: notify.iphone_bas
data:
title: "Adaptive Ligthing: manual_control reset"
message: "{{ light }} is reset to not 'manually controlled'"
- alias: "Adaptive lighting: notify manual_control"
mode: parallel
max: 20
triggers:
- trigger: event
event_type: adaptive_lighting.manual_control
variables:
light: "{{ trigger.event.data.entity_id }}"
conditions: "{{ 'hall' not in light and 'stairs' not in light }}"
actions:
- action: system_log.write
data:
message: "{{ light }} is manually controlled"
level: error
logger: yolo.yolo
- action: notify.iphone_bas
data:
title: "Adaptive Ligthing: manual_control"
message: "{{ light }} is now 'manually controlled', context={{ trigger.event.context }}"