Dynamic google assistant commands

Hi!

I have a question … about google assistant (I use it only from a few google home mini), I would like to know if:

  • when I run a script from google assistant (using routines) I would like to know the room of the google home mini that exec the script, is this possible ?

For example, I have a few routines for some tv channels (OSMC media player), but I would like to exec only on the room and tv that I’m talking with google homes

  • it’s possible to pass some parameter to the routine execution (script) using google assistant for run the script?

For example: ok google, put the channel 2: will run my script custom_channel and how can I receive de parameter ‘2’.

Thanks for your support !! Regards

how are you integrating google home to HA?

If you use IFTTT, unfortunately, the calling device isn’t available in any way. So you can use a call that includes a parameter - see Use variables in Google Assistant input command for Chromecasting via HA

I can’t comment on the “native” integration - https://www.home-assistant.io/components/google_assistant/

When I am in my bedroom and just say turn off the light it will only turn of 5he lights in my bedroom.

I also can say turn of lights in the kitchen.
Maybe script can also be room aware?

I am using the “native” Google assistant stuff without nabucasa.

Google Assistant - Home Assistant states that script is a supported domain, and there is nothing to suggest you can’t tell it a room. Not sure how you set it up though.

( I should probably look into this myself, so i can start exposing temperature sensors and the like - shame the documentation on how to use the integration is lacking…

if script is not room aware, just make a template switch,
so the ON command calls your script
the rest is the same :slight_smile:
thats how i do it, so all my switches are located in the correct room

its because i dont want to have scripts exposed, since you cant actually see them in the home app
i want to ability to also actually use the google home app :slight_smile:

To answer your question:

when I run a script from google assistant (using routines) I would like to know the room of the google home mini that exec the script, is this possible ?

No. While Google, itself, is aware of which room you are in, which is why you can say “Turn off the Lights” and it only does so for the lights in the room you are in, it does not pass this information on to Home Assistant in any useful way.

Thanks @swiftlyfalling, this was the answer that I was looking for.

I’m using a few google homes for tts notifications and for some basic voice commands but it could be more useful if I could know the google home device that exec the script, for send tts response only to this device or for interact with devices in this room from the script.

Thanks for your answers.

I have read before that it seems possible to have multiple Google projects loaded in 1 HA , so you can link multiple test projects…
Maybe it’s an approach to duplicate also your sripts and link the single ones to each Google home, so you know what script fired, that way you also know the source of your Google home device…

Ufff this could be a crazy configuration for update and support when you have more than 5 google home mini and a lot of actions (scripts) to share …

Indeed, but why not exposing your script as a switch, put the switch in the same room, problem solved?

a template script with a template switch for each room? with an automation for each switch ?

no your same script, but create multiple template switches that call the same script
each template switch you put in a room
then yeah, an automation for each switch, depends what you want to do? because with a template switch , you can call different servcies at the same time , fire a script, but also fire a tts command
so you dont need an automation at all

not sure what you want to do ?

Sorry for delay in the answer @pergola.fabio.

I have 2 examples that I have to use with google assistant and google home mini:

  1. For example, say “change to channel 5” for change channel on KODI (PVR). Now I have one script for echar channel (only 2 channel for testing) and it only works with one KODI (I have a few Kodi and a few Google homes mini, so I want to receive the channel number like a parameter in the script from google assistant).

  2. Also I have some commands like … “ok google, check doors and windows” and I have a script that check what windows or doors are open and play (using tts) the open windows on ALL google home and I would like to get the answer only with the google home that I’m talking… so I need the google home name or id that exec the command.

Thanks for your support!

well, parsing variables is not possible i think , i also looked for that feature, if you want parsing variables, you need to use IFTTT, IFTTT works with ingredients, so you could use the number as an ingrediant
if you dont want to use, just make multiple scripts

also for that “check door en windows”, multiply them also, and create a “template switch” for each script… the template switch you can add in the same “room” as your google home mini is

maybe another approach to use dynamic commands, is to expose your kodi as a template mediaplayer/cover/light
so you could use the “volume”/“brightness” commands as channel commands instead , so faking it actually :slight_smile:

so you can say like “set the xxx to 20” , so google thinks you are changing the volume/brighness, but you are actually calling a script that changes your channel…

Thanks for your answer @pergola.fabio.

I don’t want to add another component to the installation (IFTT) and I want avoid to have lots of “fake template switch” for every room/googlehome and script.

I will continue researching, looking for other options, thanks for your support!

yeah, keep me posted, i am also interested in those dynamic commands, i now have also multiple switches for my channels, that actually do the same, just number is diffferent

Hey @pergola.fabio, I’ve multiple Google Assistant Displays and Chromecast enabled screens scattered around my house and I want to expose them as a switch/script to display cameras around the house similar to what you’ve done here: Delay with camera stream I’m not using the “stream” capability also, as that’s really slow!!!

I’d like to issue the command “OK Google, show the camera” and have Google Assistant tell Hassio what device the command originated from so it executes the correct logic to show the camera on the device located in the same room. Do you think that’s possible?

CC: @Zpeed

Yeah, you can solve that with ifttt, then you can send dynamic values… Don’t think you can native with HA alone…

what i am doing is, create a script for every room where you can want to be able to execute the script,
then with nabucasa use the cloud.yaml file to configure the same name for the script and use property “room” to attach the script only for one specific room. (Note: room should be the exact name as it is in google home app)

for example

script.bedroom_discovery_channel:
      name: Discovery Channel
      room: Bedroom
script.living_room_discovery_channel:
      name: Discovery Channel
      room: Living Room 

the room property is used to tell google assistant where the script is. so when you are in bedroom and say “Activate Discovery Channel” it will execute the script bedroom_discovery_channel but if you said the same command (“Activate Discovery Channel”) in the living room google home will call the script living_room_discovery_channel.
The only problem is if you say it in a room without the command it will be executed in all the rooms with the command configured at the same time what shouldn’t be a real because there is no reason the execute in a room without the command.

5 Likes