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

Entity to handle updates via events #24733

Merged
merged 3 commits into from Jun 26, 2019

Conversation

@balloob
Copy link
Member

commented Jun 24, 2019

Description:

Entity registry used to keep a weak ref to an update method to allow entities to listen for when the entry was updated. This PR migrates that approach to instead listen for the entity registry updated events.

This did introduce a bit of an "Oh" moment: entities need to listen for updates when added to Home Assistant. However, the majority (90+%) of the integrations that implement async_add_to_hass do not call the super version.

So this PR introduces internal versions of the add and remove lifecycle callbacks. Not to be used by integrations. This will guarantee us that the right code is being called and can safely rely on it.

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.
  • I have followed the development checklist

If the code does not interact with devices:

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

@balloob balloob requested a review from home-assistant/core as a code owner Jun 24, 2019

balloob added 2 commits Jun 24, 2019
@pvizeli
Copy link
Member

left a comment

I think we should split the Entity Object. All function they are not interested by developers for integration should lands into an object i.e. EntityCore and that will be inherited from Entity they represent what devs need can overload.

@balloob

This comment has been minimized.

Copy link
Member Author

commented Jun 26, 2019

I like the idea of splitting it up.

@balloob balloob merged commit 06af6f1 into dev Jun 26, 2019

13 checks passed

build Workflow: build
Details
ci/circleci: pre-install-all-requirements Your tests passed on CircleCI!
Details
ci/circleci: pre-test 3.5.5 Your tests passed on CircleCI!
Details
ci/circleci: pre-test 3.6 Your tests passed on CircleCI!
Details
ci/circleci: pre-test 3.7 Your tests passed on CircleCI!
Details
ci/circleci: pylint Your tests passed on CircleCI!
Details
ci/circleci: static-check Your tests passed on CircleCI!
Details
ci/circleci: test 3.5.5 Your tests passed on CircleCI!
Details
ci/circleci: test 3.6 Your tests passed on CircleCI!
Details
ci/circleci: test 3.7 Your tests passed on CircleCI!
Details
cla-bot Everyone involved has signed the CLA
codecov/patch 100% of diff hit (target 94.12%)
Details
codecov/project 94.15% (target 90%)
Details

@delete-merged-branch delete-merged-branch bot deleted the entity-handle-updates branch Jun 26, 2019

mxworm added a commit to mxworm/home-assistant that referenced this pull request Jun 28, 2019
Merge branch 'dev' into current
* dev: (102 commits)
  Fix netatmo weatherstation setup error  (home-assistant#24788)
  Changed default encoding to mp3 (home-assistant#24808)
  Updated frontend to 20190627.0
  Use step from tado rather than assuming 0.1 (home-assistant#24807)
  Use climate device's target temp step value (home-assistant#24804)
  Fix another Life360 bug (home-assistant#24805)
  Zestimate fix for issue home-assistant#23837 (home-assistant#23838)
  Bump ZHA quirks module (home-assistant#24802)
  Make sure entity config is never none (home-assistant#24801)
  Update azure-pipelines-release.yml for Azure Pipelines (home-assistant#24800)
  Add time delta option when searching for deutsche_bahn connections (home-assistant#24600)
  Catch uncaught Alexa error (home-assistant#24785)
  Upgrade pytest to 4.6.3 (home-assistant#24782)
  Pubnub to 1.0.8 (home-assistant#24781)
  Fix life360 exception when no location provided (home-assistant#24777)
  Upgrade vallox to async client API (home-assistant#24774)
  Entity to handle updates via events (home-assistant#24733)
  Bumped version to 0.95.0
  Return correct name for met.no (home-assistant#24763)
  Ignore duplicate tradfri discovery (home-assistant#24759)
  ...
@balloob balloob referenced this pull request Jul 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.