pungkulaa

Untitled

Apr 13th, 2024
25
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.61 KB | None | 0 0
  1. # 1.54" LCD TOUCH CAPTIVE ST7789V
  2. # 400 mA Litium battery
  3. # Triaxial accelerometer BMA423
  4. # Touch Screen Chip: FT6236U
  5. # LoRa SX1262
  6. # PMU Power Management: AXP2101
  7. # Speaker: PIR
  8. # DRV2605 Haptic Motor SDA: IO10 SCL: IO11
  9. # RTC Clock Module: PCF8563
  10.  
  11. ###############################
  12. # -> LILYGO-T-Watch-S3 <- #
  13. # -> ESPHOME <- #
  14. # -> https://github.com/velijv/LILYGO-T-Watch-S3-ESPHome <- #
  15. #############################
  16. substitutions:
  17. voice_assist_idle_phase_id: "1"
  18. voice_assist_listening_phase_id: "2"
  19. voice_assist_thinking_phase_id: "3"
  20. voice_assist_replying_phase_id: "4"
  21. voice_assist_not_ready_phase_id: "10"
  22. voice_assist_error_phase_id: "11"
  23. voice_assist_muted_phase_id: "12"
  24.  
  25. esphome:
  26. name: watch
  27. platformio_options:
  28. board_build.flash_mode: dio
  29. on_boot:
  30. priority: 600
  31. then:
  32. - display.page.show: esphome_logo
  33. - delay: 30s
  34. - if:
  35. condition:
  36. lambda: return id(init_in_progress);
  37. then:
  38. - lambda: id(init_in_progress) = false
  39.  
  40. esp32:
  41. board: esp32-s3-devkitc-1
  42. variant: esp32s3
  43. framework:
  44. type: arduino
  45. #type: esp-idf
  46. version: recommended
  47. # sdkconfig_options:
  48. # CONFIG_ESP32_S3_BOX_BOARD: "y"
  49.  
  50. flash_size: 16MB
  51.  
  52. psram:
  53. mode: octal
  54. speed: 80MHz
  55.  
  56. logger:
  57. hardware_uart: uart0
  58.  
  59. api:
  60. encryption:
  61. key: !secret api_key
  62.  
  63. #Custom Creates a service to start listening
  64. services:
  65. - service: va_start
  66. then:
  67. - voice_assistant.start:
  68. silence_detection: true
  69.  
  70. - service: va_stop
  71. then:
  72. - voice_assistant.stop
  73.  
  74. # OTA is required for Over-the-Air updating
  75. ota:
  76. password: !secret api_key
  77. # password: "dd217a9ae48399a5252385c22f4db6a3"
  78.  
  79. wifi:
  80. ssid: !secret wifi_ssid
  81. password: !secret wifi_password
  82.  
  83. ap:
  84. password: "12345678"
  85.  
  86. image:
  87. - file: https://pungkula.duckdns.org:1337/local/duckie2.png
  88. id: esphome_logo
  89. resize: 240x240
  90. # Sets up the improv via serial client for Wi-Fi provisioning.
  91. # Handy if your device has a usb port for the user to add credentials when they first get it.
  92. improv_serial:
  93. next_url: https://veli.ee/esphome?device_name={{device_name}}&ip_address={{ip_address}}&esphome_version={{esphome_version}}
  94.  
  95.  
  96. #output:
  97. #- platform: ledc
  98. # pin: ?
  99. # id: backlight_output
  100.  
  101. #light:
  102. # - platform: monochromatic
  103. # id: led
  104. # name: LCD Backlight
  105. # entity_category: config
  106. # output: backlight_output
  107. # restore_mode: RESTORE_DEFAULT_ON
  108. # default_transition_length: 250ms
  109.  
  110.  
  111.  
  112.  
  113. #remote_receiver:
  114. # pin: GPIO38
  115. # dump: all
  116. # Settings to optimize recognition of RF devices
  117. #tolerance: 50%
  118. #filter: 250us
  119. #idle: 4ms
  120. #buffer_size: 2kb
  121.  
  122. #remote_transmitter:
  123. # pin: GPIO39
  124. # carrier_duty_percent: 100%
  125.  
  126. # -> BUTTON <- #
  127. button:
  128. - platform: restart
  129. name: "Reboot Butler"
  130. entity_category: "diagnostic"
  131.  
  132. - platform: shutdown
  133. name: "Stäng av Butler"
  134. entity_category: "diagnostic"
  135.  
  136. - platform: factory_reset
  137. id: factory_reset_btn
  138. name: NOLLSTÄLL Butler
  139.  
  140. # -> SPI <- #
  141. spi:
  142. clk_pin: GPIO18
  143. mosi_pin: GPIO13
  144. #miso_pin: NULL
  145.  
  146.  
  147. # -> i2C <- # - voice_assistant.start_continuous:
  148. i2c:
  149. # - id: bus_a
  150. # sda: GPIO18
  151. # scl: GPIO11
  152. # scan: true
  153. # #interrupt: GPIO14
  154. - id: tsc
  155. sda: GPIO39
  156. scl: GPIO48
  157. scan: true
  158. #interrupt: GPIO16
  159.  
  160. # -> i2s audio <- #
  161. i2s_audio:
  162. id: i2saudio
  163. i2s_lrclk_pin: GPIO15
  164. #i2s_bclk_pin: GPIO18 #?
  165. #i2s_mclk_pin: 15
  166. #i2c_SDOUT: GPIO46
  167.  
  168. # -> MICROPHONE <- #
  169. #microphone:
  170. # - platform: i2s_audio
  171. # bits_per_sample: 16bit
  172. # channel: right
  173. # i2s_din_pin: ${BOARD_MIC_DATA}
  174. # adc_type: external
  175. # pdm: true
  176.  
  177.  
  178. microphone:
  179. - platform: i2s_audio
  180. id: watch_mic
  181. bits_per_sample: 16bit
  182. channel: right
  183. i2s_din_pin: GPIO47
  184. adc_type: external
  185. pdm: true
  186. #SCLK PIN IO44
  187.  
  188. # -> MEDIA PLAYER <- #
  189. media_player:
  190. - platform: i2s_audio
  191. id: watch_player
  192. i2s_dout_pin:
  193. number: GPIO46 # ${BOARD_DAC_IIS_DOUT}
  194. ignore_strapping_warning: true
  195. dac_type: external
  196. mode: mono
  197. i2s_comm_fmt: msb
  198.  
  199.  
  200. #########################
  201. # -> VOICE ASSISTANT <- #
  202. #########################
  203.  
  204. voice_assistant:
  205. id: va
  206. microphone: watch_mic
  207. #speaker:
  208. media_player: watch_player
  209. use_wake_word: true
  210. noise_suppression_level: 0
  211. auto_gain: 31dBFS
  212. volume_multiplier: 2.0
  213. # vad_threshold: 3
  214. on_listening:
  215. - lambda: id(voice_assistant_phase) = ${voice_assist_listening_phase_id};
  216. on_stt_vad_end:
  217. - lambda: id(voice_assistant_phase) = ${voice_assist_thinking_phase_id};
  218. on_tts_end:
  219. - delay: 5s
  220. - homeassistant.service:
  221. service: media_player.play_media
  222. data:
  223. entity_id: media_player.ha
  224. media_content_id: !lambda 'return x;'
  225. media_content_type: music
  226. announce: "true"
  227. on_error:
  228. - if:
  229. condition:
  230. lambda: return !id(init_in_progress);
  231. then:
  232. - lambda: id(voice_assistant_phase) = ${voice_assist_error_phase_id};
  233. on_client_disconnected:
  234. - lambda: id(voice_assistant_phase) = ${voice_assist_not_ready_phase_id};
  235.  
  236. ######################
  237. ######################
  238. # -> DISPLAY <- #
  239. display:
  240. # - platform: ili9xxx
  241. # - platform: ST7789V
  242. # cs_pin: GPIO12
  243. # dc_pin: GPIO38
  244. # id: screen
  245. # model: ST7789V
  246. # transform:
  247. # mirror_x: true
  248. # mirror_y: true
  249. # swap_xy: false
  250. # dimensions:
  251. # width: 240
  252. # height: 240
  253. # offset_width: 0
  254. # offset_height: 80
  255. # invert_colors: true
  256.  
  257. - platform: ili9xxx
  258. cs_pin: GPIO12
  259. dc_pin: GPIO38
  260. id: screen
  261. model: ST7789V
  262. transform:
  263. mirror_x: true
  264. mirror_y: true
  265. swap_xy: false
  266. dimensions:
  267. width: 240
  268. height: 240
  269. offset_width: 0
  270. offset_height: 80
  271. invert_colors: true
  272.  
  273. # -> TOUCHSCREEN <- #
  274. touchscreen:
  275. - platform: ft63x6
  276. interrupt_pin:
  277. number: GPIO16
  278. # allow_other_uses: true
  279. display: screen
  280. id: tscreen
  281. i2c_id: tsc
  282. calibration:
  283. x_min: 0
  284. x_max: 240
  285. y_min: 0
  286. y_max: 240
  287. on_touch:
  288. # - light.turn_on:
  289. # id: led
  290. # brightness: 50%
  291. # - voice_assistant.start:
  292. # silence_detection: true
  293. - if:
  294. condition: voice_assistant.is_running
  295. then:
  296. - voice_assistant.stop:
  297. else:
  298. - voice_assistant.start_continuous:
  299.  
  300.  
  301.  
  302.  
  303. ##### SWITCH ######
  304. switch:
  305. # - platform: template
  306. # name: Mute
  307. # id: mute
  308. # optimistic: true
  309. # restore_mode: RESTORE_DEFAULT_OFF
  310. # entity_category: config
  311. # on_turn_off:
  312. # - if:
  313. # condition:
  314. # lambda: return !id(init_in_progress);
  315. # then:
  316. # - lambda: id(va).set_use_wake_word(true);
  317. # - lambda: id(voice_assistant_phase) = id(voice_assist_idle_phase_id);
  318. # - if:
  319. # condition:
  320. # not:
  321. # - lambda: return id(voice_assistant).is_running();
  322. # then:
  323. # - lambda: id(voice_assistant).start_continuous();
  324. # on_turn_on:
  325. # - if:
  326. # condition:
  327. # lambda: return !id(init_in_progress);
  328. # then:
  329. # - lambda: id(voice_assistant).stop();
  330. - platform: template
  331. name: Use wake word
  332. id: use_wake_word
  333. optimistic: true
  334. restore_mode: RESTORE_DEFAULT_OFF
  335. entity_category: config
  336. on_turn_on:
  337. - lambda: id(va).set_use_wake_word(true);
  338. - if:
  339. condition:
  340. not:
  341. - voice_assistant.is_running
  342. then:
  343. - voice_assistant.start_continuous
  344. on_turn_off:
  345. - voice_assistant.stop
  346. - lambda: id(va).set_use_wake_word(false);
  347.  
  348.  
  349.  
  350. ##### SCRIPT #######
  351.  
  352.  
  353. #### GLOBALS ####
  354. globals:
  355. - id: init_in_progress
  356. type: bool
  357. restore_value: no
  358. initial_value: "true"
  359. - id: voice_assistant_phase
  360. type: int
  361. restore_value: no
  362. initial_value: ${voice_assist_not_ready_phase_id}
  363.  
  364.  
  365. color:
  366. - id: idle_color
  367. hex: ${idle_illustration_background_color}
  368. - id: listening_color
  369. hex: ${listening_illustration_background_color}
  370. - id: thinking_color
  371. hex: ${thinking_illustration_background_color}
  372. - id: replying_color
  373. hex: ${replying_illustration_background_color}
  374. - id: loading_color
  375. hex: ${loading_illustration_background_color}
  376. - id: error_color
  377. hex: ${error_illustration_background_color}
  378.  
Advertisement
Add Comment
Please, Sign In to add comment