-
-
Notifications
You must be signed in to change notification settings - Fork 69
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
Nest Protect integration for Home Assistant looses authentication after home assistant restarts #341
Comments
I am having an identical issue; HA is running off a dedicated NUC [no docker] |
I'm having the same issue, except tonight no combinations of token / cookie will work |
Same hre: tried several times and the cookies moethod works randomly and whe it works HA looses authentication after a restart. |
@ViPeR5000 , and @iMicknl - any suggestions? |
follow up -- I was able to eventually get this reauthenticated and it's been stable/signed in for 7+days |
using the beta (and master) but after restart I get the LOGGED_OUT issue |
@channafam I don't have any suggestions at the moment. |
This has been happening to me also. I was able to authenticate using the documented procedure, but only once and not since. I keep getting "Unexpected error". Any advice is appreciated. This seems to be the relevant log entry: 2024-09-01 12:34:04.285 ERROR (MainThread) [custom_components.nest_protect] Flow aborted: already_in_progress UPDATE: I was able to authenticate by deleting all the re-authentication prompts. I didn't have to delete the integration itself. I'm guessing that it can't support more than one authentication flow at a time? |
This just happened to me as well (I've restarted HA many times in the last month or so and this is the first time I've lost my Nest authentication; I'm still on HA 2024.5.3, no recent updates there). I wasn't 100% sure what @millerim meant by "deleting all the re-authentication prompts" but when I obtained a new issue token and cookies, I got an error about "invalid flow" when I tried entering them in the authentication popup that showed up when I initially restarted HA. So I closed that popup (which I think is what @millerim was referring to) and I went to settings - integrations - Nest Protect, and selected "Add Entry". Entering my new credentials there worked. |
To clarify: each re-authentication entry in the integration page had a “kebab” menu with the option to delete the integration. I deleted both of them and was able to re-authenticate once they were gone.
… On Sep 2, 2024, at 7:53 PM, Haus ***@***.***> wrote:
This just happened to me as well (I've restarted HA many times in the last month or so and this is the first time I've lost my Nest authentication; I'm still on HA 2024.5.3, no recent updates there).
I wasn't 100% sure what @millerim <https://github.com/millerim> meant by "deleting all the re-authentication prompts" but when I obtained a new issue token and cookies, I got an error about "invalid flow" when I tried entering them in the authentication popup that showed up when I initially restarted HA. So I closed that popup (which I think is what @millerim <https://github.com/millerim> was referring to) and I went to settings - integrations - Nest Protect, and selected "Add Entry". Entering my new credentials there worked.
—
Reply to this email directly, view it on GitHub <#341 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AHGOIXHW5NJL4NW3PLCVDYLZUT253AVCNFSM6AAAAABKKLW2H2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMRVGM4TAOJQGU>.
You are receiving this because you were mentioned.
|
Worked for me as well. TNX for sharing ;-) |
Is it possible to have an integration by using google username, password and OTP secrets? @iMicknl It's really started annoying to re-enter cookies every week. |
Not that I am aware. If someone figures out how to get an access token, I am happy to implement this. The cookie method was a community contribution as well. |
Same issue. I can authenticate successfully every time, but I'm hoping I don't have to go through the cumbersome project after every home assistant restart! |
I've upgraded to the latest release (thank you) but can confirm that I'm still finding the problem of losing authentication at each HA restart. As I seem to get an average of one update each day, the re-authentication is becoming a major chore. What I don't get is what changed about 6 months ago? Before that the cookie method authentication persisted between restarts and life was easy:) I can try and look at logs but which would be the right ones to look at? P.S. I also use Homebridge with the Nest Protect plugin and the cookie method fails on HA re-start as well. So it might be intrinsic to the cookie method... or did something else change. |
Same here, I feel that I should just ignore it but every time I can't seem to resist pasting in the URL & Cookie to fix it! |
I know, I like to tidy things up and, also, it is a safety device so I like to keep them connected. |
In my case, reloading the integration brings it back every time.
|
I just realized it doesn't happen on restarts for me. I just restarted and the integration is working fine. I do get the USER_LOGGED_OUT every day and reloading works. Need to figure out a way to automate the reloads since the entities still show available they just don't update until I reload (and I get the USER_LOGGED_OUT message in the logs). Seems like something is timing out. |
This issue no longer occurs for me. Previously, every restart broke the integration. In the past few weeks it has not recurred despite many restarts. I didn't take any specific action to resolve it, but I have been keeping my homassistant docker image up to date. |
Same for me. It appears to be gone. |
Strange, mine still breaks. Running on the latest HA version 2025.1.4 and version 0.4.0 of the integration... |
Mine also still breaks, running the latest of everything |
I'm not on a beta, on exact same versions you quoted. |
Joyously, my cookie details now seems to persist through restarts - running HA 2025.2.0 and the integration at 0.4.0. Hope it stays like that! |
No joy here ... still breaking with 2025.2.0 after a restart (not an immediate restart, after a while) |
The problem is most likely not linked to the HA code and restart, but to your Nest session. If the cookie is invalidated, you will be prompted to re-login. This cookie method is very far from ideal and I don't have much insights on how/when these cookies are invalidated. |
Understood, but the thing is that I capture the issueToken url & cookie from my PC, don't sign out of the nest session, after a while restart HA and it breaks. If I then go to home.nest.com, my session is still active. |
With debug on I already see this error:
|
Could you try to delete the integration from HA? Not removing the custom component itself, but deleting all the devices, so the integration wouldn't be active, then a HA restart, and try to add the Integration, but this time doing the authentication through an incognito window? My assumption, that the authentication, cookie and token changes, because the logged in session doesn't go "headless" like in incognito mode, when the browser window closed. If you have issues logging into on the Nest page, then you need to activate 3rd party cookies in incognito mode, as I remember. But that should be written in the instructions. |
I will have another look at this. That seems to be odd, why that would be a NoneType object. |
Perhaps it's linked to the reauth. Perhaps when he reauthebticates he creates a new entry? |
So have done it with the incognito window (btw the cookie value is way smaller than without the incognito). Will provide a new update later on today, but crossing fingers |
@GSzabados I confirm that this works. So everyone, you need to get the issuetoken & cookies from an incognito browser session. @iMicknl , perhaps updating the Readme? => Update, it's already in the readme! Perhaps making it stand out? Thx |
This also appears to work for me, I had tried removing the config before, but without doing it in incognito and that didn't help, incognito seems to be the solution Thanks to all involved |
Incognito was the route I took from the beginning. The USER_LOGGED_OUT error is happening every 1-2 hours. I have setup a command line sensor to track the error in the logs (runs every 60 seconds) and use that to reload the integration automatically so I do have a working integration thanks to this automation but still trying to figure out the issue. I'll enable debug to get more details on the error right before this one. I have 3 protect devices |
Could you try my suggestion from a few posts above? But when you finished setting up the integration and got the token and cookie, please close the incognito window, without logging out there, just closing it. I assume you did the incognito window log-in on a PC and not a phone, bit if you did it on a phone, could you try it on a PC? |
Yes that's correct I did it on a PC and closed the incognito window without logging out. Tried that twice. I just updated to Home Assistant 2025.2.3 which seems to have a nest token refresh related fix and wanted to wait a few hours before trying to get a new cookie in case this fixes my issue, but perhaps they are unrelated? To me it seems like the issue is related to the token not being refreshed automatically and the reload is what is triggering the refresh. |
Completely unrelated, that is a completely different API (Google SDM)
By any chance, are you using the token and cookie the same time on multiple HA instances? If you do so, would you mind to generate a separate token and cookie for each HA where you are using this integration? And could you please make sure that you are running the latest version of the integration? |
Thanks @GSzabados. I do have another HA instance but I don't have this integration added to that one.
Monitoring now. If I make it past the 2 hour mark without an error then I should be good. I'll report back. |
No luck. Same behavior. Errored out in 2 hours and reloading the integration fixed it again. Besides the loggedout error I also get this:
My command line sensor is monitoring for both errors to reload the integration since most of the time I get USER_LOGGED_OUT and sometimes I get the NotAuthenticatedException but not as often. I use both as a trigger to reload the integration. |
One additional piece of info in case that is useful, I used to have an original Nest account from before Google bought them and I eventually migrated my account a few years ago to use Google SSO. |
What are you trying to turn off? Where is the service call coming from? And what is the following error after this? I am asking, because after that exception, the integration should have either a 1 minute or 5 minutes pause, and should try to authenticate again. |
Sometimes the integration silently fails without throwing a USER_LOGGED_OUT error. To test if the integration is still up and working I sometimes will just toggle one of the switch entities (from the list of entities, not a manual service call) which throws this NotAuthenticatedException error (any of the switch entities created by the integration) which in turn triggers my automation to reload the integration. There is no other protect error after that one. I have seen the message you are referring to before (the one that indicates the 5 min pause) but for some reason I no longer see it after I added the auto reload automation. I have just enabled debug logging so I'll see if there is anything new that I can share from the logs. I also turned off my automation in case there is more useful info I can get |
Ok, I see. I think there might be a bug with the re-authentication there, and that's why reloading the integration works, because it does the reauthentication correctly. Meanwhile could you try this? change in the client.py the following to 600 at line 278:
Otherwise, do you have any kind of random (dis)connection issues? What kind of internet are you using? Mobile? Starlink? |
Gotcha. Well, strangely my last reload was 4 hours ago after that error I posted and I have not had a timeout since (even after toggling the switch entities randomly). I'll keep monitoring and change the timeout as you suggested if the issue comes back. No other connection/disconnection issues. I'm on a wired (non-fiber) connection and pretty stable. Looking at the logs I see the token is being refreshed hourly now with no issues (so far) 2025-02-15 15:03:48.713 DEBUG (MainThread) [custom_components.nest_protect] Subscriber: retrieving new Google access token |
@51av0sh, do you have any further update? I have looked at both yours and @geertmeersman's logs, all the USER_LOGGED_OUT seems to be due to the cookie is invalidated (due to the user has logged out or was invalidated in the browser). Those should raise an issue in Home Assistant, that you need to re-authentice the integration. I did not look there in details, that it does raise the issue or not, but should. If not, then that is a bug. The odd thing, is that the integration shows that 5 minutes pause error message. That exception should be captured correctly, but your observation was right, it should not try to connect again, as it should raise the issue for re-authentication. |
Hey @GSzabados I'm not getting any more USER_LOGGED_OUT errors since I readded the token on the latest Nest Protect and Home Assistant builds. The only issue I've seen in the past 2 days is the custom_components.nest_protect.pynest.exceptions.NotAuthenticatedException error twice but only after I toggled one of the switch entities just to test that the integration is still working. The last time that happened was 26 hours ago but it has not happened since. |
Seems it just happened again
However I no longer see USER_LOGGED_OUT in my logs at all and only see this error above if I toggle one of the switch entities (lovelace shows "Failed to perform the action switch/turn_off. unknown error" but it's not happening often or consistently like before (I used to get USER_LOGGED_OUT every 1 to 2 hours consistently). |
OK, I am happy to hear that. then it should be solved. For the NotAuthenticated could you try to change the timeout? |
Sure thing. Just lowered it from 3600 * 24 to 600 * 24. I've also re-enabled debug logging. I'll keep you updated. |
Just change it to 600 without the multiplication.
This should be dealt with in the |
Got it. Went back and changed it to 600 flat without * 24 |
This should fix Nest Protect integration for Home Assistant looses authentication after home assistant restarts iMicknl#341, where the integration really has to be-authenticate.
@GSzabados Looks like that solved my problem |
* Re-auth prompt on BadCredentialsException This should fix Nest Protect integration for Home Assistant looses authentication after home assistant restarts #341, where the integration really has to be-authenticate. * Update custom_components/nest_protect/__init__.py * Update custom_components/nest_protect/__init__.py * Update custom_components/nest_protect/__init__.py --------- Co-authored-by: Mick Vleeshouwer <[email protected]>
The problem
Nest Protect integration for Home Assistant looses authentication after every home assistant restart. This issue only started recently.
It’s seems I need to gather issue token and cookies after each restart. Gathering the details now seems to work intermittently. Following the instructions provided https://github.com/iMicknl/ha-nest-protect/tree/beta#retrieving-issue_token-and-cookies, the gathered token and cookie does not always work. Seems I need to follow procedure multiple times before on combination is finally accepted and allows authentication
What version of this integration (ha-nest-protect) has the issue?
0.4.0b5
What version of Home Assistant Core has the issue?
2024.7.0 And previous 2 versions
Device / Model
Nest Protect
Diagnostics information
No response
Home Assistant log
Logs
Additional information
@iMicknl - any thoughts?
No response
The text was updated successfully, but these errors were encountered: