djtimca / hagooglewifi

Home Assistant integration for Google Wifi systems.
Apache License 2.0
79 stars 26 forks source link

KeyError: 'operation' in start_retrieve_sensitive_info #56

Closed mark007 closed 2 years ago

mark007 commented 2 years ago

Perhaps this is similar to https://github.com/djtimca/hagooglewifi/issues/30 but I thought I should log it anyways. I get two KeyErrors every few days at least. Sometimes more frequently.

One is this one which I couldn't find any existing issue for, hence this one being written. I'm using the latest version of both HA and the googlewifi integration via hacs.


Logger: custom_components.googlewifi
Source: custom_components/googlewifi/__init__.py:171
Integration: Google WiFi (documentation, issues)
First occurred: 20:03:15 (1 occurrences)
Last logged: 20:03:15

Unexpected error fetching GoogleWifi data: 'operation'
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 187, in _async_refresh
    self.data = await self._async_update_data()
  File "/config/custom_components/googlewifi/__init__.py", line 171, in _async_update_data
    system_data = await self.api.get_systems()
  File "/usr/local/lib/python3.9/site-packages/googlewifi/__init__.py", line 191, in get_systems
    return await self.structure_systems(response)
  File "/usr/local/lib/python3.9/site-packages/googlewifi/__init__.py", line 284, in structure_systems
    sensitive_info = await self.get_sensitive_info(system_id=this_system["id"], station_ids=station_ids)
  File "/usr/local/lib/python3.9/site-packages/googlewifi/__init__.py", line 611, in get_sensitive_info
    operation_id = await self.start_retrieve_sensitive_info(
  File "/usr/local/lib/python3.9/site-packages/googlewifi/__init__.py", line 589, in start_retrieve_sensitive_info
    operation_id = response["operation"]["operationId"]
KeyError: 'operation'
djtimca commented 2 years ago

Thanks - this is from the underlying library (https://github.com/djtimca/googlewifi-api). Working on on update there and will include handling for this one there.

mark007 commented 2 years ago

Thank you! I have updated to the latest HA integration this evening. I am seeing some new errors there, do you think I should log them as issues against hagooglewifi or against the googlewifi-api you had mentioned, or perhaps an upcoming googlewifi-api is planning to look to resolve these?

In short summary its throwing errors for me like

  File "/usr/local/lib/python3.9/site-packages/googlewifi/__init__.py", line 289, in structure_systems
    for this_station in system_metrics.get("stationMetrics"):
TypeError: 'NoneType' object is not iterable

and

  File "/usr/local/lib/python3.9/site-packages/googlewifi/__init__.py", line 589, in start_retrieve_sensitive_info
    operation_id = response.get("operation",[]).get("operationId")
AttributeError: 'list' object has no attribute 'get'

Thank you.

djtimca commented 2 years ago

Should be against the API. Thanks

mark007 commented 2 years ago

Great thank you, I have logged those here https://github.com/djtimca/googlewifi-api/issues/5