Triggering voice announcements from HA

Is there any way for HA to trigger Alexa to say something (something custom - as dictated by HA)?
What about Google Assistant?
What about the Google Assistant for hass.io?

I’m trying to determine what my options are for an automation that looks like this…

  • HA checks weather
  • HA sees that it’s likely to start raining in the next hour
  • HA checks window sensors and sees that the dining room and bedroom windows are open.
  • HA triggers Alexa/Google Assistant/Mycroft/_______ to say, “It’s going to rain soon. You might want to close the dining room and bedroom windows.”

I’m not sure about Alexa, but with the google home you can use tts.google_say with the data of {"message": "your message to speak", "entity_id":"the entity id of your google home"}.

Thanks, kjr1995! Do you know if that’s a local command? Or do Google’s servers need to get involved?

I’m not sure.

Yes, Google servers are involved to generate the MP3 file to be announced. So you will need an active internet connection for this announcement.

Alternatively you can record your own MP3 and send the command directly to you media player

Thanks, xx_Nexus_xx!

You could also look into Amazon Polly, as it doesn’t take long to get bored with the way the Google Home speaks your text. Polly supports SSML which allows you to insert pauses, emphasis, pitch, rate etc.

There’s a free tier for a year, and after that you get charged per million characters, so it’s cheap but not free. I think. I’m still in the free year.

Thanks, michaelblight! Now we’re talking! How do I get Amazon Polly setup and working with HA? Also, any way to keep things local?

Check out this thread. If you aren’t afraid of a little coding you can use Appdaemon to send text to this and it will output it on the desired alexa unit.

Right now, I have mine telling me when the back door is opened if it’s after we have set the nighttime mode at the house. I open the door and Alexa pops up and says “the back door is open, please remember to close and lock it when you are done”.

No amazon AWS type coding required.

VERY cool! I’m not afraid of coding (though I’m a python novice – I do a lot better when I have example code that I can paste and modify).I’m definitely going to look into that!

you can also look at this for the Google option (apparently its much nicer sounding than the usual TTS:

With that custom component linked to by @turboc there is no advanced coding required. It simply exposes your echo devices to HA as media players. Which allows you to use the standard TTS coding in yaml you may already be accustomed to.

example:

- alias: Weekly TTS Test
  trigger:
    platform: time
    at: '12:15:00'
  condition:
    condition: time
    weekday:
      - wed
  action:
    - service: media_player.alexa_tts
      data:
        entity_id: 
          - media_player.computer_room_dot
          - media_player.kitchen_dot
          - media_player.livingroom_dot
          #- media_player.master_bedroom_dot
        message: "This is a weekly test of the announcing system" 

No Appdaemon or anything extra required.

2 Likes

Nice, I do all my automations in AD so I wasn’t sure about the HA templates. Thanks for the post.