/
function_alarmclock.yaml
141 lines (135 loc) · 4.04 KB
/
function_alarmclock.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
################################################################################
# Alarm Clock
################################################################################
# Group
group:
################################################################################
alarmclock_settings:
name: Alarm Clock Settings
control: hidden
entities:
- automation.wakeup_light_bedroom
- automation.wakeup_apple_tv
- input_datetime.wakeup_time
- input_number.wakeup_duration
################################################################################
### Inputs ###
input_datetime:
wakeup_time:
name: Wakeup Time
has_date: false
has_time: true
initial: 05:00
input_number:
wakeup_duration:
name: Wakeup duration
icon: mdi:clock-in
initial: 30
min: 0
max: 60
step: 5
automation:
################################################################################
- id: wakeup_light_bedroom
alias: 'Wakeup - Bedroom Light'
initial_state: 'on'
trigger:
- platform: template
value_template: >
{{ states.sensor.time.state == ((states.input_datetime.wakeup_time.attributes.timestamp | int) - (states.input_number.wakeup_duration.state | int * 60)) | timestamp_custom('%H:%M',False) }}
condition:
condition: state
entity_id: binary_sensor.workday_sensor
state: 'on'
action:
service: light.turn_on
data:
entity_id: light.master_bedroom_lights
profile: energize
data_template:
transition: >
{{ states.input_number.wakeup_duration.state | multiply(60) | int }}
################################################################################
################################################################################
- id: wakeup_apple_tv
alias: 'Wakeup - Apple TV'
initial_state: 'on'
trigger:
- platform: template
value_template: >
{{ states.sensor.time.state == ((states.input_datetime.wakeup_time.attributes.timestamp | int) - (states.input_number.wakeup_duration.state | int * 60)) | timestamp_custom('%H:%M',False) }}
condition:
condition: state
entity_id: binary_sensor.workday_sensor
state: 'on'
action:
service: script.wakeup_apple_tv
################################################################################
script:
################################################################################
wakeup_apple_tv:
alias: 'Wakeup - Apple TV'
sequence:
# Turn on the TV
- service: media_player.turn_on
data:
entity_id: media_player.master_bedroom
- service: remote.send_command
data:
entity_id: remote.master_bedroom
command:
- menu
- delay:
seconds: 15
# Go to the home menu
- service: remote.send_command
data:
entity_id: remote.master_bedroom
command:
- top_menu
- delay:
seconds: 1
# Go to the first menu item (Plex)
- service: remote.send_command
data:
entity_id: remote.master_bedroom
command:
- top_menu
# Open Plex
- service: remote.send_command
data:
entity_id: remote.master_bedroom
command:
- select
- delay:
seconds: 15
# Select Apocrathia user account
- service: remote.send_command
data:
entity_id: remote.master_bedroom
command:
- select
- delay:
seconds: 5
# Go to news
- service: remote.send_command
data:
entity_id: remote.master_bedroom
command:
- down
- right
- right
- right
- right
- right
- right
- select
- delay:
seconds: 15
# Fullscreen
- service: remote.send_command
data:
entity_id: remote.master_bedroom
command:
- select
################################################################################