Guest User

Untitled

a guest
Jun 13th, 2024
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 7.54 KB | None | 0 0
  1. esphome:
  2.   name: xiao-s3-new
  3.   friendly_name: Xiao-S3-New
  4.   platformio_options:
  5.     board_build.flash_mode: dio
  6.   on_boot:
  7.     - priority: -100
  8.       then:
  9.         - wait_until: api.connected
  10.         - light.turn_on: ledd
  11.         - delay: 250ms
  12.         - light.turn_off: ledd
  13.         - delay: 1s
  14.         - light.turn_on: ledd
  15.         - delay: 2s
  16.         - light.turn_off: ledd
  17.  
  18. esp32:
  19.  #board: seeed_xiao_esp32s3
  20.   board: esp32-s3-devkitc-1
  21.   variant: esp32s3
  22.   flash_size: 8MB
  23.   framework:
  24.     type: esp-idf
  25.     version: recommended
  26.     sdkconfig_options:
  27.       CONFIG_ESP32_S3_BOX_BOARD: "y"
  28.    
  29. psram:
  30.   mode: octal # Please change this to quad for N8R2 and octal for N16R8
  31.   speed: 80MHz
  32.  
  33. # Enable logging
  34. logger:
  35. # Enable Home Assistant API
  36. api:
  37.   encryption:
  38.     key: "Hfx1jqxdXsPYLLIvgFu/Qz8Trn3rAl1sV13PX0TxsVc="
  39.   on_client_connected:
  40.         then:
  41.           - delay: 50ms
  42.           - light.turn_on: ledd
  43.           - delay: 2s
  44.           - light.turn_off: ledd
  45.           - micro_wake_word.start:
  46.   on_client_disconnected:
  47.         then:
  48.           - voice_assistant.stop:
  49.  
  50.  
  51. ota:
  52.   password: "a2b6e8adb2f89847eb5dfe0f306183d0"
  53.  
  54. wifi:
  55.   ssid: !secret wifi_ssid
  56.   password: !secret wifi_password
  57.  
  58.   # Enable fallback hotspot (captive portal) in case wifi connection fails
  59.   ap:
  60.     ssid: "Xiao-S3-New Fallback Hotspot"
  61.     password: "opgX7pFduQmu"
  62.   fast_connect: on
  63.   power_save_mode: none
  64.   manual_ip:
  65.     static_ip: 192.168.1.50
  66.     gateway: 192.168.1.1
  67.     subnet: 255.255.255.0
  68.     dns1: 192.168.1.1
  69.   on_connect:
  70.     then:
  71.       - micro_wake_word.start:
  72.       - light.turn_on: ledd
  73.       - delay: 250ms
  74.       - light.turn_off: ledd
  75.       - delay: 500ms
  76.       - light.turn_on: ledd
  77.       - delay: 250ms
  78.       - light.turn_off: ledd
  79.  
  80.  
  81. captive_portal:
  82.  
  83.  
  84. output:
  85.   - id: rgb_GREEN
  86.     platform: ledc
  87.     pin:
  88.       number: 2
  89.       inverted: true
  90.   - id: rgb_RED
  91.     platform: ledc
  92.     pin:
  93.       number: 3
  94.       inverted: true
  95.   - id: rgb_BLUE
  96.     platform: ledc
  97.     pin:
  98.       number: 1
  99.       inverted: true
  100.   - id: light_output
  101.     #platform: gpio
  102.     platform: ledc
  103.     pin: GPIO21
  104.     inverted: true
  105.  
  106.  
  107. light:
  108.   - platform: rgb
  109.     name: "RGB Lights"
  110.     id: RGB_Lights
  111.     red: rgb_RED
  112.     green: rgb_GREEN
  113.     blue: rgb_BLUE
  114.     default_transition_length: 0s
  115.     effects:
  116.       - pulse:
  117.           name: "Slow Pulse"
  118.           transition_length: 250ms
  119.           update_interval: 250ms
  120.           min_brightness: 50%
  121.           max_brightness: 100%
  122.       - pulse:
  123.           name: "Fast Pulse"
  124.           transition_length: 100ms
  125.           update_interval: 100ms
  126.           min_brightness: 50%
  127.           max_brightness: 100%
  128.  
  129.  
  130.   #- platform: binary
  131.   - platform: monochromatic
  132.     name: "LED"
  133.     id: ledd
  134.     output: light_output
  135.     default_transition_length: 250ms
  136.     effects:
  137.       - strobe:
  138.           name: Slow Strobe
  139.           colors:
  140.             - state: true
  141.               brightness: 100%
  142.               duration: 500ms
  143.             - state: false
  144.               duration: 500ms
  145.       - strobe:
  146.           name: Fast Strobe
  147.           colors:
  148.             - state: true
  149.               brightness: 100%
  150.               duration: 100ms
  151.             - state: false
  152.               duration: 100ms
  153.       - pulse:
  154.           name: "Slow Pulse"
  155.           transition_length: 250ms
  156.           update_interval: 250ms
  157.           min_brightness: 50%
  158.           max_brightness: 100%
  159.       - pulse:
  160.           name: "Fast Pulse"
  161.           transition_length: 100ms
  162.           update_interval: 100ms
  163.           min_brightness: 50%
  164.           max_brightness: 100%
  165.  
  166.  
  167. button:
  168.   - platform: restart
  169.     name: "Restart"
  170.     id: but_rest
  171.  
  172.  
  173.  
  174.  
  175.  
  176.  
  177. i2s_audio:
  178.   - id: i2s_in # For microphone
  179.     i2s_lrclk_pin: 6  #WS
  180.     i2s_bclk_pin: 5 #SCK
  181.  
  182.   - id: i2s_out #For Speaker
  183.     i2s_lrclk_pin: 8  #LRC
  184.     i2s_bclk_pin: 9 #BLCK
  185.  
  186. adf_pipeline:
  187.   - platform: i2s_audio
  188.     type: audio_out
  189.     id: adf_i2s_out
  190.     i2s_audio_id: i2s_out
  191.     i2s_dout_pin: 44
  192.  
  193.   - platform: i2s_audio
  194.     type: audio_in
  195.     id: adf_i2s_in
  196.     i2s_audio_id: i2s_in
  197.     pdm: false
  198.     i2s_din_pin: 4
  199.     channel: left
  200.     sample_rate: 16000
  201.     bits_per_sample: 16bit
  202.  
  203. microphone:
  204.   - platform: adf_pipeline
  205.     id: mic
  206.     pipeline:
  207.      - adf_i2s_in
  208.       - self
  209.  
  210. #speaker:
  211.   #- platform: i2s_audio
  212.     #id: external_speaker
  213.     #dac_type: external
  214.     #i2s_audio_id: i2s_in
  215.     #i2s_dout_pin: 4
  216.     #mode: mono
  217.  
  218.  
  219. media_player:
  220.   - platform: adf_pipeline
  221.     id: spk
  222.     name: idf_player-mini
  223.     internal: false
  224.     pipeline:
  225.      - self
  226.       - adf_i2s_out
  227.     on_play:
  228.       - light.turn_on:
  229.           id: ledd
  230.           brightness: 100%
  231.           effect: "Slow Pulse"
  232.     on_pause:
  233.       - light.turn_off: ledd
  234.     on_idle:
  235.       - micro_wake_word.start:
  236.          
  237.  
  238.  
  239. external_components:
  240.   - source: my_components
  241.   - source:
  242.       type: git
  243.       url: https://github.com/gnumpi/esphome_audio
  244.       ref: main
  245.     components: [ adf_pipeline, i2s_audio ]
  246.     refresh: 0s
  247.  
  248.  
  249. micro_wake_word:
  250.   on_wake_word_detected:
  251.    
  252.     - voice_assistant.start:
  253.         wake_word: !lambda return wake_word;
  254.         silence_detection: true
  255.     - light.turn_on:
  256.         id: RGB_Lights
  257.         effect: "Slow Pulse"
  258.         red: 80%
  259.         green: 0%
  260.         blue: 80%
  261.         brightness: 100%
  262.   model: okay_nabu
  263.  
  264.  
  265.  
  266. voice_assistant:
  267.   id: va
  268.   microphone: mic
  269.   #speaker: external_speaker
  270.   media_player: spk
  271.   use_wake_word: false
  272.   noise_suppression_level: 4
  273.   auto_gain: 31dBFS
  274.   volume_multiplier: 8.0
  275.   on_listening:
  276.     - light.turn_on:
  277.         id: ledd
  278.         brightness: 100%
  279.         #effect: "Slow Strobe"
  280.   on_stt_vad_end:
  281.     - light.turn_on:
  282.         id: RGB_Lights
  283.         effect: "Fast Pulse"
  284.         red: 80%
  285.         green: 0%
  286.         blue: 80%
  287.         brightness: 100%
  288.   on_stt_end:
  289.     - light.turn_on:
  290.         id: RGB_Lights
  291.         effect: "Fast Pulse"
  292.         red: 80%
  293.         green: 0%
  294.         blue: 80%
  295.         brightness: 100%
  296.     - logger.log:
  297.         format: "I heard : %s"
  298.         args: ['x.c_str()']
  299.         level: INFO
  300.   #on_tts_stream_start:
  301.     #- light.turn_on:
  302.           #id: ledd
  303.           #effect: "Slow Strobe"
  304.   #on_tts_stream_end:
  305.     #- light.turn_off: ledd
  306.   on_error:
  307.     - micro_wake_word.start:
  308.   #on_idle:
  309.     #- light.turn_off: ledd
  310.   on_tts_end:
  311.    #- delay: 3s
  312.     - wait_until:
  313.         not:
  314.           - voice_assistant.is_running:
  315.          #- media_player.is_playing:
  316.     #- delay: 1s
  317.  
  318.  
  319.  
  320.   on_end:
  321.     then:
  322.       - light.turn_off: RGB_Lights
  323.       - light.turn_off: ledd
  324.       - micro_wake_word.start:
  325.    
  326.    
  327.   #on_client_connected:
  328.     #- light.turn_on: ledd
  329.     #- delay: 2s
  330.     #- light.turn_off: ledd
  331.  
  332.   #on_client_disconnected:
  333.     #- if:
  334.         #condition:
  335.           #switch.is_on: use_wake_word
  336.         #then:
  337.           #- micro_wake_word.stop:
  338.   #on_tts_stream_start:
  339.     #- light.turn_off:
  340.         #id: RGB_Lights
  341.     #- voice_assistant.stop:
  342.     #- delay: 1s
  343.     #- voice_assistant.start_continuous:
  344.  
  345.  
  346.  
  347. switch:
  348.   - platform: template
  349.     name: Mute Microphone
  350.     id: use_wake_word
  351.     optimistic: true
  352.     restore_mode: RESTORE_DEFAULT_OFF
  353.     entity_category: config
  354.     on_turn_off:
  355.       - micro_wake_word.start:
  356.       - light.turn_off: ledd
  357.     on_turn_on:
  358.       - micro_wake_word.stop:
  359.      - voice_assistant.stop
  360.       - lambda: id(va).set_use_wake_word(false);
  361.       - light.turn_on:
  362.           id: ledd
  363.           brightness: 50%
  364.  
Advertisement
Add Comment
Please, Sign In to add comment