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 config flow to discord #61069

Merged
merged 17 commits into from
Mar 30, 2022
Merged

Conversation

tkdrob
Copy link
Contributor

@tkdrob tkdrob commented Dec 5, 2021

Breaking change

Discord can now be set up in the UI. Existing yaml configurations are automatically imported and can be safely removed.

Proposed change

Add config flow to discord

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)
  • 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:

@github-actions
Copy link

github-actions bot commented Jan 5, 2022

There hasn't been any activity on this pull request recently. This pull request has been automatically marked as stale because of that and will be closed if no further activity occurs within 7 days.
Thank you for your contributions.

@github-actions github-actions bot added the stale label Jan 5, 2022
@tkdrob
Copy link
Contributor Author

tkdrob commented Jan 5, 2022

Config flows take a while in the queue so it should not be closed by the bot.

@github-actions github-actions bot removed the stale label Jan 5, 2022
Copy link
Member

@frenck frenck left a comment

Choose a reason for hiding this comment

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

Please note, the upstream library has been archived and is unmaintained.
It won't be compatible with our Python 3.10 upgrade at this point.

https://github.com/Rapptz/discord.py

@tkdrob
Copy link
Contributor Author

tkdrob commented Jan 10, 2022

Please note, the upstream library has been archived and is unmaintained. It won't be compatible with our Python 3.10 upgrade at this point.

https://github.com/Rapptz/discord.py

Well that blows, not sure if there is another suitable package.

@frenck
Copy link
Member

frenck commented Feb 21, 2022

@tkdrob Meanwhile; I've replaced the discord.py package by nextcord in the current dev branch.

@tkdrob
Copy link
Contributor Author

tkdrob commented Feb 21, 2022

@tkdrob Meanwhile; I've replaced the discord.py package by nextcord in the current dev branch.

This latest commit will fail due to mypy. Discord in dev seems to have a problem Channel not found for ID:

@tkdrob
Copy link
Contributor Author

tkdrob commented Feb 22, 2022

@tkdrob Meanwhile; I've replaced the discord.py package by nextcord in the current dev branch.

I can also go back to Node Red, the Discord node works there 😜

@frenck frenck self-requested a review March 14, 2022 20:00
@frenck
Copy link
Member

frenck commented Mar 14, 2022

Well, tested locally, that works as expected:

image

Copy link
Member

@frenck frenck left a comment

Choose a reason for hiding this comment

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

Some initial comments. I haven't looked a the tests yet.

homeassistant/components/discord/__init__.py Outdated Show resolved Hide resolved
homeassistant/components/discord/notify.py Outdated Show resolved Hide resolved
homeassistant/components/discord/notify.py Outdated Show resolved Hide resolved
homeassistant/components/discord/strings.json Outdated Show resolved Hide resolved
homeassistant/components/discord/strings.json Outdated Show resolved Hide resolved
homeassistant/components/discord/strings.json Outdated Show resolved Hide resolved
homeassistant/components/discord/config_flow.py Outdated Show resolved Hide resolved
homeassistant/components/discord/config_flow.py Outdated Show resolved Hide resolved
homeassistant/components/discord/config_flow.py Outdated Show resolved Hide resolved
homeassistant/components/discord/config_flow.py Outdated Show resolved Hide resolved
@tkdrob tkdrob marked this pull request as draft March 15, 2022 23:29
@tkdrob tkdrob marked this pull request as ready for review March 17, 2022 02:27
@frenck frenck added the config-flow This integration migrates to the UI by adding a config flow label Mar 19, 2022
@frenck frenck self-requested a review March 19, 2022 11:00
Copy link
Member

@frenck frenck left a comment

Choose a reason for hiding this comment

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

Nice! Thanks, @tkdrob 👍

@frenck frenck merged commit 9f0665b into home-assistant:dev Mar 30, 2022
@tkdrob tkdrob deleted the discord_config_Flow branch March 30, 2022 11:20
@epenet epenet mentioned this pull request Mar 30, 2022
22 tasks
@github-actions github-actions bot locked and limited conversation to collaborators Mar 31, 2022
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.

Please address the comments in a new PR. Thanks!

return await self.async_step_reauth_confirm()

self._set_confirm_only()
return self.async_show_form(step_id="reauth")
Copy link
Member

Choose a reason for hiding this comment

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

The form should be shown by the confirm step. The reauth step will always receive the existing config entry data as input.

Platform.NOTIFY,
DOMAIN,
hass.data[DOMAIN][entry.entry_id],
hass.data[DOMAIN],
Copy link
Member

Choose a reason for hiding this comment

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

Same comments as for the slack config flow PR. See the Tibber integration for the correct way to call this function.

context={"source": config_entries.SOURCE_USER},
)
with mocked_discord_info(), patch_discord_login():
result = await hass.config_entries.flow.async_configure(
Copy link
Member

Choose a reason for hiding this comment

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

We normally patch the integration setup function on all create entry and reauth_successful results to avoid setting up the whole integration.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants