Advertisement
ItsNotMyFault79

Untitled

Oct 9th, 2024
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 6.29 KB | None | 0 0
  1. substitutions:
  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.  
  25. esphome:
  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.  
  34. esp32:
  35.   board: esp32dev
  36.   framework:
  37.     type: arduino
  38.  
  39. # Enable logging
  40. logger:
  41.   logs:
  42.    # levels include NONE, ERROR, WARN, INFO, DEBUG
  43.     component: ERROR
  44.  
  45. # Enable Home Assistant API
  46. api:
  47.   encryption:
  48.     key: !secret esphome_encryption_key
  49.  
  50. ota:
  51.  - platform: esphome
  52.    password: !secret esphome_ota_password
  53.    id: my_ota
  54.  
  55. wifi:
  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
  75. web_server:
  76.   port: 80
  77.   version: 3  
  78.  
  79. captive_portal:
  80. button:
  81.   - platform: restart
  82.     icon: mdi:power-cycle
  83.     name: "ESP Reboot"
  84.  
  85. switch:
  86.   - platform: gpio
  87.     id: gain_boost
  88.     name: "Gain Boost"
  89.     inverted: True
  90.     pin: "${gain_pin}"
  91.     restore_mode: ALWAYS_ON
  92.  
  93. sensor:
  94.   - platform: adc
  95.     pin:
  96.       number: "${pot_pin}"
  97.       mode:
  98.         input: true
  99.         pullup: False
  100.     name: "Volume Pot"
  101.     id: my_sensor
  102.     attenuation: auto
  103.     update_interval: 15s
  104.  
  105. # Reports internal temperature of the ESP32
  106.   - platform: internal_temperature
  107.     name: "Internal Temperature"
  108.     entity_category: "diagnostic"
  109.     update_interval: 30s
  110.  
  111. # Reports uptime
  112.   - platform: uptime
  113.     name: Uptime
  114.     entity_category: "diagnostic"
  115.     update_interval: 300s
  116.  
  117. # Reports WiFi signal strength  
  118.   - platform: wifi_signal
  119.     name: "WiFi Signal"
  120.     accuracy_decimals: 1
  121.     entity_category: "diagnostic"
  122.     update_interval: 5s
  123.  
  124. binary_sensor:
  125. # Button section normally open closed to ground as ESP pins have weak pull-up power
  126.   - platform: gpio
  127.     name: Power Switch
  128.     pin:
  129.       number: "${pot_power_pin}"
  130.       mode:
  131.         input: true
  132.         pullup: true
  133.       inverted: true
  134.     filters:
  135.       - delayed_off: 20ms
  136.     on_press:
  137.       - logger.log: Knob Power ON
  138. #      - display.page.show_next: oled_display
  139. #      - component.update: oled_display
  140.  
  141.   - platform: gpio
  142.     name: Talk Button
  143.     pin:
  144.       number: "${talk_button_pin}"
  145.       mode:
  146.         input: true
  147.         pullup: true
  148.       inverted: true
  149.     filters:
  150.       - delayed_off: 20ms
  151.     on_press:
  152.       - logger.log: Talk Button Pressed
  153. #      - display.page.show_next: oled_display
  154. #      - component.update: oled_display
  155.     on_release:
  156.       - logger.log: Talk Button Released
  157.      
  158.  
  159. # Update LED status based on alarm loop state
  160.   - platform: homeassistant
  161.     name: "Loop Status"
  162.     id: loop1_status
  163.     entity_id: binary_sensor.alarm_house_door_window_sensors
  164.     publish_initial_state: True
  165.     on_state:
  166.       then:
  167.          script.execute: update_led
  168.  
  169. #   System status report for ONLINE or OFFLINE display
  170.   - platform: status
  171.     name: "Node Status"
  172.     id: system_status
  173.     publish_initial_state: True
  174.     on_state:
  175.       then:
  176.         - script.execute: update_led
  177.  
  178. # Example configuration entry
  179. script:
  180.   - id: update_led
  181.     then:
  182.       - lambda: |-
  183.           if (!id(system_status).state)
  184.              id(alert_light).turn_on().set_rgb(0, 0, 1).set_brightness(0.5).set_effect("Fast Pulse").perform();
  185.           else if (!id(loop1_status).state)
  186.              id(alert_light).turn_on().set_rgb(0, 1, 0).set_brightness(0.25).set_effect("None").perform();
  187.           else
  188.              id(alert_light).turn_off().perform();
  189.  
  190. # Single Neopixel LED
  191. light:
  192.   - platform: neopixelbus
  193.     type: GRB
  194.     variant: WS2811
  195.     pin: "${rgb_led_pin}"
  196.     num_leds: 1
  197.     name: "Alert Light"
  198.     id: alert_light
  199.     default_transition_length: 0s
  200.     effects:
  201.       - pulse:
  202.           name: "Slow Pulse"
  203.           transition_length:
  204.             on_length: 500ms
  205.             off_length: 500ms
  206.           update_interval: 1s
  207.       - pulse:
  208.           name: "Fast Pulse"
  209.           transition_length:
  210.             on_length: 250ms
  211.             off_length: 250ms
  212.           update_interval: 500ms
  213.  
  214. # This allows the on-board blue LED to indicate conneciton and other status
  215. status_led:
  216.   pin:
  217.     number: "${led1_pin}"
  218.     inverted: False
  219.  
  220. # I2S pin config
  221. i2s_audio:
  222.   - id: i2s_out
  223.     i2s_lrclk_pin: "${i2s_out_lrclk_pin}"
  224.     i2s_bclk_pin: "${i2s_out_bclk_pin}"
  225.   - id: i2s_in
  226.     i2s_lrclk_pin: "${i2s_in_lrclk_pin}" # WS
  227.     i2s_bclk_pin: "${i2s_in_bclk_pin}" # CLK
  228.  
  229. # Media player configuration
  230. media_player:
  231.   - platform: i2s_audio
  232.     name: ESPHome I2S Media Player
  233.     dac_type: external
  234.     i2s_audio_id: i2s_out
  235.     i2s_dout_pin: "${i2s_dout_audio}"
  236.     mode: mono
  237.     on_pause:
  238.      - media_player.stop
  239.  
  240. # Microphone configuration
  241. microphone:
  242.   - platform: i2s_audio
  243.     i2s_audio_id: i2s_in
  244.     i2s_din_pin: "${i2s_din_audio}" # SD
  245.     adc_type: external
  246.     id: mic_i2s
  247.     pdm: false
  248.  
  249. # Voice assistant configuration
  250. voice_assistant:
  251.   microphone: mic_i2s
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement