· this year · Oct 09, 2024, 08:30 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 INMP441 I2S in (mic)
17 i2s_din_audio: "GPIO35" # / SD
18
19 # IP info
20 use_this_ip: "192.168.xxx.xxx"
21 use_this_gateway: "192.168.xxx.xxx"
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 graner_ssid
58 password: !secret graner_password
59 - ssid: !secret aca_ssid
60 password: !secret aca_password
61 power_save_mode: NONE
62
63# Enable fallback hotspot (captive portal) in case wifi connection fails
64 ap:
65 ssid: "${device_name} FB"
66 password: !secret esphome_fallback_password
67
68# manual_ip:
69# static_ip: "${use_this_ip}"
70# gateway: "${use_this_gateway}"
71# subnet: "${use_this_subnet}"
72# dns1: "${use_this_dns1}"
73
74# setup a web page for quick control this eats a LOT of memory. Best to use only for debug
75web_server:
76 port: 80
77 version: 3
78
79captive_portal:
80
81button:
82 - platform: restart
83 icon: mdi:power-cycle
84 name: "ESP Reboot"
85
86switch:
87 - platform: gpio
88 id: gain_boost
89 name: "Gain Boost"
90 inverted: True
91 pin: "${gain_pin}"
92 restore_mode: ALWAYS_ON
93
94sensor:
95 - platform: adc
96 pin:
97 number: "${pot_pin}"
98 mode:
99 input: true
100 pullup: False
101 name: "Volume Pot"
102 id: my_sensor
103 attenuation: auto
104 update_interval: 15s
105
106# Reports internal temperature of the ESP32
107 - platform: internal_temperature
108 name: "Internal Temperature"
109 entity_category: "diagnostic"
110 update_interval: 30s
111
112# Reports uptime
113 - platform: uptime
114 name: Uptime
115 entity_category: "diagnostic"
116 update_interval: 300s
117
118# Reports WiFi signal strength
119 - platform: wifi_signal
120 name: "WiFi Signal"
121 accuracy_decimals: 1
122 entity_category: "diagnostic"
123 update_interval: 5s
124
125binary_sensor:
126# Button section normally open closed to ground as ESP pins have weak pull-up power
127 - platform: gpio
128 name: Power Switch
129 pin:
130 number: "${pot_power_pin}"
131 mode:
132 input: true
133 pullup: true
134 inverted: true
135 filters:
136 - delayed_off: 20ms
137 on_press:
138 - logger.log: Knob Power ON
139# - display.page.show_next: oled_display
140# - component.update: oled_display
141
142 - platform: gpio
143 name: Talk Button
144 pin:
145 number: "${talk_button_pin}"
146 mode:
147 input: true
148 pullup: true
149 inverted: true
150 filters:
151 - delayed_off: 20ms
152 on_press:
153 - logger.log: Talk Button Pressed
154# - display.page.show_next: oled_display
155# - component.update: oled_display
156 on_release:
157 - logger.log: Talk Button Released
158
159
160# Update LED status based on alarm loop state
161 - platform: homeassistant
162 name: "Loop Status"
163 id: loop1_status
164 entity_id: binary_sensor.alarm_house_door_window_sensors
165 publish_initial_state: True
166 on_state:
167 then:
168 script.execute: update_led
169
170# System status report for ONLINE or OFFLINE display
171 - platform: status
172 name: "Node Status"
173 id: system_status
174 publish_initial_state: True
175 on_state:
176 then:
177 - script.execute: update_led
178
179# Example configuration entry
180script:
181 - id: update_led
182 then:
183 - lambda: |-
184 if (!id(system_status).state)
185 id(alert_light).turn_on().set_rgb(0, 0, 1).set_brightness(0.5).set_effect("Fast Pulse").perform();
186 else if (!id(loop1_status).state)
187 id(alert_light).turn_on().set_rgb(0, 1, 0).set_brightness(0.25).set_effect("None").perform();
188 else
189 id(alert_light).turn_off().perform();
190
191# Single Neopixel LED
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 name: "Slow Pulse"
204 transition_length:
205 on_length: 500ms
206 off_length: 500ms
207 update_interval: 1s
208 - pulse:
209 name: "Fast Pulse"
210 transition_length:
211 on_length: 250ms
212 off_length: 250ms
213 update_interval: 500ms
214
215# This allows the on-board blue LED to indicate conneciton and other status
216status_led:
217 pin:
218 number: "${led1_pin}"
219 inverted: False
220
221# I2S pin config
222i2s_audio:
223 - id: i2s_out
224 i2s_lrclk_pin: "${i2s_out_lrclk_pin}"
225 i2s_bclk_pin: "${i2s_out_bclk_pin}"
226 - id: i2s_in
227 i2s_lrclk_pin: "${i2s_in_lrclk_pin}" # WS
228 i2s_bclk_pin: "${i2s_in_bclk_pin}" # CLK
229
230# Media player configuration
231media_player:
232 - platform: i2s_audio
233 name: ESPHome I2S Media Player
234 dac_type: external
235 i2s_audio_id: i2s_out
236 i2s_dout_pin: "${i2s_dout_audio}"
237 mode: mono
238 on_pause:
239 - media_player.stop
240
241# Microphone configuration
242microphone:
243 - platform: i2s_audio
244 i2s_audio_id: i2s_in
245 i2s_din_pin: "${i2s_din_audio}" # SD
246 adc_type: external
247 id: mic_i2s
248 pdm: false
249
250# Voice assistant configuration
251voice_assistant:
252 microphone: mic_i2s