Google Wifi Integration (Custom Component)

I just noticed a new error in logs. I don’t see anything working incorrectly expect that my phone was detected at home all afternoon although I was out.

Error:


Logger: homeassistant
Source: custom_components/googlewifi/device_tracker.py:64 
First occurred: 7 November 2020, 8:53:09 (23020 occurrences) 
Last logged: 19:35:45

Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 119, in _handle_refresh_interval
    await self.async_refresh()
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 193, in async_refresh
    update_callback()
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 223, in _handle_coordinator_update
    self.async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 296, in async_write_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 320, in _async_write_ha_state
    sstate = self.state
  File "/usr/src/homeassistant/homeassistant/components/device_tracker/config_entry.py", line 136, in state
    if self.is_connected:
  File "/config/custom_components/googlewifi/device_tracker.py", line 64, in is_connected
    if self.coordinator.data[self._system_id]["devices"][self._item_id].get("connected"):
KeyError: '1316F8EB82CBD84657BE1D1DAE2BAF591332D4D4B6FA5D4E130C4A7055EB00C3'

Does it persist if you reload the integration or reboot Hass?

I’m one hour into a reboot and haven’t seen the error yet.

Thanks for writing this component. It might just save me from having get rid of my Google Wifi which has good wifi coverage (but a pretty crumby app) and upgrade to Unifi gear! I’m seeing this in my logs. Any ideas?

Logger: homeassistant
Source: custom_components/googlewifi/device_tracker.py:67
First occurred: November 8, 2020, 10:19:01 PM (11002 occurrences)
Last logged: 4:53:09 PM

Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 119, in _handle_refresh_interval
    await self.async_refresh()
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 193, in async_refresh
    update_callback()
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 223, in _handle_coordinator_update
    self.async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 296, in async_write_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 320, in _async_write_ha_state
    sstate = self.state
  File "/usr/src/homeassistant/homeassistant/components/device_tracker/config_entry.py", line 136, in state
    if self.is_connected:
  File "/config/custom_components/googlewifi/device_tracker.py", line 67, in is_connected
    connected_ap = self.coordinator.data[self._system_id]["access_points"][connected_ap]["accessPointSettings"]["accessPointOtherSettings"]["roomData"]["name"]
KeyError: 'name'

That’s an interesting one. I assumed that every Wifi point would have a name or area assigned to it (even the defaults) in the app. I can push an update later this morning that will default a name to the access points if there isn’t one set.

OK I have pushed 0.1.1 which should fix the issue with access point names to handle scenarios where the access point has not been assigned room information in the Google app. @paulau please test and let me know if this is resolved for you now.

@sergio_pt I have also put in an automatic reload of the integration if the Google API drops some of the device tracker keys which I also had happen on my system. I’m not sure if this will correct the problem (very sporadic so hard to reproduce), but let me know if you continue to see this issue (and I will continue to monitor my logs as well).

1 Like

Love the integration, and that i dont need IFTTT for this anymore.

Since all network devices in the wifi setup are imported, it could be smart to import them in HA as disabled devices. This will make the cleaning job easier.

Personaly i got 79 imported, and wanted to use 7 of them…

Thanks Tim. I’ve installed the update but now I can’t get it to load at all. Also note that for one of my access points I’ve assigned “Other” with a custom label via the app -> settings -> network & general -> wifi points -> select the wifi point -> pencil icon (to edit) then room name to “other”.

Logger: homeassistant.config_entries
Source: helpers/entity_component.py:172
First occurred: 9:32:51 AM (4212 occurrences)
Last logged: 9:34:53 AM

Error unloading entry Google Wifi for binary_sensor
Error unloading entry Google Wifi for device_tracker
Error unloading entry Google Wifi for switch
Error unloading entry Google Wifi for light
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 319, in async_unload
    result = await component.async_unload_entry(hass, self)  # type: ignore
  File "/usr/src/homeassistant/homeassistant/components/binary_sensor/__init__.py", line 144, in async_unload_entry
    return await hass.data[DOMAIN].async_unload_entry(entry)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 172, in async_unload_entry
    raise ValueError("Config entry was never loaded!")
ValueError: Config entry was never loaded!
Logger: homeassistant.components.light
Source: custom_components/googlewifi/light.py:35
Integration: Light
First occurred: 9:32:51 AM (21 occurrences)
Last logged: 9:34:52 AM

Error while setting up googlewifi platform for light
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 197, in _async_setup_platform
    await asyncio.shield(task)
  File "/config/custom_components/googlewifi/light.py", line 35, in async_setup_entry
    name=f"{access_point['accessPointSettings']['accessPointOtherSettings']['roomData']['name']} Access Point",
KeyError: 'name'
Logger: homeassistant.components.binary_sensor
Source: custom_components/googlewifi/binary_sensor.py:47
Integration: Binary sensor ([documentation](https://www.home-assistant.io/integrations/binary_sensor), [issues](https://github.com/home-assistant/home-assistant/issues?q=is%3Aissue+is%3Aopen+label%3A%22integration%3A+binary_sensor%22))
First occurred: 9:32:50 AM (21 occurrences)
Last logged: 9:34:52 AM

Error while setting up googlewifi platform for binary_sensor

Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 197, in _async_setup_platform await asyncio.shield(task) File "/config/custom_components/googlewifi/binary_sensor.py", line 47, in async_setup_entry ap_name = f"{access_point['accessPointSettings']['accessPointOtherSettings']['roomData']['name']} Access Point" KeyError: 'name'

Thanks @monsivar. I’ll look at that in a future update. The only thing I’m concerned with is that for beginner users they may have difficulty finding the devices which are added as disabled.

Thanks @paulau I have pushed 0.1.2 which should correct the issue.

I recommend you completely remove the integration first, then reboot and reinstall from scratch. I feel like the first error you are seeing may be caused by the integration being partially set up on your system.

I see your points, but on the other side, I think people installing custom components probably have some understanding of HA and will be able to find them. Many an possibility to choose when connecting and updating?

I have submitted this for inclusion in the default HACS integrations as well and there are a lot of newer users on that base. Have to do some looking on how to do this first, then maybe will add an option during setup of the integration for that so you can choose.

:+1: it’s an great custom component! So keep up the good work :smiley:

OK so I just pushed 0.1.3 which gives you two new features:

  1. @monsivar when you set up the integration from new you will now have an option in the config flow to add the entities as enabled or disabled. If you select disabled they will all be added in disabled state and you can just enable what you want in HA.

  2. I also added an options flow in the Integration configuration which will allow you to specify a custom polling interval for your system if you want something other than the default 5 seconds.

Enjoy (and please report any issues here or in GitHub). Thanks!

1 Like

Thanks Tim. I’ve removed the integration, removed it from HACs, rebooted and added everything again a few times and I get the same behaviour:

2020-11-11 12:45:52 ERROR (MainThread) [homeassistant.config_entries] Error unloading entry Google Wifi for light
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 319, in async_unload
    result = await component.async_unload_entry(hass, self)  # type: ignore
  File "/usr/src/homeassistant/homeassistant/components/light/__init__.py", line 292, in async_unload_entry
    return await hass.data[DOMAIN].async_unload_entry(entry)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 172, in async_unload_entry
    raise ValueError("Config entry was never loaded!")
ValueError: Config entry was never loaded!

It cycles through light, binary_sensor, device_tracker & switch. I’ve then tried it on a separate instance of HA which hasn’t had any custom components installed before and had the same issue, so not sure why this is happening.

Also, something note related but a little confusing, in the add integration screen, it’s now showing as “NOAA Aurora Sensor” due to the translation file.

OK thanks for the heads up! Fixed the naming (working on too many things at once!).

I removed the automatic unload to try to make that other error go away. Please test 0.1.4 to see if that solves it.

Really and I mean Really, appreciate this Custom Component. We have shotty internet in outback Australia, and I was having to reset my Google Wifi every morning due to drop outs… this component will allow me to automate the reset… love your work!!

1 Like

Beautiful! Thank you so much. That works a treat and the only ones who won’t be thanking you will be my kids, after I magically disable their internet access :wink:

There appears one issue in the logs with the translations which shows when you are prompted to assign rooms to devices

json.decoder.JSONDecodeError: Expecting property name enclosed in double quotes: line 28 column 1 (char 875)

The “other” named access point shows too. It took me a while to find my access point “Study” (which shows in the app as one of the standard rooms) - it’s named “Den”.

Great work! Thank you so much for your help and creating the component!

That’s an odd one! Is that all that’s provided in the traceback? I haven’t seen that error and it is likely related to the same room naming issue that I can’t replicate in my environment. If there is more let me know (otherwise if it doesn’t affect it working I’m not going to worry about it for now).

My kids love it too… my Internet scheduling has been much more reliable since I put this in place. :slight_smile:

Hi Tim!

I got a new error error after latest update:

Logger: homeassistant.util.json
Source: util/json.py:32
First occurred: 14:56:00 (8 occurrences)
Last logged: 14:57:22

Could not parse JSON content: /config/custom_components/googlewifi/translations/en.json
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/util/json.py", line 32, in load_json
    return json.loads(fdesc.read())  # type: ignore
  File "/usr/local/lib/python3.8/json/__init__.py", line 357, in loads
    return _default_decoder.decode(s)
  File "/usr/local/lib/python3.8/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/local/lib/python3.8/json/decoder.py", line 353, in raw_decode
    obj, end = self.scan_once(s, idx)
json.decoder.JSONDecodeError: Expecting property name enclosed in double quotes: line 28 column 1 (char 875)

These errors occur everytime I try to open the “options” in integrations screen.