-
Notifications
You must be signed in to change notification settings - Fork 10
/
louder-esp32-media-player.yaml
121 lines (107 loc) · 2.71 KB
/
louder-esp32-media-player.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
substitutions:
name: "louder-esp32"
friendly_name: Louder-ESP32 Media Player
# max_volume: "0.9" # If volume exceeds this we reset it to this. Be sure to uncomment the code below "max_volume feature".
esphome:
name: "${name}"
name_add_mac_suffix: false
project:
name: Sonocotta.Louder ESP32
version: '1.0'
comment: "${friendly_name} Louder ESP32 ${pcb_version}"
includes:
- louderesp32.h
platformio_options:
lib_deps: "Wire"
on_boot:
priority: 800
then:
## Set a volume limit just to be safe...
- media_player.volume_set:
id: louderesp32
volume: 20%
esp32:
board: mhetesp32minikit
### Optional if you want ethernet (then remove all wifi config) ###
#ethernet:
# type: W5500
# clk_pin: GPIO18
# mosi_pin: GPIO23
# miso_pin: GPIO19
# cs_pin: GPIO05
# interrupt_pin: GPIO35
# reset_pin: GPIO14
# Enable logging
logger:
level: DEBUG
# Enable Home Assistant API
api:
# Allow Over-The-Air updates
ota:
platform: esphome
password: !secret esphome_ota_password
wifi:
ssid: !secret esphome_wifi_ssid
password: !secret esphome_wifi_password
ap:
ssid: "$name Hotspot"
password: !secret esphome_ap_password
captive_portal:
psram:
mode: octal
speed: 80MHz
switch:
- platform: custom
lambda: |-
auto tas5805 = new TAS5805();
App.register_component(tas5805);
return {tas5805};
switches:
name: "Enable Amp"
id: amp
i2c:
sda: GPIO21
scl: GPIO27
scan: True
id: i2c_component
i2s_audio:
i2s_lrclk_pin: GPIO25
i2s_bclk_pin: GPIO26
interval:
- interval: 1min
then:
- if:
condition:
- switch.is_on: amp
- for:
time: 30s
condition:
or:
- media_player.is_idle: louderesp32
- media_player.is_paused: louderesp32
then:
- switch.turn_off: amp
media_player:
- platform: i2s_audio
name: $friendly_name
id: louderesp32
dac_type: external
i2s_dout_pin: GPIO22
mode: stereo
on_play:
- switch.turn_on: amp
### max_volume feature - uncomment below to enable
# on_state:
# then:
# - if:
# condition:
# lambda: |-
# float current_volume = roundf(id(louderesp32).volume * 100) / 100.0;
# float max_vol = roundf(${max_volume} * 100) / 100.0;
# return current_volume > max_vol;
# then:
# - logger.log: "Volume exceeds max volume, resetting to max volume"
# - media_player.volume_set:
# id: louderesp32
# volume: ${max_volume}
# - logger.log: "Volume set to max volume"