-
Notifications
You must be signed in to change notification settings - Fork 57
/
Copy pathaurora_schedule.yaml
152 lines (131 loc) · 3.88 KB
/
aurora_schedule.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
#
# Schedule the Nanoleaf Aurora based on its loaded-in effects
#
# Unless an effect is manually selected, this scheduler will do its thing.
#
# @subscribe input_boolean.nap_mode
# @subscribe input_boolean.night_mode
# @subscribe input_boolean.scene_mode
# @subscribe input_select.aurora_effect
#
# @publish variable.aurora_brightness
# @publish variable.aurora_effect
#
# @see /automations/devices/aurora_effect.yaml
#
# @link https://forum.nanoleaf.me/docs/openapi
#
- id: aurora_schedule
alias: "Aurora SCHEDULE"
trigger:
# Every hour on the hour.
- platform: time_pattern
minutes: 00
seconds: 00
# When an item which was off or physically disconnected comes back online.
- platform: state
entity_id:
- light.aurora
from: 'off'
# When scenes are disabled.
- platform: state
entity_id: input_boolean.scene_mode
to: 'off'
# When the selected effect is switched to default.
- platform: state
entity_id: input_select.aurora_effect
to: "Auto"
condition:
# If automation was not trigered lately (debounce).
- condition: template
value_template: >-
{% set current = as_timestamp(utcnow()) %}
{% set last_triggered = as_timestamp(states.automation.aurora_schedule.attributes.last_triggered) | float %}
{{ current - last_triggered > 1}}
# If the Aurora is active.
- condition: state
entity_id: light.aurora
state: 'on'
# If the selected effect is the default.
- condition: state
entity_id: input_select.aurora_effect
state: 'Auto'
# If no scenes are enabled.
- condition: state
entity_id: input_boolean.scene_mode
state: 'off'
# If it's not during the night mode.
- condition: state
entity_id: input_boolean.night_mode
state: 'off'
# If it's not during the nap mode.
- condition: state
entity_id: input_boolean.nap_mode
state: 'off'
action:
# Update the Aurora effect variable with the desired effect name.
- service: variable.set_variable
data:
variable: aurora_effect
value_template: >-
{% set hour = states('sensor.time').split(':')[0] %}
{% set schedule = {
'00': 'Be Productive',
'01': 'Canada Day',
'02': 'Color Burst',
'03': 'Fifty shades',
'04': 'Flames',
'05': 'Forest',
'06': 'Inner Peace',
'07': 'Movie Night',
'08': 'Nemo',
'09': 'Northern Lights',
'10': 'Rain',
'11': 'Retro Future',
'12': 'Romantic',
'13': 'Serve warm and chilled',
'14': 'Snowfall',
'15': 'Stranger Things',
'16': 'Synthwave',
'17': 'Tron Legacy',
'18': 'Tron2',
'19': 'Vibrant Sunrise',
'20': 'Inner Peace',
'21': 'Nemo',
'22': 'Flames',
'23': 'Retro Future',
} %}
{{ schedule[hour] }}
# Update the Aurora brightness variable with the desired level.
- service: variable.set_variable
data:
variable: aurora_brightness
value_template: >-
{% set hour = states('sensor.time').split(':')[0] %}
{% set schedule = {
'00': '35',
'01': '30',
'02': '25',
'03': '20',
'04': '20',
'05': '25',
'06': '45',
'07': '60',
'08': '75',
'09': '80',
'10': '85',
'11': '95',
'12': '100',
'13': '100',
'14': '95',
'15': '90',
'16': '85',
'17': '80',
'18': '75',
'19': '70',
'20': '65',
'21': '60',
'22': '55',
'23': '50',
} %}
{{ schedule[hour] }}