Advertisement
salviaguru1

esp32-s3-box-3 ztlumení

Feb 8th, 2025
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.28 KB | None | 0 0
  1. ESP:
  2. voice_assistant:
  3. on_tts_end:
  4. - homeassistant.service:
  5. service: media_player.play_media
  6. data:
  7. entity_id: media_player.obyvaci_pokoj
  8. media_content_id: !lambda 'return x;'
  9. media_content_type: music
  10. announce: "true"
  11. Packages
  12.  
  13. #slouží k uložení původní hlasitosti
  14.  
  15. input_number:
  16. sonos_puvodni_hlasitost:
  17. name: Sonos původní hlasitost
  18. min: 0
  19. max: 1
  20. step: 0.01
  21.  
  22. #slouží k uložení původní hlasitosti
  23. automation:
  24. - id: "update_sonos_volume"
  25. alias: "Aktualizace Sonos původní hlasitosti"
  26. description: "Aktualizuje input_number.sonos_puvodni_hlasitost při změně hlasitosti přehrávače"
  27. trigger:
  28. - platform: state
  29. entity_id: media_player.obyvaci_pokoj
  30. attribute: volume_level
  31. condition:
  32. - condition: state
  33. entity_id: assist_satellite.esp32_s3_box_3_2e8148_assist_satellite
  34. state: "idle" # Aktualizace probíhá pouze, když je asistent v klidu
  35. action:
  36. - service: input_number.set_value
  37. target:
  38. entity_id: input_number.sonos_puvodni_hlasitost
  39. data:
  40. value: "{{ state_attr('media_player.obyvaci_pokoj', 'volume_level') }}"
  41. mode: single
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50. - id: "zmena_hlasitosti_s3_box3"
  51. alias: "Změna hlasitosti ESP32 s3_box3 při asistenci"
  52. description: "Sniž hlasitost při poslouchání, zpracovávání a nastav na 0.25 při odpovídání"
  53. trigger:
  54. - platform: state
  55. entity_id: assist_satellite.esp32_s3_box_3_2e8148_assist_satellite
  56. to: "listening"
  57. - platform: state
  58. entity_id: assist_satellite.esp32_s3_box_3_2e8148_assist_satellite
  59. to: "processing"
  60. - platform: state
  61. entity_id: assist_satellite.esp32_s3_box_3_2e8148_assist_satellite
  62. to: "responding"
  63. condition: []
  64. action:
  65. - choose:
  66. # Pokud stav přejde do "listening" nebo "processing", ztlum na 0
  67. - conditions:
  68. - condition: template
  69. value_template: >-
  70. {{ trigger.to_state.state in ['listening', 'processing'] }}
  71. sequence:
  72. - service: media_player.volume_set
  73. target:
  74. entity_id: media_player.obyvaci_pokoj
  75. data:
  76. volume_level: 0
  77. # Pokud stav přejde do "responding", nastav hlasitost na 0.25
  78. - conditions:
  79. - condition: state
  80. entity_id: assist_satellite.esp32_s3_box_3_2e8148_assist_satellite
  81. state: "responding"
  82. sequence:
  83. - service: media_player.volume_set
  84. target:
  85. entity_id: media_player.obyvaci_pokoj
  86. data:
  87. volume_level: 0.35
  88. # Po návratu do "idle" vrať původní hlasitost
  89. - wait_for_trigger:
  90. - platform: state
  91. entity_id: assist_satellite.esp32_s3_box_3_2e8148_assist_satellite
  92. to: "idle"
  93. - service: media_player.volume_set
  94. target:
  95. entity_id: media_player.obyvaci_pokoj
  96. data:
  97. volume_level: "{{ states('input_number.sonos_puvodni_hlasitost') | float }}"
  98. mode: restart
  99.  
  100.  
  101.  
  102.  
  103.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement