Button Triggers Voice Assist Listen

Hello community.

I currently have Assist working with cloud, Gemini and starts with wake word, connected to the Voice Preview box and other mics and media players around the house.
I am trying to create an automation where clicking a button on my physical Onvis switch will prompt assistant to start listening - kind of making the button act as the wake word.
I am unable to find any entity or action where assist starts listening to link it to the button. Can you please assist on how to achieve that?

2 Likes

Hi Lou,
Could you solve it?
Thanks!

Add a button in the esphome code that will launch the voice assistant. I won’t go into details, since you should understand well what exactly you are doing

Thanks a lot, MCHK.

In case somebody needs the code:

switch:
  - platform: template
    name: "Voice Assistant Trigger"
    id: voice_assistant_trigger
    turn_on_action:
      - if:
          condition:
            lambda: return !id(init_in_progress) && !id(color_changed);
          then:
            - if:
                condition:
                  switch.is_on: timer_ringing
                then:
                  - switch.turn_off: timer_ringing
                else:
                  - if:
                      condition:
                        media_player.is_announcing:
                      then:
                        media_player.stop:
                          announcement: true
                      else:
                        - if:
                            condition:
                              voice_assistant.is_running:
                            then:
                              - voice_assistant.stop:
                            else:
                              - if:
                                  condition:
                                    media_player.is_playing:
                                  then:
                                    - media_player.pause:
                                  else:
                                    - if:
                                        condition:
                                          and:
                                            - switch.is_off: master_mute_switch
                                            - not: voice_assistant.is_running
                                        then:
#                                          - script.execute:
#                                              id: play_sound
#                                              priority: true
#                                              sound_file: !lambda return id(center_button_press_sound);
#                                          - delay: 300ms
                                          - voice_assistant.start:
      - delay: 2s  # Optional: Automatisches Ausschalten
      - switch.turn_off: voice_assistant_trigger

Example automation to trigger (including lowering the volume of the media player). Just remove it, if you don’t need it:

alias: "Voice: Sprachassistent per Switch triggern"
triggers:
**YOUR TRIGGER**
actions:
  - service: input_number.set_value
    target:
      entity_id: **input_number.spotify_voice_save_volume_setting**
    data:
      value: "{{ state_attr('**media_player.spotifyplus**', 'volume_level') | float(0.5) }}"
  - service: media_player.volume_set
    target:
      entity_id: **media_player.spotifyplus**
    data:
      volume_level: 0.2
  - service: switch.turn_on
    target:
      entity_id: **switch.home_assistant_voice_abc_voice_assistant_trigger**
  - wait_for_trigger:
      - platform: state
        entity_id: **assist_satellite.home_assistant_voice_abc_assist_satellit**
        to: "idle"
    timeout: "00:00:10"
  - service: media_player.volume_set
    target:
      entity_id: **media_player.spotifyplus**
    data:
      volume_level: "{{ states('**input_number.spotify_voice_save_volume_setting**') | float(0.5) }}"
2 Likes