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

Remove auth token from device when removing HomeWizard entry #138596

Draft
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

DCSBL
Copy link
Contributor

@DCSBL DCSBL commented Feb 15, 2025

Proposed change

When the user removes a HomeWizard entry, try to clean up the authentication token on the device.

This is just a good practise and does not handle any error, like a device not available or a an invalid token.

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

  • This PR fixes or closes issue: fixes #
  • This PR is related to issue:
  • Link to documentation pull request:
  • Link to developer documentation pull request:
  • Link to frontend pull request:

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.

To help with the load of incoming pull requests:

)

# Ignore any error, because device may be unreachable
with suppress(Exception):
Copy link
Member

Choose a reason for hiding this comment

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

does it make sense here to treat all exceptions the same (if the answer is "yes" also fine). I was just thinking, if the device is reachable but we still cannot remove it if we should take action

Copy link
Member

Choose a reason for hiding this comment

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

Isn't this described in the PR description?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, but I wasn’t sure if we shouldn’t consider some/retry if makes sense

Copy link
Contributor Author

Choose a reason for hiding this comment

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

IMO this is just some cleanup which is not really required. It is fine if it fails, because the user can factory reset the device to clear all tokens if they get into issues.

I think this is just a bit better than doing nothing, any other solution with error handling will just cause issues and confusion.

Copy link
Member

Choose a reason for hiding this comment

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

fine by me, but I'd prefer catching and logging a warning then, to give the user a chance to notice something went wrong and is left over in the device (together with "you can factory reset to get rid of it")

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That would be nice indeed 👍

@frenck frenck marked this pull request as draft February 15, 2025 20:55
@DCSBL DCSBL marked this pull request as ready for review February 17, 2025 08:54
@DCSBL DCSBL marked this pull request as draft February 17, 2025 09: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.

3 participants