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


#1

Ok, I assume this may sound like a newbie question, but please bare with me I’m still a HA beginner :slight_smile:

I have a few of my light bulbs that are without Home Assistant support (or API), but they are working great with my Google Home thanks to skill integration. Now, I would of course like to control these bulbs with my HA floorplan setup, but Im afraid the only way is to use a Google Assistant addon in Home Assistant, and send text commands to my local Google Home Mini’s that will turn on/off the lights.

I would like to be able to do this by clicking on buttons in my HA frontend, just like the other bulbs that have HA-support built in.

In other words, when I click on a button in my HA frontend, it sends a command (to Google Assistant with an addon) “OK Google, turn off the bedroom ceiling lamp” and then Google Home performs the action.

Could someone here guide me what Hass.io addon I should use, and if you have any simple example code on how to make commands?

I have really been googling and searching for days now, also here in this forum, but still havent found much information if this even is possible :frowning:

Im running latest HA on Raspberry Pi 3 B+ with latest Hassio.

Thank you so much!


#2

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/


#3

Which devices?

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


#4

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?


#5

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


#6

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.


#7

Look at the docs on here for IFTTT


#8

looks like there is no IFTTT app for Orbivo…


#9

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!


AWOX SmartLight support, please?
#10

Nice! I will try this. Thanks for sharing.


#11

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


#12

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.


#13

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


#14

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


#15

It worked! Thanks a lot!