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