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 configuration flow to Todoist integration #100094

Merged
merged 5 commits into from
Sep 12, 2023

Conversation

allenporter
Copy link
Contributor

@allenporter allenporter commented Sep 11, 2023

Proposed change

Add a config flow to the Todoist integration. The motivation for doing this is to prepare for adding more platforms. (todo platform proposal)

The existing yaml configuration supports many options that are not supported in the config flow. The platform yaml configuration will remain, and those cannot be imported.

The service that creates new tasks currently does not support multiple configurations. Therefore, the new configuration flow only allows one instance.

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 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.

To help with the load of incoming pull requests:

@allenporter allenporter marked this pull request as draft September 11, 2023 04:59
@home-assistant
Copy link

Hey there @boralyl, mind taking a look at this pull request as it has been labeled with an integration (todoist) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of todoist can trigger bot actions by commenting:

  • @home-assistant close Closes the pull request.
  • @home-assistant rename Awesome new title Renames the pull request.
  • @home-assistant reopen Reopen the pull request.
  • @home-assistant unassign todoist Removes the current integration label and assignees on the pull request, add the integration domain after the command.

@allenporter allenporter marked this pull request as ready for review September 11, 2023 05:31
@allenporter allenporter merged commit 183b779 into home-assistant:dev Sep 12, 2023
21 checks passed
_LOGGER.exception("Unexpected exception")
errors["base"] = "unknown"
else:
await self.async_set_unique_id(user_input[CONF_TOKEN])
Copy link
Member

Choose a reason for hiding this comment

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

Why do we set a unique id if we only allow one config entry? And the inverse question, why only allow one config entry if we can set a unique id?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Second question first: I first set this up with a unique id then saw the service call adds tasks without referencing a config entry or entity, and so that looked like a problem.
(The config entry however does reference a project name, so it could be possible perhaps to infer but that seemed sketchy).

First question: However, I thought it might be possible to add more config entries in the future if the service changes or is deprecated so I left the unique id. I didn't think it hurts, is there a down side?

As we talk through, I also realize this could potentially be updated in the future to support re-auth updating the API key so maybe this isn't a valid in unique id. I was thinking of it like an oauth client id but realize how it's not really like than. Given that, perhaps needs to be removed anyway. I'm not sure what, then, could be a unique id but theoretically I'd like this to be able to support multiple accounts since once the service is fixed there's no big reason it couldn't otherwise.

Copy link
Member

Choose a reason for hiding this comment

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

Ok. Yeah, I don't think token is a good unique_id since we want to be able to re-authenticate without changing unique_id.

I'd migrate the service to an entity service. The service call targets a specific project which equals an entity, right? Then we don't need to worry about unique_id for the config entry for the sake of the service.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will remove the unique id...

Yeah entity service sounds right. When I did the same thing for Google calendar, it needed to be a new service with a new name etc and s deprecation period before removal of the old service? That is, it can't be immediately moved.

I'm thinking here that using a new Todo entity service may work...

Am I thinking about that right or is there a shortcut?

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, it will need to be a new service so we can keep the old one around and create a repair issue when the old service is called, telling users to use the new service instead. The entity service will require an entity target so we can't reuse the old service name if we want old service calls to still work.

@frenck
Copy link
Member

frenck commented Sep 12, 2023

This PR was merged without docs? It should not have been merged in that case.

@allenporter Please make sure to open up a documentation PR.

../Frenck

@allenporter
Copy link
Contributor Author

This PR was merged without docs? It should not have been merged in that case.

@allenporter Please make sure to open up a documentation PR.

../Frenck

Thanks for catching, definitely a mistake and something I knew about then forgot to do -- the checks looked all green, but obviously I can see they aren't now. Was not intentional!

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

5 participants