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

Allow entries with same user_key for Pushover #77904

Merged
merged 3 commits into from Sep 29, 2022

Conversation

engrbm87
Copy link
Contributor

@engrbm87 engrbm87 commented Sep 6, 2022

Breaking change

Proposed change

Pushover allows configuring mutiple applications with different api key. These applications will use the same user key.
This PR removes the unique_id so multiple applications (notify services) can be configured.

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
  • The code has been formatted using Black (black --fast 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.

The integration reached or maintains the following Integration Quality Scale:

  • No score or internal
  • 🥈 Silver
  • 🥇 Gold
  • 🏆 Platinum

To help with the load of incoming pull requests:

@mdehaas

This comment was marked as off-topic.

@frenck
Copy link
Member

frenck commented Sep 8, 2022

@mdehaas Please... please... don't ping or ask for reviews. This is kinda demanding (even if you didn't mean it like that). Please have patience. Thanks 👍

Comment on lines -90 to -91
await self.async_set_unique_id(user_input[CONF_USER_KEY])
self._abort_if_unique_id_configured()
Copy link
Member

Choose a reason for hiding this comment

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

So the combination of user key and API key is unique right?

Shouldn't that be used as the unique identifier instead?

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 first thought of that. But if the api key is removed the user can reauthenticate with a new api key. So that makes the api key not unique.
Can we update the unique_id when reauthenticating?

Copy link

Choose a reason for hiding this comment

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

As I read the documentation of the Pushover API the API token is unique. Wouldn't that solve the problem? If a user registers this in HA it would be a new instance. Just make the API not changeable for an existing configuration but document the procedure to change the API key is create a new configuration?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

An API key can be regenerated which means for the same application an old api token can be revoked and new one used instead.
image
This means we should still provide a re-authentication flow to enter new api_key.

Copy link

Choose a reason for hiding this comment

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

@engrbm87 Can I help you in any way? If a re-authentication flow is problematic I think a valid scenario for now would be to consider the API Token as unique and document the need to remove and recreate the configuration through the interface.

Copy link

Choose a reason for hiding this comment

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

Or just create a GUID and use that as the unique_id. It is not connected to any combination of User Key and App Key and therefore you can reconfigure both without adjusting the unique_id. I feel this is not the right choice because there would be nothing stopping you from creating multiple services with the same User/App key pair. On the other hand, this does not break anything, just the behavior on the phone-app might not be wat the user expects.

Copy link

Choose a reason for hiding this comment

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

Or just create a GUID and use that as the unique_id. It is not connected to any combination of User Key and App Key and therefore you can reconfigure both without adjusting the unique_id. I feel this is not the right choice because there would be nothing stopping you from creating multiple services with the same User/App key pair. On the other hand, this does not break anything, just the behavior on the phone-app might not be wat the user expects.

i know i'm a fringe user as this issue affects me to begin with, but i think i might be 'really' fringe user as i have(had until the HA update) two different Pushover User Keys defined. one for personal use and one for work (Group Key) that gets used by the team. locking the User Key to a single instance would still be a breaking change from the YAML config option that was originally available.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's fine to reject adding another config entry with the same user_key + api_key as implemented in the PR.
However, should that check also be done in the reauth flow?

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 added the check in the reauth. Please check and confirm.

Choose a reason for hiding this comment

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

Many thanks for progress here!
Do the code changes handle only creating new entries by GUI or would it also allow importing multiple entries from existing configuration.yaml?

@frenck frenck added the smash Indicator this PR is close to finish for merging or closing label Sep 26, 2022
Copy link
Contributor

@emontnemery emontnemery left a comment

Choose a reason for hiding this comment

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

LGTM, thanks @engrbm87 👍

@emontnemery emontnemery added this to the 2022.10.0 milestone Sep 29, 2022
@emontnemery emontnemery merged commit d0ac107 into home-assistant:dev Sep 29, 2022
balloob pushed a commit that referenced this pull request Sep 29, 2022
* Allow entries with same user_key for Pushover

* remove unique_id completely

* Abort reauth if entered api_key already exists
Update tests
@github-actions github-actions bot locked and limited conversation to collaborators Sep 30, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bugfix by-code-owner cherry-picked cla-signed has-tests integration: pushover small-pr PRs with less than 30 lines. smash Indicator this PR is close to finish for merging or closing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Pushover GUI configuration allows only one instance
8 participants