-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmediacontroller.yaml
192 lines (167 loc) · 4.54 KB
/
mediacontroller.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
esphome:
name: mediacontroller
platform: ESP32
board: esp-wrover-kit
wifi:
ssid: ""
password: "!"
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Mediacontroller Fallback Hotspot"
password: ""
captive_portal:
# Enable logging
logger:
# Enable Home Assistant API
api:
password: ""
ota:
password: ""
time:
- platform: homeassistant
id: time1
font:
- file: 'arial.ttf'
id: font3
size: 12
- file: 'arial.ttf'
id: fontbig
size: 35
color:
- id: my_red
red: 100%
green: 3%
blue: 5%
spi:
clk_pin: GPIO16
mosi_pin: GPIO17
display:
- platform: ssd1351_spi
model: "SSD1351 128x128"
reset_pin: GPIO25
cs_pin: GPIO19
dc_pin: GPIO18
id: my_display
pages:
- id: page1
lambda: |-
// Print time in HH:MM format
it.strftime(0, 60, id(fontbig), TextAlign::BASELINE_LEFT, "%l:%M", id(time1).now());
// Print AM/PM
it.strftime(127, 60, id(fontbig), TextAlign::BASELINE_RIGHT, "%P", id(time1).now());
- id: page2
lambda: |-
// Print "Spotify Song" on top left.
if (id(spotify_artist).has_state()) {
it.printf(0, 30, id(font3), TextAlign::BASELINE_LEFT, "%s", id(spotify_artist).state.c_str(), id(my_red));
}
// Print "Spotify Artist" on bottom left.
if (id(spotify_song).has_state()) {
it.printf(0, 60, id(font3), TextAlign::BASELINE_LEFT, "%s", id(spotify_song).state.c_str());
}
- id: page3
lambda: |-
// Print time in HH:MM format
it.strftime(0, 60, id(font3), TextAlign::BASELINE_LEFT, "%l:%M", id(time1).now());
// Print AM/PM
it.strftime(127, 60, id(font3), TextAlign::BASELINE_RIGHT, "%P", id(time1).now());
interval:
- interval: 5s
then:
- display.page.show_next: my_display
- component.update: my_display
text_sensor:
- platform: homeassistant
id: spotify_song
entity_id: sensor.media_song
internal: true
- platform: homeassistant
id: spotify_artist
entity_id: sensor.media_artist
internal: true
binary_sensor:
- platform: gpio
id: button_kitchen
pin:
number: GPIO15
mode: INPUT_PULLUP
inverted: True
on_multi_click:
- timing:
- ON for at most 1s
- OFF for at most 1s
- ON for at most 1s
- OFF for at least 0.2s
then:
- homeassistant.service:
service: media_player.media_next_track
data:
entity_id: media_player.buro
- logger.log: "double click - next track"
- timing:
- ON for .5s to 2s
- OFF for at least 0.1s
then:
- script.execute: start_playlist_shuffle
- logger.log: "long press - play spotify playlist"
- timing:
- ON for at most .49s
- OFF for at least 0.25s
then:
- homeassistant.service:
service: media_player.media_play_pause
data:
entity_id: media_player.buro
- logger.log: "single click - play/pause"
sensor:
- platform: rotary_encoder
id: knob_buro
pin_a: GPIO27
pin_b: GPIO26
min_value: -3
max_value: 3
on_value_range:
- above: 2
then:
- script.execute: volume_up
- below: -2
then:
- script.execute: volume_down
script:
- id: volume_up
then:
- homeassistant.service:
service: media_player.volume_up
data:
entity_id: media_player.buro
- logger.log: "vol up trigger"
- sensor.rotary_encoder.set_value:
id: knob_buro
value: 0
- id: volume_down
then:
- homeassistant.service:
service: media_player.volume_down
data:
entity_id: media_player.buro
- logger.log: "vol down trigger"
- sensor.rotary_encoder.set_value:
id: knob_buro
value: 0
- id: start_playlist_shuffle
then:
- homeassistant.service:
service: media_player.play_media
data:
entity_id: media_player.buro
media_content_id: spotify:playlist:7qFH2xh3ZiewF1WDgXQbfC
media_content_type: playlist
- homeassistant.service:
service: media_player.shuffle_set
data:
entity_id: media_player.buro
shuffle: "true"
- homeassistant.service:
service: media_player.media_next_track
data:
entity_id: media_player.buro