Send commands/actions to Google Home with buttons on HA Frontend

Hey,
I am actually researching this. I found the following but haven’t implement as yet. I have tested up to command line switch because I do not have access to my pi. Everything works so far. I can send a message to my phone via url and tasker opens up google assistant and issue the command.

  1. Send a Command to Google Assistant from Tasker | AutoApps Forums
    https://forum.joaoapps.com/index.php?resources/send-a-command-to-google-assistant-from-tasker.297/

2.Activating Tasker tasks from Home Assistant using command line switches - Home Assistant
https://www.home-assistant.io/blog/2015/12/10/activating-tasker-tasks-from-home-assistant-using-command-line-switches/

Which devices?

I would use IFTTT to talk to Google and home assistant…

1 Like

I can use IFTTT to do that? I currently have an orvibo allone RF hub which controls my blinds that is integrated with GH. How can I use IFTTT to integrate with HA?

create a webhook as the if and the google action as the that… Then from HA, send the webhook command. It’s reasonable straightforward

I am new to this stuff. So I do not understand. To be clear you are saying that I can use a button in HA as the webhook to say if I press this button then google will carryout an action? I have done research and I only see that you can trigger google actions only with voice or text. Please explain in more details.

Look at the docs on here for IFTTT

looks like there is no IFTTT app for Orbivo…

Thanks guys.

I solved this by using the Google Assistant Webserver addon in Hassio, which you can send HTTP requests to being translated to Google Home commands. Im sending the http requests by creating command line switches:

switch:

platform: command_line
switches:

  taklampa_vardagsrummet_google_home:
    command_on: "/usr/bin/curl -X GET http://192.168.0.6:15555/command?message=turn%20on%20big%20ceiling%20lamp"
    command_off: "/usr/bin/curl -X GET http://192.168.0.6:15555/command?message=turn%20off%20big%20ceiling%20lamp"
    friendly_name: Taklampan i Vardagsrummet (Ceiling lamp living room)
  taklampa_hallen_dorrlampan_google_home:
    command_on: "/usr/bin/curl -X GET http://192.168.0.6:15555/command?message=turn%20on%20door%20light"
    command_off: "/usr/bin/curl -X GET http://192.168.0.6:15555/command?message=turn%20off%20door%20light"
    friendly_name: Dörrlampan i Hallen (Door lamp in the hallway)

Then I created an input_boolean for each lamp:

input_boolean:

emu_taklampa_kontoret:
name: Taklampan på Kontoret
initial: off
emu_taklampa_vardagsrummet:
name: Taklampa i Vardagsrummet
initial: off
emu_taklampa_dorren:
name: Dörrlampan i Hallen
initial: off

And then put (for each lamp) the input_boolean together with the switch for each google home call into a group, which I can then add to various Lovelace cards for example.

group:

taklampa_vardagsrum_emulerad:
name: “Taklampa Vardagsrum”
entities:
- input_boolean.emu_taklampa_vardagsrummet #Emulerad lampa
- switch.taklampa_vardagsrummet_google_home #Emulerad Switch med Google Home assistans
taklampa_dorrlampan_emulerad:
name: “Dörrlampan”
entities:
- input_boolean.emu_taklampa_dorren #Emulerad lampa
- switch.taklampa_hallen_dorrlampan_google_home #Emulerad Switch med Google Home assistans

Now, to add this to a picture entity card in ui-lovelace.yaml, I have these lines (for each lamp) to switch on and off the lamps, and the input_boolean keeps remembering which states the lamps has (on or off). By clicking the picture entity, Im doing a trigger action. I also added a turn-off action when I press on the image for a second, using the hold_action. Here is an example:

ui-lovelace.yaml

  • entity: input_boolean.emu_taklampa_vardagsrummet
        image: /local/click_hover.png
        style:
          left: 49%
          top: 41%
          width: 12%
        tap_action: 
          action: call-service
          service: homeassistant.toggle
          title: Taklampan i Vardagsrummet
          service_data:
            entity_id: 
            - input_boolean.emu_taklampa_vardagsrummet
            - switch.taklampa_vardagsrummet_google_home
            
        hold_action:
          action: call-service
          service: homeassistant.turn_off
          title: Taklampan i Vardagsrummet
          service_data:
            entity_id: 
            - input_boolean.emu_taklampa_vardagsrummet
            - switch.taklampa_vardagsrummet_google_home
        type: image
        title: Taklampan i Vardagsrummet 

Its all quite easy to make working, but it took me a few days to understand the whole process, as Im quite new to HA in general.

I will add my full code maybe later this week.
Thanks again!

8 Likes

Nice! I will try this. Thanks for sharing.

1 Like

Can you share how you get the Google Assistant Webserver addon working please?

1 Like

I simply followed the instructions and installed the add-on in Hassio and used custom ports as in the screenshot (because default portd didnt work for me). The instructions for creating the Google API file are also straight forward and all included in the add-on page. Just add the repository URL “https://github.com/AndBobsYourUncle/hassio-addons” in Hassio Addons and the plugin will be available. All info is there:
https://github.com/AndBobsYourUncle/hassio-addons

Btw…
I remember the last Google API AUTH process (within HA) gave me a strange error first time, but commands still worked right away and have been working for weeks now.

Let me know if you have any problems getting it to work.

I created an API to synch Google Home with HA. Can I use this existing API?

Hmm Im not sure. Its safest to just create a second one, I guess.

It worked! Thanks a lot!

1 Like

So I ran through all of the steps to set this up.
When I get my token back from Google I paste it into the WebUI and I get things similar to this:
image
Chrome reacted similarly.
Restarting the container doesn’t seem to fix the issue, it needs to be uninstalled and re-installed to get back to a state where there’s even any WebUI.

These are the latest logs:

[27/Aug/2019:10:57:24] ENGINE Started monitor thread 'Autoreloader'.
[27/Aug/2019:10:57:24] ENGINE Serving on http://0.0.0.0:9324
[27/Aug/2019:10:57:24] ENGINE Bus STARTED
192.168.1.171 - - [27/Aug/2019:11:01:04] "GET / HTTP/1.1" 200 713 "" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.1.2 Safari/605.1.15"
192.168.1.171 - - [27/Aug/2019:11:01:04] "GET /favicon.ico HTTP/1.1" 200 1406 "http://192.168.1.216:9324/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.1.2 Safari/605.1.15"
[27/Aug/2019:11:02:09] ENGINE SystemExit raised: shutting down HTTP server
[27/Aug/2019:11:02:09] ENGINE Bus STOPPING
[27/Aug/2019:11:02:09] ENGINE HTTP Server cherrypy._cpwsgi_server.CPWSGIServer(('0.0.0.0', 9324)) shut down
[27/Aug/2019:11:02:09] ENGINE Stopped thread 'Autoreloader'.
[27/Aug/2019:11:02:09] ENGINE Bus STOPPED
[27/Aug/2019:11:02:09] ENGINE Bus EXITING
[27/Aug/2019:11:02:09] ENGINE Bus EXITED
[27/Aug/2019:11:02:09] ENGINE Waiting for child threads to terminate...
 * Serving Flask app "hassio_gassistant" (lazy loading)
 * Environment: production
   WARNING: Do not use the development server in a production environment.
   Use a production WSGI server instead.
 * Debug mode: off
INFO:werkzeug: * Running on http://0.0.0.0:5000/ (Press CTRL+C to quit)

Is there an easier way to do this with the cloud integration?
I’m thinking of buying a Fan with Grid Connect which can be controlled by google, but has no ifttt integration unfortunately. So I was thinking this maybe a solution, but was also thinking there might be an easier way of doing this given I subscribe to the cloud service.

Hi!
I actually started a thread about the same stuff yeasterday:

And i found a solution that is also working quite similier:
it is called: Assistant-Relay-for-Hassio
It was quite easy to setup - and then you can use rest calls from inside HA

:slight_smile:

1 Like

This is broken for me at the moment with the maintainer not updating anymore, sadly enough.

1 Like

Assistant-Relay-for-Hassio is still working fine for me.
I got an email from google saying Oauth is changing on Oct 3, so everything might be broken after Oct 3, 2022.

If anyone knows a way to send commands to google assistant from Home Assistant I would like to know :slight_smile: I use it with NodeRed, when there is motion outside on one of my cameras, I send a REST command with Assistant-Relay-for-Hassio to my google nest screen to show me a camera feed of the area.

1 Like

You should check out Google Assistant SDK - Home Assistant (home-assistant.io) if you are still looking for the answer to this.

I setup some buttons for a Tuya Fan that I can control from Google Assistant on my phone but with the new Tuya integration I cannot get to work without paying their subscription.

once you have followed the few simple steps. you can use NodeRed or even just create a template switch like this:

  - platform: template
    switches:
      dining_room_fan:
        friendly_name: "Dining Room Fan"
        icon_template:
            mdi:ceiling-fan
        turn_on:
            service: google_assistant_sdk.send_text_command
            data:
                command: turn on Dining Room fan
        turn_off:
            service: google_assistant_sdk.send_text_command
            data:
                command: turn off Dining Room fan
1 Like