Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scan failed, scheduling token update #21

Open
nvx opened this issue Feb 15, 2021 · 5 comments
Open

Scan failed, scheduling token update #21

nvx opened this issue Feb 15, 2021 · 5 comments

Comments

@nvx
Copy link

nvx commented Feb 15, 2021

New install, I had to get a master token using the python script and use that due to the issues described in #14

Setup seemed fine, except it can't ever scan. Errors in the log saying "DEBUG (MainThread) [custom_components.googlehome] Scan failed, scheduling token update" pretty constantly.

It seems to successfully be able to update Google Home info for the devices it's detecting however:

2021-02-15 21:59:50 DEBUG (MainThread) [custom_components.googlehome] Updating Google Home info for <ip>
2021-02-15 21:59:50 DEBUG (MainThread) [custom_components.googlehome] {<bulk json about one of my Google Home Minis here>}

Following the instructions at https://rithvikvibhu.github.io/GHLocalApi/#section/Google-Home-Local-API/Authentication I was able to use the access token to successfully get a local token and hit some endpoints on my Google Home Minis, so I'm confident that the master token works since that's how the get_tokens.py script gets the access token that worked. I do note that gpsoauth is a couple of patch versions behind, of which I note simon-weber/gpsoauth@6a52a38 is in 0.4.3 that might be relevant to this issue.

@nvx
Copy link
Author

nvx commented Feb 15, 2021

I updated the gpsoauth dependency to 0.4.3 which resolved the password login issue, but I'm still getting the same the scan failed message continually.

@nvx
Copy link
Author

nvx commented Feb 15, 2021

Looking a bit deeper, it looks like the error handling is a bit wrong. Adding some debug logs around here:

https://github.com/Drakulix/googlehome/blob/master/custom_components/googlehome/__init__.py#L113-L114

It turns out bluetooth_data is []. If I log the IP and token used at that call, I can GET /setup/bluetooth/scan_results on that Google Home Mini with that token and it works (HTTP 200, if I set the cast-local-authorization-token to a dummy value I get a HTTP 401), although the returned json body is []. So looks like the issue isn't "why is the auth not working", but rather "why is the scan results empty".

Is that if statement better off being something like if bluetooth_data is None:?

@Drakulix
Copy link
Owner

Thanks for opening and the debugging so far.

Yes you are right, an empty result is no wrong result, that should print an error message.

However are you expecting an empty result? Or is there still some problem with bluetooth scanning on your home mini?
(Btw while the scan feature appears to be working for me, it is currently not in a very good state, but for entirely different reasons: #12)

@nvx
Copy link
Author

nvx commented Feb 15, 2021

So I thought this scanned for BLE devices, of which I can see a half dozen in range so thought something was definitely broken. To test though I opened Bluetooth pairing on my phone and low and behold it started showing up in the scans (of the nearest few Google Home devices anyway, the ones on the other side of the house can't see it naturally) and of course #12 bit me with the bathroom Google Home writing over the much closer Google Home that is next to me.

This was with that if statement changed to a None check.

Did Google change it from BLE to just regular BT? Or is it only looking for devices in pairing mode so not showing up the devices I see with a BLE scanner app?

@Drakulix
Copy link
Owner

Drakulix commented Feb 15, 2021

Well the feature is used in the google home app to pair a speaker. So although the home mini has BLE functionality, it might not pick up every device or expose all result via the API endpoint. (Those get rendered in the google home app after all.)

However I never had a problem with smartphones showing up (without any pairing). So I am not sure whats going on. Maybe you can poke around in the api yourself? E.g. check your bluetooth status? https://rithvikvibhu.github.io/GHLocalApi/#operation/Status

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants