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

Add reauth for missing token scope in Husqvarna Automower #117098

Conversation

Thomas55555
Copy link
Contributor

@Thomas55555 Thomas55555 commented May 8, 2024

Breaking change

Proposed change

  • To have full functionality of the integration, users have to connect their account in the developer portal of the manufacturer to the Authentication API and the Automower Connect API. If they only connect to the Authentication API only polling works but the websockets connection can't be established. Maybe it's also related that some users can't send commands to their device.
  • Maybe this PR should be included in the next patch release, as it is kind of a fix.

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Deprecation (breaking change to happen in the future)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • I have followed the perfect PR recommendations
  • The code has been formatted using Ruff (ruff format homeassistant tests)
  • Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • For the updated dependencies - a link to the changelog, or at minimum a diff between library versions is added to the PR description.
  • Untested files have been added to .coveragerc.

To help with the load of incoming pull requests:

@home-assistant home-assistant bot marked this pull request as draft May 8, 2024 22:41
@home-assistant
Copy link

home-assistant bot commented May 8, 2024

Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍

Learn more about our pull request process.

@Thomas55555 Thomas55555 marked this pull request as ready for review May 9, 2024 19:16
@Thomas55555 Thomas55555 changed the title Add repair for wrong token scope in Husqvarna Automower Add reauth for wrong token scope in Husqvarna Automower May 9, 2024
@Thomas55555 Thomas55555 changed the title Add reauth for wrong token scope in Husqvarna Automower Add reauth for missing token scope in Husqvarna Automower May 9, 2024
@Thomas55555 Thomas55555 marked this pull request as draft May 9, 2024 20:06
translation_key="wrong_scope",
data={"entry_id": entry.entry_id},
)
entry.async_start_reauth(hass)
Copy link
Member

Choose a reason for hiding this comment

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

We can raise ConfigEntryAuthFailed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Wouldn't that be to restrictive? Because in this case the integration would fail to setup. But the integration would still work without that token scope, only some functions won't.

Copy link
Member

Choose a reason for hiding this comment

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

Ok. Then please add a code comment here explaining why we don't raise.

Copy link
Member

Choose a reason for hiding this comment

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

I'm reading the linked issue and it seems not having the websocket will create unexpected behavior and problems. Why should we allow to use the integration without the websocket?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought it's better for the user. If the user updates its HA instance, the the integration is more or less broken, until he finds time to reauthenticate. And so he can at least use the integration with polling every 8 minutes. But if you think it's better to raise ConfigEntryAuthFailed we can do so.

Copy link
Member

Choose a reason for hiding this comment

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

I think it's better to have things behave predictably. The docs say you should activate both APIs, so most users will probably have done that already.

@Thomas55555 Thomas55555 marked this pull request as ready for review May 12, 2024 16:03
Copy link
Member

@MartinHjelmare MartinHjelmare left a comment

Choose a reason for hiding this comment

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

Thanks!

Copy link
Member

@MartinHjelmare MartinHjelmare left a comment

Choose a reason for hiding this comment

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

One additional question.

#117098 (comment)

@home-assistant home-assistant bot marked this pull request as draft May 12, 2024 16:12
@Thomas55555 Thomas55555 marked this pull request as ready for review May 12, 2024 20:23
@MartinHjelmare MartinHjelmare marked this pull request as draft May 12, 2024 23:09
@Thomas55555 Thomas55555 marked this pull request as ready for review May 13, 2024 16:28
Copy link
Member

@MartinHjelmare MartinHjelmare left a comment

Choose a reason for hiding this comment

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

Thanks!

@MartinHjelmare MartinHjelmare added this to the 2024.5.4 milestone May 13, 2024
@MartinHjelmare MartinHjelmare merged commit b299684 into home-assistant:dev May 13, 2024
24 checks passed
@Thomas55555 Thomas55555 deleted the Add-repair-for-wrong-token-scope-to-Husqvarna-Automower branch May 13, 2024 21:07
@github-actions github-actions bot locked and limited conversation to collaborators May 14, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants