· last year · Jul 26, 2024, 07:05 PM
1substitutions:
2 device_name: "bellspeaker"
3 short_name: "Bell Speaker Box"
4
5 # ESP32 Pin Allocations
6 rgb_led_pin: "GPIO19" # WS2811 addressable RGB LED
7 knob_power_pin: "GPIO23" # Amplifier Button (inverted)
8 pot_pin: "GPIO39" # Pin "SVN" aka GPIO39 - wiper of 10k pot tween 3.3v and gnd
9 led1_pin: "GPIO2" # Blue LED internal (inverted)
10 gain_pin: "GPIO25" # used to adjust the gain of the player
11 i2s_out_lrclk_pin: "GPIO21" # \ I2S out (speaker)
12 i2s_out_bclk_pin: "GPIO22" # /
13 i2s_in_lrclk_pin: "GPIO26" # \ I2S in (mic)
14 i2s_in_bclk_pin: "GPIO18" # /
15 i2s_dout_audio: "GPIO27" # media player pin
16
17 # IP info
18 use_this_ip: "192.168.77.xxx"
19 use_this_gateway: "192.168.101.1"
20 use_this_subnet: "255.255.255.0"
21 use_this_dns1: "8.8.8.8"
22
23
24# *******************************
25# * Pin Definitions *
26# * ESP-32 Mini Pin Allocations *
27# ***********************************************
28 # I2C_SCL: "16" # 16 SCL (I2C) BME680, SH1106 \ INVERTED due to flipped board (labels out)
29 # I2C_SDA: "17" # 17 SDA (I2C) /
30
31# "${uart_tx:}" <-used to copy/paste the substition syntax
32
33esphome:
34# Code to reset the auth password on device
35# on_boot:
36# - lambda: |-
37# id(my_ota).set_auth_password("31fbaa7c32760017dceb3b922c92d4de");
38
39 name: "${device_name}"
40 friendly_name: "${short_name}"
41
42esp32:
43 board: esp32dev
44 framework:
45 type: arduino
46
47# Enable logging
48logger:
49 logs:
50 # levels include NONE, ERROR, WARN, INFO, DEBUG
51 component: ERROR
52
53# Enable Home Assistant API
54api:
55 encryption:
56 key: !secret esphome_encryption_key
57
58ota:
59 - platform: esphome
60 password: !secret esphome_ota_password
61 id: my_ota
62
63wifi:
64 networks:
65 - ssid: !secret graner_ssid
66 password: !secret graner_password
67 - ssid: !secret aca_ssid
68 password: !secret aca_password
69 power_save_mode: NONE
70
71# Enable fallback hotspot (captive portal) in case wifi connection fails
72 ap:
73 ssid: "${device_name} FB"
74 password: !secret esphome_fallback_password
75
76# manual_ip:
77# static_ip: "${use_this_ip}"
78# gateway: "${use_this_gateway}"
79# subnet: "${use_this_subnet}"
80# dns1: "${use_this_dns1}"
81
82# setup a web page for quick control this east a LOT of memory. Best to use only for debug
83#web_server:
84# port: 80
85# version: 1
86
87# Sets the on-board blue LED to report status by blinks
88status_led:
89 pin:
90 number: GPIO2
91 inverted: False
92
93captive_portal:
94
95switch:
96# Switch to bump the gain up/down (sorta like -5db pad)
97 - platform: gpio
98 id: gain_boost
99 name: "Gain Boost"
100 inverted: True
101 pin: "${gain_pin}"
102 restore_mode: ALWAYS_ON
103
104# Reset switch in case the ESP32 gets stuck
105 - platform: restart
106 name: ESP32 Restart
107
108sensor:
109# Reads and transmits the volume pot position
110 - platform: adc
111 pin:
112 number: "${pot_pin}"
113 mode:
114 input: true
115 pullup: False
116 name: "Volume Pot"
117 id: my_sensor
118 attenuation: auto
119 update_interval: 1000ms
120
121
122# Single Neopixel RGB LED behind the volume knob
123light:
124 - platform: neopixelbus
125 type: GRB
126 variant: WS2811
127 pin: "${rgb_led_pin}"
128 num_leds: 1
129 name: "Alert Light"
130 id: alert_light
131 default_transition_length: 0s
132 effects:
133 - pulse:
134 - pulse:
135 name: "Slow Pulse"
136 transition_length:
137 on_length: 500ms
138 off_length: 500ms
139 update_interval: 1s
140 - pulse:
141 name: "Fast Pulse"
142 transition_length:
143 on_length: 250ms
144 off_length: 250ms
145 update_interval: 500ms
146 - addressable_random_twinkle:
147 progress_interval: 250ms
148 - addressable_fireworks:
149 - addressable_flicker:
150 - addressable_rainbow:
151 name: Rainbow Effect With Custom Values
152 speed: 20
153 width: 50
154 - addressable_color_wipe:
155 - addressable_scan:
156 name: Scan Effect With Custom Values
157 move_interval: 100ms
158 scan_width: 1
159
160binary_sensor:
161# Button section (latching) normally open closed to ground as ESP pins have weak pull-up power
162 - platform: gpio
163 pin:
164 number: "${knob_power_pin}"
165 mode:
166 input: true
167 pullup: true
168 inverted: true
169 name: Knob Power Switch
170 filters:
171 - delayed_off: 20ms
172 on_press:
173 - logger.log: Knob Power ON
174# - display.page.show_next: oled_display
175# - component.update: oled_display
176
177 - platform: homeassistant
178 id: ha_light_group_state
179 entity_id: light.loop_lights
180
181 - platform: homeassistant
182 id: loop1_status
183 entity_id: binary_sensor.alarm_house_door_window_sensors
184 publish_initial_state: True
185 on_state:
186 then:
187 - if:
188 condition:
189 binary_sensor.is_off: loop1_status
190 then:
191 - light.turn_on:
192 id: alert_light
193 red: 0%
194 green: 100%
195 blue: 0%
196# brightness: !lambda |-
197# return id(ha_light_brightness).state / 255;
198 effect: none
199 else:
200 - light.turn_off:
201 id: alert_light
202# red: 100%
203# green: 0%
204# blue: 0%
205# brightness: !lambda |-
206# return id(ha_light_brightness).state / 255;
207# effect: none
208# -----------------------------------------------------------------------------------------
209
210# System status report for ONLINE or OFFLINE display
211 - platform: status
212 name: "Node Status"
213 id: system_status
214 publish_initial_state: True
215 on_state:
216 then:
217 - if:
218 condition:
219 binary_sensor.is_off: system_status
220 then:
221 - light.turn_on:
222 id: alert_light
223 red: 0%
224 green: 0%
225 blue: 100%
226 brightness: 50%
227 effect: "Fast Pulse"
228 else:
229 - light.turn_off:
230 id: alert_light
231
232
233# this setup allows switchable control of the blue led on the ESP32 board itself
234#output:
235# id: led_1_output
236# platform: gpio
237# pin:
238# number: "${led1_pin}"
239# inverted: False
240
241i2s_audio:
242 - id: i2s_out
243 i2s_lrclk_pin: "${i2s_out_lrclk_pin}"
244 i2s_bclk_pin: "${i2s_out_bclk_pin}"
245# - id: i2s_in
246# i2s_lrclk_pin: "${i2s_in_lrclk_pin}"
247# i2s_bclk_pin: "${i2s_in_bclk_pin}"
248
249# LR to be grounded
250
251media_player:
252 - platform: i2s_audio
253 name: ESPHome I2S Media Player
254 dac_type: external
255 i2s_audio_id: i2s_out
256 i2s_dout_pin: "${i2s_dout_audio}"
257 mode: mono
258 on_pause:
259 - media_player.stop
260
261
262