Google Home execute command when I say "ok google"

Hello guys!
I’m try to find a way to run a command over HA/HTTP/IFTTT when i say “OK GOOGLE” and my google home start to listening me.
There is a way for this?! In particular i want to mute my TV immediately after i say the magic words to google home, through a nodemcu with an IR LED pointed to my TV.

It’s possible?

Thanks,
Simone

Yes. You first need to connect to Google assistant either via cloud or the component

Then you can create automations. I’ve created a few binary sensors for that need. Have a look at my config if it helps

Hi lolouk! Thanks for your reply!
I’ve already configured google assistant component on my configuration file on home assistant.
But how i can run a command when i trigger google home for my problem?
I can turn on and off lights and climate but how i can mute my TV (without chromecast) immediately after i call google home??

so I take it you have a command/service in HA that allows you to mute the tv? If so create an input_boolean that you expose to GA, then when that input_boolean is turned on/off you mute your tv accordingly.

To recap, I have a device (nodemcu with esp8266) that communicates in MQTT and that commands TV through some topic with an IR LED. If i create an input_boolean how do I activate it when I start talking to google home?

The problem is activate input_boolean and getting the command from google home when he turns on and is listening to me before i put the question or the command to it.
(eg. i want a command from google home when it lights up, in the same time, unconditionally of my vocal command)

I hope I have made it clear

look at my Google_Assistant.yaml file, it will show you how to expose the input_booleans to GA.
Once expose, you can tell GA to turn on/off your input_boolean.
You can then add a custom routine so that when you say mute the tv it turns on the input_boolean and when you say un mute the tv it turns off the input_boolean (or the other round, as you prefer)
You then create automations in HA so that when the input_boolean state is changed, you mute / unmute the TV
Alternatively you could use a template_switch if you’re able to retrieve the mute status from your TV.

Sorry but I think we have not fully understood yet…

So have you already configured GA (Google Assistant) on your HA right?
What have you exposed to GA?
Whatever is exposed should show on the GA app on your phone. have you managed to go this far?

Couldnt you set up an automation to trigger when your home goes from off to awake?

I have tried triggering my google home but his state (on the service page of HA) didn’t change at all.

do can you see in the GA app on your phone entities/devices from HA?
IF not you’ve not exposed anything or you haven’t set the GA component correctly.
If it’s setup correctly and you see the devices in GA, they should sync with HA.
How have you added GA? Is it via HA cloud or is it as a manual setup?

lolouk, yes i can see my ha devices in google home app on my iPhone. I’ve created a test app on google console sdk that point to my home assistant (https://www.home-assistant.io/components/google_assistant/ - FIRST TIME SETUP anchor) and it works like a charm.
My problem is further than this. I’m finding a way to manage a change state on my google home from off/idle to awake/listening my voice.

Imagine having the TV turned on with a high enough volume. When I say “ok google”, he automatically sends the command to home assistant (and therefore to my device) which makes the volume turn down to be able to better understand my voice commands (because my google home is very close to the tv).
I do not have to say “ok google lowers the tv” and then my command.

ah ok, then I don’t think it’s possible, “ok google” is a trigger, it needs an action after that. if there’s nothing else said, there’s no action to run…

Nothing, i have tried different things but without success…
But there must be a way because Chromecast device automatically turn down volume on TV (SmartTV or CEC protocol) when a device like google home is activated and listening voice…

I know this post is over a year old, but I just wanted to help anyone that finds this like I did.

First I don’t know how to make a trigger occur when you say “Ok Google”, this might not even be a state they expose. But a better way to trigger an event than exposing an input_boolean is using the event platform and look for the google_assistant_command event type.

platform: event
event_type: google_assistant_command

I found using an input_boolean prevents you changing the brightness and colour of lights if that’s all your exposing to google. Sorry again for the necro.

5 Likes