sebirdman/hass_traeger

Timeout fetching information on restart

Closed this issue · 20 comments

2021-07-19 19:39:23 ERROR (MainThread) [custom_components.traeger] Timeout error fetching information from https://cognito-idp.us-west-2.amazonaws.com/ - 
2021-07-19 19:39:23 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry myuser@gmail.com for traeger
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 293, in async_setup
    result = await component.async_setup_entry(hass, self)  # type: ignore
  File "/config/custom_components/traeger/__init__.py", line 49, in async_setup_entry
    await client.start()
  File "/config/custom_components/traeger/traeger.py", line 224, in start
    await self.update_grills()
  File "/config/custom_components/traeger/traeger.py", line 118, in update_grills
    json = await self.get_user_data()
  File "/config/custom_components/traeger/traeger.py", line 85, in get_user_data
    await self.refresh_token()
  File "/config/custom_components/traeger/traeger.py", line 75, in refresh_token
    self.token_expires = response["AuthenticationResult"]["ExpiresIn"] + request_time
TypeError: 'NoneType' object is not subscriptable

I had the same issue. I was using version 0.2. Upgrading to 0.3 fixed it for me.

Unfortunately the above is with 0.3 for me.

I'm getting the exact same error as @bakerkj and I'm also already on 0.3 as well. Removing and re-adding fixes it short term but it comes up again regularly for me.

I’ve been having devices quit updating recently. They started working again after restarting home assistant

This continues to happen on boot. @sebirdman is there anything other data I could provide to help debug this?
It looks to me like response = await self.do_cognito() is returning None which then causes the subsequent subscript operations to fail to operate on None
self.token_expires = response["AuthenticationResult"]["ExpiresIn"] + request_time self.token = response["AuthenticationResult"]["IdToken"]

Would catching this error similar to the exception that follows:
except KeyError as exception:

Be reasonable?

Continued problems on restart. Works perfectly if I then reinstall the integration.

2021-10-03 18:29:24 ERROR (MainThread) [custom_components.traeger] Timeout error fetching information from https://cognito-idp.us-west-2.amazonaws.com/ - 
2021-10-03 18:29:24 ERROR (MainThread) [custom_components.traeger] Failed to login with None
2021-10-03 18:29:29 ERROR (MainThread) [custom_components.traeger] Error parsing information from https://1ywgyc65d1.execute-api.us-west-2.amazonaws.com/prod/users/self - Cannot serialize non-str key None
2021-10-03 18:29:29 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry bakerkj@umich.edu for traeger
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 304, in async_setup
    result = await component.async_setup_entry(hass, self)  # type: ignore
  File "/config/custom_components/traeger/__init__.py", line 49, in async_setup_entry
    await client.start()
  File "/config/custom_components/traeger/traeger.py", line 229, in start
    await self.update_grills()
  File "/config/custom_components/traeger/traeger.py", line 124, in update_grills
    self.grills = json["things"]
TypeError: 'NoneType' object is not subscriptable

I'd recommend trying the latest integration.

I've seen definite improvements since 0.4 was released. The integration is staying connected for the most part and the additional sensors are great! I did have one timeout last night and a restart didn't fix it, I had to reinstall the integration. However, I just upgraded to 2021.10.4 and after the restart everything has connected without having to reinstall the integration so it's looking better.

@sebirdman running 2021.10.4, with 0.4 addon the same error persists on restart.

Error setting up entry bakerkj@umich.edu for traeger

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 304, in async_setup
    result = await component.async_setup_entry(hass, self)  # type: ignore
  File "/config/custom_components/traeger/__init__.py", line 56, in async_setup_entry
    await client.start()
  File "/config/custom_components/traeger/traeger.py", line 274, in start
    await self.update_grills()
  File "/config/custom_components/traeger/traeger.py", line 131, in update_grills
    json = await self.get_user_data()
  File "/config/custom_components/traeger/traeger.py", line 90, in get_user_data
    await self.refresh_token()
  File "/config/custom_components/traeger/traeger.py", line 80, in refresh_token
    self.token_expires = response["AuthenticationResult"]["ExpiresIn"] + request_time
TypeError: 'NoneType' object is not subscriptable

Yeah after a few restarts I'm still getting that same error message as well.

This seems to be because authentication is failing for some reason. It's unclear why.

Another note, in the past I removed and reinstalled the integration when this happened, that always fixed it. However most recently I tried disabling and then re-enabling the integration. Doing so works like a charm.

@bakerkj @spencer-scott strange question but what general region do you live in? It looks like this error comes from a timeout on cognito, which can be based out of us-east or us-west.

scratch, that, apparently only west works for sign in

i've got an attempted fix coming soon.

@bakerkj @spencer-scott i've updated the component with some changes that should help out here. let me know if this fixes it for you.

@sebirdman I've installed the update and will keep you posted how it goes...

@bakerkj any bad news?

Hey @sebirdman I’ve had installed since you updated last. I started on 2021.10.5 and had zero issues, shortly after I upgraded to 2021.10.6 and it was having a similar timeout issue and I just reverted back to 2021.10.5 and since then have had zero issues thru several restarts. The integration has definitely been staying connected for me. I need to upgrade and test again and then maybe reinstall the integration once upgraded to see if it will hold thru restarts. Thanks again for your updates.

@sebirdman seems solid so far. I've restarted a handful of times and the integration stays up every time.

Thank you!

going to close since it sounds like it's been stable for a bit! feel free to reopen if it continues.