Unofficial Google Home Local API

Hello!
I’ve discovered that there’s an API of Google Home that you can utilize locally.
GitHub user rithvikvibhu has documented it and stored here:
https://rithvikvibhu.github.io/GHLocalApi/
And here’s the repo: https://github.com/rithvikvibhu/GHLocalApi

I’ve placed this thread in the “Bindings” category for obvious reasons :wink:
This API gives us an opportunity to (e.g.):

  • get alarms and timers
  • get/set Assistant notifications
  • set night mode
  • get device settings
  • set bluetooth discoverable
  • etc.

The API is not officially published. It’s a result of manual network scanning. Shout out to the authors! :slight_smile:

I’ll play around with the API in my local openHAB and see what we can do with it! :wink:
In the meantime we can think of a binding for that! I think googlehome or googlehomecontrol would be a proper name
for that. Is there anyone who would like to code one? I’m setting up a branch with binding skeleton :wink:

EDIT: The port is 8008, so you need to send a POST or GET request (e.g. with Postman) to the following endpoint:

Example request Description
GET http://192.168.0.XXX:8008/setup/assistant/alarms gives you a list of alarms and timers
GET http://192.168.0.XXX:8008/setup/eureka_info All kinds of device info, including noise level, WiFi ssid, uptime and more

etc.

Cheers,
Kuba

8 Likes

Little things like this want to make me sell all my alexa devices and switch to google home instead. Even if its a small API, the fact that this is useable locally, makes it really attractive.
Thanks for the post!

The more I look at it, the more promising this looks!
Imagine trigger channels that would execute when an alarm or timer goes off :slight_smile:

See my findings here regarding alerts and timers.

The PR with barebones binding skeleton is here: https://github.com/openhab/openhab2-addons/pull/3128

Anyone can join me in the efforts. Branch is here.

@kubawolanin I’m glad to see this being worked on :slight_smile: . Thanks! Let me know if you have any problems with the API.

1 Like

Just 3h between forum topic and first pull-request. We speedrun Openhab now.

Sounds really great.
But I think we need another name.

“Google Home binding” can easily be confused with the Google Home Action binding.

It won’t be a openHAB Action - @MARZIMA’s work is a Google Assistant Action.

If I can make the Google Home speaker talk and say notifications like “The garage is still open” then I’ll happily get rid of Alexa!

1 Like

with a little help of node-red you can do it now: http://www.notenoughtech.com/home-automation/google-home-notifications-tutorial/

You actually can already :wink: Google Home has a Chromecast inside, so you can use Chromecast binding and treat GHome as an Audio Sink.
From there you can simply add a rule:

rule "The garage is still open"
when
    Something happened
then
    say("The garage is still open")
end

Note that you’ll need to set up a TTS service in openHAB (like VoiceRSS, PollyTTS etc).

3 Likes

Hi,
I was wondering if there are any news on this project. I just tried to to install the binding from github by creating a jar file and placing that in the addons folder. However, I guess, that is not the correct way, as I cannot find the binding in the paper UI.
This binding’s functionality would be quite different from the Google Assistant Action.
Best wishes,
Johannes

1 Like

May I bring this topic up again? Does this API still work for you?
I recently tried to use it however I got stuck at getting the required authentication tokens. Before I invest more time into this I’d like to know if it’s worth it or if the API is not available anymore.

Edit: I got the API working and can communicate with my Nest Hub successfully. If anyone comes across this in the future an has questions hit me up :relaxed:

1 Like

hi @Felix_Schneider, I would love to hear, what you did to get it working. At some point I stopped trying :unamused:

Understandable! I failed to get this API to work three times. Only after many many google searches and trial and error I got it working.
I am writing this now since tomorrow I will switch back to Alexa for my smart speakers.


If you have any questions let me know. Also I want to add that the developer/the guy who found the API is alive and reachable via email. I found it on his github. I once wrote him and he answered to me in about half a day.


I created a github repository to include all needed files and my experience. You can find it here.

1 Like

Hi @Felix_Schneider, thank you for your detailed git repo! I just discovered this unofficial API whichs offers great possibilities if successfully implemented. I finished reading through yours and author’s documentation, and an a-to-z openhab binding seems delicate due to new authentification methods. By the way, I’m still googling / trying to use your first script, get_master_and_access_tokens.py, which returns the error “Provide an android_id”. Do you know if it is related to the " Local Authorization Token" as documented by the author or have you encountered a similar issue ?
Thank you for your time.

I didn’t encounter this issue. However looking at the code this issue has to be before the lokal auth token is used.
I printed my android id out for testing. Maybe you can test using this one instead of calling _get_android_id()

┌─[17:59:23]-[:)]-[openhabian@openhab]-[/tmp/GoogleHomeApi/ (main)]
└──> python get_master_and_access_tokens.py
android id: DCA6321BE59D

Do you get any import errors? In line 13 getmac is imported (from uuid import getnode as getmac)and used later to get the id. If the import doesn’t work the script can’t get the id.

Thank you fr your help! I did notice the import line 13, I tried to “pip install uuid” without success (it installed the module but did not solve the issue). I should have included the full output, I’m sorry. No import errors, here it is :

~/Git/GoogleHomeApi$ python3 get_master_and_access_tokens.py 
Traceback (most recent call last):
  File "get_master_and_access_tokens.py", line 78, in <module>
    device_id = _get_android_id()
  File "get_master_and_access_tokens.py", line 58, in _get_android_id
    raise OSError("a valid MAC could not be determined."
OSError: a valid MAC could not be determined. Provide an android_id (and be sure to provide the same one on future runs).

Do you know how this Id is obtained ? My IoT devices, including the two google home, are on a separate subnet.

I used your Android Id (Device Id) and I’m actually getting master and access tokens. I have to test if I can get a local auth token for my device with them (maybe device id validation is only happening when requesting the first tokens…). I have to recompile grpcurl first!

No, sadly not. However you may google what the imported function from uuid import getnode does.


You’ll have to see if this works for you. However I am pretty optimistic it does. The script only communicates with googles servers and if you are able to communicate with your Google homes you should be golden.


When you do get these tokens you should get the lokal tokens and be able to communiate with your devices.


Why?

Hi Felix,
thanks for your support - last year :see_no_evil: … I finally came around to give this another try and now it works for me :+1: Basically, my intention is the same as yours, get the alarms and timers. Ideally, I want to capture the alarm set as part of the “good night” routine, and in the morning slowly increase the brightness of the lights in the bedroom, before the alarm sounds. Let’s see, if I can get this to work.
Best wishes

In regards to @Potjoe : I had the same issue and just put in the mac address of a google home mini … I don’t think that’s the proper solution, but it worked for me.

1 Like