Skip to content

Migrate Mailgun to use the webhook component#17464

Merged
balloob merged 8 commits intohome-assistant:devfrom
rohankapoorcom:mailgun-webhooks
Oct 23, 2018
Merged

Migrate Mailgun to use the webhook component#17464
balloob merged 8 commits intohome-assistant:devfrom
rohankapoorcom:mailgun-webhooks

Conversation

@rohankapoorcom
Copy link
Copy Markdown
Member

@rohankapoorcom rohankapoorcom commented Oct 15, 2018

Description:

Migrating Mailgun over to the webhook API so that it doesn't need an api password.

This is built on top of #17460 (which is approved and needs to be merged before this one).

Breaking Change: Each instance of Home Assistant will now generate it's own unique webhook url for Mailgun to use. One will need to be generated and provided to Mailgun for incoming messages from Mailgun to Home Assistant to continue to flow.

I followed the approach used in #16817 to implement a new config flow to register the webhook. Existing configuration (api key, domain) still occurs via the configuration.yaml file.

I will update the documentation and unit tests once this gets an initial look. I want to validate that the approach makes sense first.

Related issue (if applicable): Related to #15376

Pull request in home-assistant.io with documentation (if applicable): home-assistant/home-assistant.io#7026

Checklist:

  • The code change is tested and works locally.
  • Local tests pass with tox. Your PR cannot be merged unless tests pass

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

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

  • New dependencies have been added to the REQUIREMENTS variable (example).
  • New dependencies are only imported inside functions that use them (example).
  • New or updated dependencies have been added to requirements_all.txt by running script/gen_requirements_all.py.
  • New files were added to .coveragerc.

If the code does not interact with devices:

  • Tests have been added to verify that the new code works.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

line too long (111 > 79 characters)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

'urllib.parse.parse_qsl' imported but unused

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

A lot of this code is directly copied from the IFTTT setup. I would be willing to create a superclass for use for both mailgun and ifttt config flow but I'm not sure if that's the best way of handling this duplication.

Is there any way to share some of the strings? Any value in doing so?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Good call on generalizing!

We should follow the same strategy as the generalized discovery flow: https://github.com/home-assistant/home-assistant/blob/dev/homeassistant/helpers/config_entry_flow.py#L7

Strings will still be done on a per component basis, which is good as for webhooks it can be all over the place.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Sounds good - I've done a pass over this and built a new webhook_config_entry_flow. Let me know if I went about this the right way before I write up tests for it.

@rohankapoorcom rohankapoorcom changed the title WIP: Migrate Mailgun to use the webhook component Migrate Mailgun to use the webhook component Oct 22, 2018
@@ -0,0 +1,61 @@
"""Helpers for data entry flows for config entries that use webhooks."""
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can you merge this file with helpers/config_entry_flow.py

@rohankapoorcom
Copy link
Copy Markdown
Member Author

@rohankapoorcom
Copy link
Copy Markdown
Member Author

rohankapoorcom commented Oct 23, 2018

Documentation updated and I added a section on this being a breaking change.

Once this is merged in, there should be a follow up PR where we implement the Making It Secure section from the Mailgun guide (this was never previously implemented in Home Assistant).

@ghost ghost assigned balloob Oct 23, 2018
@balloob
Copy link
Copy Markdown
Member

balloob commented Oct 23, 2018

Awesome work.

Yes you're right we can delete that test in IFTTT now. Added that in a commit to your branch.

@balloob balloob merged commit d5a5695 into home-assistant:dev Oct 23, 2018
@ghost ghost removed the in progress label Oct 23, 2018
@rohankapoorcom rohankapoorcom deleted the mailgun-webhooks branch October 23, 2018 14:31
@balloob balloob mentioned this pull request Nov 9, 2018
@home-assistant home-assistant locked and limited conversation to collaborators Feb 5, 2019
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.

6 participants