Skip to content

Load/unload geofency entities correctly between component and platform#20497

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

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

Conversation

@rohankapoorcom
Copy link
Copy Markdown
Member

Description:

  • Switch geofency device_tracker platform to use async_setup_entry/async_unload_entry
  • Switch geofency 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. Like #20448 but for geofency.

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.

Comment thread tests/components/geofency/test_init.py Outdated
"""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 Author

Choose a reason for hiding this comment

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

Isn't better practice to create a task so that we don't block this thread? Or does it not matter since all we're doing is registering with the dispatcher?

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.

There is no risk of deadlock when using this method.

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! Can be merged when build passes.

@rohankapoorcom rohankapoorcom merged commit f575d1d into home-assistant:dev Jan 27, 2019
@ghost ghost removed the in progress label Jan 27, 2019
@rohankapoorcom rohankapoorcom deleted the geofency-unload branch January 27, 2019 21:18
fredrike pushed a commit to fredrike/home-assistant that referenced this pull request Jan 30, 2019
home-assistant#20497)

* Load/unload geofency entities correctly between component and platform

* Lint

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

4 participants