Skip to content

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

Merged
rohankapoorcom merged 3 commits into
home-assistant:devfrom
rohankapoorcom:gpslogger-unload
Jan 27, 2019
Merged

Load/unload gpslogger entities correctly between component and platform#20448
rohankapoorcom merged 3 commits into
home-assistant:devfrom
rohankapoorcom:gpslogger-unload

Conversation

@rohankapoorcom
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Member Author

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

Copy link
Copy Markdown
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
Copy Markdown
Member Author

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

"""Unload a config entry."""
hass.components.webhook.async_unregister(entry.data[CONF_WEBHOOK_ID])

hass.async_create_task(
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.

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

Copy link
Copy Markdown
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
Copy Markdown
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