Trigger a Google Assistant command from HA?

I just got Home Assistant TTS going with my Google Home, and it’s great. It got me wondering…is there some way to use HA to trigger commands to Google Home? For example, it would be great to automatically trigger a weather report spoken on the Home when a motion sensor detects me entering the kitchen in the morning. It would be the equivalent of me asking it, “OK google, what’s the forecast for today?”

How could something like that be accomplished? Does the Google Assistant API support issuing “voice” commands that aren’t actually spoken?

1 Like

At the moment, it’s kind of Rube Goldbergish, but some folks are sending tts commands to a media player within range of the GHome and using that to trigger commands.

You could just add a weather sensor to HA and use a template to pipe the forecast over. Sure, it isn’t Google Assistant figuring out the weather for you, but who cares.

Haha, that’s creative.

Interesting…I haven’t really worked with templates yet. Going to dig in. Can you show me an example of something like this?

There are multiple ways to do it.

It could be as simple as (these would go in your action section of an automation)

data_template:
  message: >
    {{ states.sensor.dark_sky_daily_summary }}

or you could write it out however you want like

data_template:
  message: >
    It is {{states.sensor.dark_sky_temperature.state}} outside, with a high of
    {{states.sensor.dark_sky_daily_high_temperature.state}}, and a
    {{states.sensor.dark_sky_precip_probability.state}} chance of rain.

Or you could throw in some flair and have it recommend coats/hats/umbrella based on various parameters.

(note, I haven’t checked syntax but it should be close)

1 Like

I’ve been doing this automation as a precipitation alert; right now I have it sending to both the GHome and Pushbullet in test mode but I will be adding home/away logic to use one or the other depending on my location. Once I get the rest of my window sensors put in (probably Spring as I’m not worried about it now) I will be adding in a notification if I left any of the windows open.

# Rain Alert

- alias: 'Raining'
  trigger:
    platform: state
    entity_id: sensor.dark_sky_precip_intensity
    from: '0'
  action:
    - service: tts.google_say
      data_template:
        message: 'Excuse me Robert, but is currently {{ states.sensor.dark_sky_precip.state }}ing and it is {{ states.sensor.dark_sky_temperature.state | int }}degrees outside.  Forecast says {{ states.sensor.dark_sky_minutely_summary.state }}.'
        cache: false
    - delay: 00:01:00
    - service: notify.pushbullet
      data_template:
        message: >
          It is currently {{ states.sensor.dark_sky_precip.state }}ing and it is {{ states.sensor.dark_sky_temperature.state | int }}degrees outside.  Forecast says {{ states.sensor.dark_sky_minutely_summary.state }}.
    - service: automation.turn_off
      entity_id: automation.raining
    - delay: 00:30:00
    - service: automation.turn_on
      entity_id: automation.raining

I have the delay there to keep the notifications down to every 30 minutes, though I may take that out after testing. Been having some issues with Dark Sky’s precips as outlined here:

Supposed to rain today so I’ll be able to test!

I have made a custom component that reads up the latest news, weather forecast, num of minutes with training to day, etc
It reads it in Norwegian, but might still be a useful example

1 Like

Cool thanks guys! I have the Home reading out a weather forecast using the Dark Sky data. But…it doesn’t sound very good because when the temperatures have a decimal, Home doesn’t read them properly.

For example, if the input string is “Currently it is 53.9 degrees” Google Home will say:

“Currently it is fifty three” …pause… “Nine degrees”

It’s interpreting that decimal as a period/end of sentence. I looked at the Dark Sky component but I didn’t see a way to specify precision (thinking I could get rid of the decimals).

You can use rounding in your template.

1 Like