Skip to content

WIP: Cloud - refresh token as task#20754

Closed
pvizeli wants to merge 2 commits intodevfrom
cloud-token-refresh
Closed

WIP: Cloud - refresh token as task#20754
pvizeli wants to merge 2 commits intodevfrom
cloud-token-refresh

Conversation

@pvizeli
Copy link
Copy Markdown
Member

@pvizeli pvizeli commented Feb 4, 2019

Description:

Refresh access token every hour to make sure that the instance can directly reconnect after a connection is lost.

Checklist:

  • The code change is tested and works locally.
  • Local tests pass with tox. Your PR cannot be merged unless tests pass
  • Write tests


sleep_time = random.randint(3100, 3600)

self.token_task = hass.async_create_task(_handle_token_refresh())
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should do this inside _handle_connection and only once we're connected.


try:
yield from hass.async_add_job(auth_api.check_token, self.cloud)
await hass.async_add_job(auth_api.check_token, self.cloud)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use hass.async_add_executor_job?

@balloob balloob mentioned this pull request Feb 5, 2019
4 tasks
@balloob
Copy link
Copy Markdown
Member

balloob commented Feb 5, 2019

Closing in favor of #20762

Removed the cleanup because it broke the tests. That can be done in a future PR.

@balloob balloob closed this Feb 5, 2019
@ghost ghost removed the in progress label Feb 5, 2019
@fabaff fabaff deleted the cloud-token-refresh branch March 17, 2019 12:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants