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

Load/unload gpslogger entities correctly between component and platform #20448

Merged
merged 3 commits into from
Jan 27, 2019

Conversation

rohankapoorcom
Copy link
Member

@rohankapoorcom rohankapoorcom commented Jan 26, 2019

Description:

  • Move gpslogger device_tracker to be inside the component
  • Switch gpslogger device_tracker platform to use async_setup_entry/async_unload_entry
  • Switch gpslogger component to forward entries to the platform for setup/teardown
  • Add unit test for testing load/unload of the forwarded entries. This test is marked xfail (and will fail) because the device_tracker component does not support unloading entities yet.

Relates to #20237.

This came out of a couple of discussions with @MartinHjelmare #20083 (comment) and #20079 (comment).

Pull request in home-assistant.io with documentation (if applicable): home-assistant/home-assistant.io#<home-assistant.io PR number goes here>

Checklist:

  • The code change is tested and works locally.
  • Local tests pass with tox. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.

If the code does not interact with devices:

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

@MartinHjelmare
Copy link
Member

Will github correctly detect the module move if that is done separately in one commit, and further changes applied after in another commit?

@rohankapoorcom
Copy link
Member Author

Looks like yes it will, just force pushed with it broken up that way.

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.

Looks good!

@rohankapoorcom
Copy link
Member Author

Rebasing with dev to get the fix for the linting error.

return True


async def async_unload_entry(hass, entry):
"""Unload a config entry."""
hass.components.webhook.async_unregister(entry.data[CONF_WEBHOOK_ID])

hass.async_create_task(
Copy link
Member

Choose a reason for hiding this comment

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

We can await the coroutine directly. We don't need to create a task.

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.

Nice!

@MartinHjelmare
Copy link
Member

Can be merged when build passes.

@rohankapoorcom rohankapoorcom merged commit d179686 into home-assistant:dev Jan 27, 2019
@rohankapoorcom rohankapoorcom deleted the gpslogger-unload branch January 27, 2019 23:37
@ghost ghost removed the in progress label Jan 27, 2019
fredrike pushed a commit to fredrike/home-assistant that referenced this pull request Jan 30, 2019
…rm (home-assistant#20448)

* Embed device_tracker in gpslogger

* Load/unload gpslogger entities correctly between component and platform

* Await the coroutine directly
@balloob balloob mentioned this pull request Feb 6, 2019
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