Voice Assistant - turn recognition off/on from automation

Starting to use this locally with the PE and also Echo, so mostly in exploration mode but want to shift entirely soon.

One thing I’d like to do (and frankly should do with Google, so would love the same technique to work there):

Is there a technique available in a script to turn recognition off system wide, such as when no one is home? And turn it back on later?

Yes, I think I can turn off each mic (though that doesn’t work for google from script), but I’d rather just do something like

switch.voice_assistant_active => off

Is there such a switch somewhere?

Partly this is to annoy my son who loves to show me he can shout “Hey google, open the garage door” and it thinks he’s me (similar voices) and opens. But just in an abundance of caution to turn off anyone being able to do something similar when I’m gone (when I’m here, I can take care of such issues personally, don’t need to automate it).

Linwood

PS. Yes, I’m aware the doors should be security issues, but I have them as covers so I don’t have shout security codes. I mean really – how secure is a secret code you have to shout at the house?

Hi, it’s not really clear what you are asking but there is a

switch.home_assistant_vpe_mute

which mutes the mic and therefore it does not respond to any voice commands anymore.
When muted, it still functions for announcements.

That looks perfect but it must work only on the preview edition? I don’t see anything with the word mute related to assistant on mine, including the echo (M5) that I am testing with at the moment. My VPE comes tomorrow.

It would be nice to mute all mics (or stop the STT processing for every satellite) with one switch, but if I need to do it individually that’s fine.

Just use a helper toggle and an automation. I have no VPE’s buy my voice devices based on VPE code have an enable voice switch.

The Atom Echo M5 does not have this by default, dunno if it’s even possible, but maybe there is some code out there that has it.

As @Arh suggests: create a helper toggle which becomes the master switch as a condition in your automations to make your voice assistants (not) respond.

Maybe I’m coming at this from the wrong direction, these all see piecemeal and awkward.

It seems to me there should be a switch that simply disables ALL of the activity in the Speech to Text, or the Conversation Agent – just stop. That breaks the pipeline for all satellites in one common place.

I just can’t find such a switch. Yet.

Which would break the heck out of a bunch of things that rely on the speech pipelines that have nothing to do with voice. Sorry. Bad idea.

HAs direction is clear - yoiu can see it in how they implemented the mute on the vpe. The m5 stack dev for the firmware you’re using just needs to do the same. (or you can add it to yours)

From there it’s triviall to create a script that says [all the switches looking like this] .turnoff and meanwhile the conversation pipe still works.

Hmmm… TTS I get, I’m curious what the Conversation Agent breaks other than voice assistant?

But I will accept your answer at face value, and go put a mute in the (official BTW) firmware that gets exposed.

Now what would be cool is if it just stopped all action and not response, otherwise it’s going to be hard to get a legitimate “OK, Hall, open the pod bay doors” with a “I can’t do that” response. :slight_smile:

Preview edition comes today, I may just give up on the Atom’s. I have a couple more of those on order to play with as well, the newer version. Their speaker is worthless, but at present I have it answering via the nearby Google Mini so I can actually hear it. That works rather well, it’s microphone is not awful, and is probably good enough for use in rooms where there won’t be much conversation or other noises. Certainly the price is right.

I’m curious to see what happens when two of them hear the same command.

Code that seems to work in case anyone needs it (added after the project copy in from github):

switch:
  - platform: template
    name: "Microphone Mute"
    id: echo_microphone_mute_switch
    icon: "mdi:microphone-off"
    optimistic: true
    restore_mode: RESTORE_DEFAULT_OFF
    entity_category: config
    on_turn_on:
      - microphone.mute:
          id: echo_microphone
    on_turn_off:
      - microphone.unmute:
          id: echo_microphone

While I’m on the subject if anyone needs it here is how to copy the response to a local google mini (assuming that’s already set up as a media player in HA):

voice_assistant: 
  on_tts_end:
      - homeassistant.action:
          action: media_player.play_media
          data:
            entity_id: media_player.office_mini  # <- Replace with your exact HA speaker entity
            media_content_type: music
            media_content_id: !lambda 'return x;'          # <- This passes the audio URL from HA to     

Note the above plays it in both places, but the Atom is barely audible. Also, note that this isn’t terribly useful if you want to stop having Google involved, but I will likely leave google muted and use them for speakers (and only speakers) going forward.