leikoilja / ha-google-home

Home Assistant Google Home custom component
MIT License
445 stars 75 forks source link

Google WIFI router causing error - local_auth_token must follow the correct format #348

Closed jazzyisj closed 3 years ago

jazzyisj commented 3 years ago

Describe the bug

Errors when Google WIFI on network. Interesting to note that this Google WIFI router is actual set up on a second home in the Googe Home app. It is not in my primary home. We should be able to limit this integration to a specific home.

Version of the integration

v1.8.1

Logs

2021-09-21 01:34:27 DEBUG (SyncWorker_1) [glocaltokens.client] Looking for 'Google Wifi router' (id=8CCC28E85744C2B7DFE6E90A013B81A7) in local network
2021-09-21 01:34:27 DEBUG (SyncWorker_1) [glocaltokens.client] [Device - Google Wifi router(id=3c5639b1-7041-4fce-ad73-fe0d36da264f)] Initializing new Device instance
2021-09-21 01:34:27 ERROR (SyncWorker_1) [glocaltokens.client] [Device - Google Wifi router(id=3c5639b1-7041-4fce-ad73-fe0d36da264f)] local_auth_token must follow the correct format
2021-09-21 01:34:27 WARNING (SyncWorker_1) [glocaltokens.client] Google Wifi router device initialization failed because of missing local_auth_token, skipping.
2021-09-21 01:34:27 DEBUG (SyncWorker_1) [glocaltokens.client] Looking for 'Google Wifi router' (id=23D62ACE28B68134828189049C8D143D) in local network
2021-09-21 01:34:27 DEBUG (SyncWorker_1) [glocaltokens.client] [Device - Google Wifi router(id=4508cfb0-000d-4f0e-9ba5-9776b98d16f6)] Initializing new Device instance
2021-09-21 01:34:27 ERROR (SyncWorker_1) [glocaltokens.client] [Device - Google Wifi router(id=4508cfb0-000d-4f0e-9ba5-9776b98d16f6)] local_auth_token must follow the correct format
2021-09-21 01:34:27 DEBUG (SyncWorker_1) [glocaltokens.client] Looking for 'Google Wifi router' (id=6E382A9A0EAF47591124C1D261FADF64) in local network
2021-09-21 01:34:27 DEBUG (SyncWorker_1) [glocaltokens.client] [Device - Google Wifi router(id=b3b5870c-f0cb-4165-8c53-7b8926ed2983)] Initializing new Device instance
2021-09-21 01:34:27 ERROR (SyncWorker_1) [glocaltokens.client] [Device - Google Wifi router(id=b3b5870c-f0cb-4165-8c53-7b8926ed2983)] local_auth_token must follow the correct format
ArnyminerZ commented 3 years ago

The device discovery feature is linked to your Google account, so that might be the issue why it adds the device from different homes, however, I find it strange that it's working at all, since all the requests are made locally, so if the Home Assistant installation is on one network, and the device on another, that should not work.

For your question on Google WiFi, that's totally a bug, it shouldn't be recognized as a device.

leikoilja commented 3 years ago

@jazzyisj and @CallumCVM i looked at the code implementation for client in glocaltokens and the logic seems right:

  1. we fetch all devices from google
  2. validate all device tokens for a correct format and if the format is incorrect we log it as error and skip passing that device to the ha-google-home integration. Therefore, the integration should still be working for you and be correctly initialized for all other google home devices you have in your networks except the WiFi routers, those should just be skipped. Is that right or is the entire integration not working for you? p.s. perhaps we should revisit the glocaltokens and not log "invalid token format" for devices like WiFi routers as error, but rather log as debug
jazzyisj commented 3 years ago

The integration is working exactly as expected.

Concern 1 was the error raised by the google wifi. They do not appear to be causing an issue, I believe just reclassifying the log message as debug would probably be adequate.

Concern 2 is fact that the integration is grabbing devices for a google home other than the intended one associated with HA. The underlying issue probably lies on the google end of things. There likely isn't a way to limit which "home" to fetch the devices from when dealing with multiple homes any more than there is a way to prevent HA entities from being added to a second home in the Google Home app. Not a big deal, any unwanted devices can always be disabled within HA.

leikoilja commented 3 years ago

Gotcha, thanks for the info @jazzyisj. The first one is fixed here and will go out with a next release. Can you please create a separate issue for concern 2, so we could separately take a look at google foyer response and see if it's possible to separate devices between homes.

jazzyisj commented 3 years ago

Done. Thanks!

https://github.com/leikoilja/ha-google-home/issues/363