Google Wifi Integration (Custom Component)

I have the Google WiFi mesh network and was disappointed in the level of integration available through the discovered integration. I was really hoping for device trackers and more control over the system itself.

So I am building it.

The first release is very simple - just includes binary sensors for each of your access points and the overall system which will report their status (on - online, off - offline) and provide you a custom service to reset either a single access point or the whole system (googlewifi.reset).

I expect next week to roll out device trackers for each Wifi device that is in your devices list, switches for each device to allow you to pause and unpause individual devices, a custom service to allow you to prioritize one of the devices (switches), and just for fun a light entity which will control the light rings on the Google Wifi pucks. Feedback will be appreciated as I roll out each platform.

You can find the integration at https://github.com/djtimca/hagooglewifi

It can be installed either as a custom repository in HACS or manually by copying to custom_components.

Please use this thread to report any issues you might have. I unfortunately can’t support the link to get your refresh token (which is required), but I highly recommend using the Google Chrome Plugin they offer - much easier.

12 Likes

This is great!
Thank you for your contribution. I already have it installed and working.

Looking forward for the features you have in roadmap :slight_smile:

Just released version 0.0.2 which now adds the device_tracker platform. Switches etc. coming soon, but at least now you can test and validate that the device tracker works (I expect better than other methods of wifi connection tracking on Google Wifi).

Is it me, or each device is duplicated by the amount of access points you have?
I have a large number of devices connected, so its hard to distinguish them, some examples below:

and

I thought this might be duplicating according to the access point it was connected to, but it doesn’t seam that.
Connected to hall point:

I tried forcing it to connect to other access point, but I got the same result.
Connected to Bedroom point:

Can you maybe change the “source_type” to help us debug what this might mean?

I had some duplication as well but didn’t have time to dig into it today. One other possibility is that the API is returning all previous devices that have been connected and I have noticed some duplication even in the app with old versions. I will do more digging tomorrow. I wish the API would return the MAC address rather than the Google Unique ID and IP - would be easier to filter out.

Hi again :slight_smile:

After having the integration running for some time, it ultimately fails and all entities go into unavailable. Restarting home assistant fixed it, but some time after it failed again.

The error is as follows:


Logger: custom_components.googlewifi
Source: custom_components/googlewifi/__init__.py:121 
Integration: Google WiFi (documentation) 
First occurred: 2 November 2020, 23:28:09 (5537 occurrences) 
Last logged: 8:01:57

Unexpected error fetching GoogleWifi data:
Traceback (most recent call last):
  File "/config/custom_components/googlewifi/__init__.py", line 118, in _async_update_data
    system_data = await self.api.get_systems()
  File "/usr/local/lib/python3.8/site-packages/googlewifi/__init__.py", line 143, in get_systems
    raise ConnectionError("Failed to retreive Google Wifi Data.")
ConnectionError: Failed to retreive Google Wifi Data.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 144, in async_refresh
    self.data = await self._async_update_data()
  File "/config/custom_components/googlewifi/__init__.py", line 121, in _async_update_data
    raise PlatformNotReady from error
homeassistant.exceptions.PlatformNotReady

Thanks for reporting - looks like I have the same issue as well - I’m guessing there is some sort of rate limit. Going to do some testing and see if I can’t get that figured out this morning. Thanks for testing!

1 Like

Yes have the same issue too

I went through the raw data returned from my system and the duplicates are definitely originating from previous devices which were connected. Google retains the ID but none of the details in the returned data. In my case I was able to trace a couple of the duplicates back to friends/family devices which had previously been connected. That doesn’t mean that it is necessarily a separate device, it could be one of your devices which changed something significant enough that it was issued a new token/key from Google Wifi at some point. Unfortunately not much we can do from the data to filter these out. You would need to just disable them in your Home Assistant UI.

Its possible. I wished it was duplicate per access point, because this way I could trace the location of the device to a specific point :stuck_out_tongue:

Actually @sergio_pt I might be able to add an attribute for which AP it is connected to… will look today. Still trying to figure out the issue of things going offline.

2 Likes

OK I’ve pushed version 0.0.3 which I’m hoping will fix the devices going offline (although not 100% positive yet). I also added a new attribute to the device tracker entities which will show what access point that device is connected to.

Updated :slight_smile:
I’ll provide feedback :slight_smile: and thank you again for your contribution!

Do you think it would be beneficial to change the attribute “source_type” to something different like “Google Mesh”? This might be nice do distinguish from other integrations that track routers, but I’m not sure if there would by any downside to ti… :thinking:

Got a new one :slight_smile:

Logger: custom_components.googlewifi
Source: custom_components/googlewifi/__init__.py:133
Integration: Google WiFi (documentation)
First occurred: 16:18:47 (1 occurrences)
Last logged: 16:18:47

Unexpected error fetching GoogleWifi data: local variable 'system_data' referenced before assignment
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 144, in async_refresh
    self.data = await self._async_update_data()
  File "/config/custom_components/googlewifi/__init__.py", line 133, in _async_update_data
    return system_data
UnboundLocalError: local variable 'system_data' referenced before assignment

It seems to be happening on a regular basis, seems every minute (but now it recovers automatically):
image

EDIT:
Seems to have stabilised for now. I will try to get a time pattern from this:
image

Found it - will be updated in the next release (later today).

1 Like

Pushed latest (0.0.4) which corrects the issue with system_data as noted. Based on how it has been working it appears that the fix earlier to solve for devices going unavailable by triggering a new session looks like it is working.

This release also includes switches and lights:

Switch
All connected devices are able to have their internet connection paused or unpaused through Home Assistant.

Light
All Google Wifi pucks can now have their lights turned on/off and brightness set through Home Assistant.

I still have as an outstanding feature to add a custom service to allow you to prioritize a specific device on the network. Probably that will come tomorrow.

Please keep me posted on any additional testing issues.

Thanks!

1 Like

Switches working great! This will allow some nice automations!
Do you think you can algo get devices and overall usage? :stuck_out_tongue:

Unfortunately the usage information isn’t in the API documentation that I’ve been able to surface at this point. It really only provides us potential for on/off, prioritization, and device tracking fundamentally. Not perfect, but a heck of a lot better than the base OnHub integration!

Definitely! This is really good! I’ll try to see how devices change access points during the day :slight_smile: