-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathphilips_tap_dial_sonos_v2.yaml
227 lines (209 loc) · 7.08 KB
/
philips_tap_dial_sonos_v2.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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
blueprint:
name: Phlips Tap Dial Sonos Controller v2
description: "Use Philips Tap Dial to control Sonos using device actions.
Use a device id which ends with '_action', e.g. 'sensor.bedroom_bed_tap_dial_switch_action'"
domain: automation
input:
button_sensor:
name: Philips Hue Tap dial switch sensor entity
description:
Sensor for Philips Hue Tap dial switch to use (Use sensor with
entity_id ends with _action)
selector:
device:
filter:
- integration: mqtt
manufacturer: Philips
model: Hue Tap dial switch
sonos_controller:
name: Sonos controller device
description: The sonos controller that this tap dial will operate
selector:
entity:
multiple: false
filter:
- domain: media_player
integration: sonos
volume_dial_fast:
name: Fast dial volume increase/decrease
description: How fast the volume is increase or decreased when dialing fast. The range is 0.0 to 1.0
default: 0.1
selector:
number:
min: 0
max: 1
step: 0.01
volume_dial_slow:
name: Slow dial volume increase/decrease
description: How fast the volume is increase or decreased when dialing slow. The range is 0.0 to 1.0
default: 0.05
selector:
number:
min: 0
max: 1
step: 0.01
volume_dial_step:
name: Singel step dial volume increase/decrease
description: How fast the volume is increase or decreased when dialing a single step at a time. The range is 0.0 to 1.0
default: 0.01
selector:
number:
min: 0
max: 1
step: 0.01
variables:
sonos_controller: !input sonos_controller
button_sensor: !input button_sensor
volume_dial_fast: !input volume_dial_fast
volume_dial_slow: !input volume_dial_slow
volume_dial_step: !input volume_dial_step
mode: restart
max_exceeded: silent
trigger:
- platform: device
domain: mqtt
device_id: !input button_sensor
type: action
subtype: button_1_press_release
- platform: device
domain: mqtt
device_id: !input button_sensor
type: action
subtype: button_2_press_release
- platform: device
domain: mqtt
device_id: !input button_sensor
type: action
subtype: button_3_press_release
- platform: device
domain: mqtt
device_id: !input button_sensor
type: action
subtype: button_4_press_release
- platform: device
domain: mqtt
device_id: !input button_sensor
type: action
subtype: dial_rotate_left_step
- platform: device
domain: mqtt
device_id: !input button_sensor
type: action
subtype: dial_rotate_left_slow
- platform: device
domain: mqtt
device_id: !input button_sensor
type: action
subtype: dial_rotate_left_fast
- platform: device
domain: mqtt
device_id: !input button_sensor
type: action
subtype: dial_rotate_right_step
- platform: device
domain: mqtt
device_id: !input button_sensor
type: action
subtype: dial_rotate_right_slow
- platform: device
domain: mqtt
device_id: !input button_sensor
type: action
subtype: dial_rotate_right_fast
condition:
- condition: template
value_template: >-
{{ trigger.payload.startswith('button_') or
trigger.payload.startswith('dial_') }}
action:
- variables:
action: "{{ trigger.payload }}"
- choose:
#BUTTON 1
- conditions: "{{ action == 'button_1_press_release' }}"
sequence:
- service: media_player.media_play_pause
target:
entity_id: !input sonos_controller
# - conditions: "{{ action == 'button_1_hold' }}"
# sequence: !input remote_button_1_hold
#BUTTON 2
- conditions: "{{ action == 'button_2_press_release' }}"
sequence:
- service: media_player.media_play_pause
target:
entity_id: !input sonos_controller
# - conditions: "{{ action == 'button_2_hold' }}"
# sequence: !input remote_button_2_hold
# #BUTTON 3
- conditions: "{{ action == 'button_3_press_release' }}"
sequence:
- service: media_player.media_previous_track
target:
entity_id: !input sonos_controller
# - conditions: "{{ action == 'button_3_hold' }}"
# sequence: !input remote_button_3_hold
#BUTTON 4
- conditions: "{{ action == 'button_4_press_release' }}"
sequence:
- service: media_player.media_next_track
target:
entity_id: !input sonos_controller
# - conditions: "{{ action == 'button_4_hold' }}"
# sequence: !input remote_button_4_hold
# DIAL LEFT
- conditions: "{{ action == 'dial_rotate_left_step' }}"
sequence:
- service: media_player.volume_set
data:
volume_level: >-
{{ [state_attr(sonos_controller, 'volume_level') - volume_dial_step, 0] | max | float }}
target:
entity_id: >-
{{ state_attr(sonos_controller, 'group_members') }}
- conditions: "{{ action == 'dial_rotate_left_slow' }}"
sequence:
- service: media_player.volume_set
data:
volume_level: >-
{{ [state_attr(sonos_controller, 'volume_level') - volume_dial_slow, 0] | max | float }}
target:
entity_id: >-
{{ state_attr(sonos_controller, 'group_members') }}
- conditions: "{{ action == 'dial_rotate_left_fast' }}"
sequence:
- service: media_player.volume_set
data:
volume_level: >-
{{ [state_attr(sonos_controller, 'volume_level') - volume_dial_fast * 1, 0] | max | float }}
target:
entity_id: >-
{{ state_attr(sonos_controller, 'group_members') }}
# DIAL RIGHT
- conditions: "{{ action == 'dial_rotate_right_step' }}"
sequence:
- service: media_player.volume_set
data:
volume_level: >-
{{ [state_attr(sonos_controller, 'volume_level') + volume_dial_step, 1] | min | float }}
target:
entity_id: >-
{{ state_attr(sonos_controller, 'group_members') }}
- conditions: "{{ action == 'dial_rotate_right_slow' }}"
sequence:
- service: media_player.volume_set
data:
volume_level: >-
{{ [state_attr(sonos_controller, 'volume_level') + volume_dial_slow, 1] | min | float }}
target:
entity_id: >-
{{ state_attr(sonos_controller, 'group_members') }}
- conditions: "{{ action == 'dial_rotate_right_fast' }}"
sequence:
- service: media_player.volume_set
data:
volume_level: >-
{{ [state_attr(sonos_controller, 'volume_level') + volume_dial_fast / 5, 1] | min | float }}
target:
entity_id: >-
{{ state_attr(sonos_controller, 'group_members') }}