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

Initialise plant attributes at startup #19315

Merged
merged 3 commits into from Dec 16, 2018

Conversation

Projects
None yet
4 participants
@PeteBa
Copy link
Contributor

PeteBa commented Dec 15, 2018

Description:

The plant component tracks selected sensor entities and displays an aggregated view of a plant in the front-end. This PR is to resolve an issue that after restarting home assistant, there are often missing values in the plant cards even though the underlying sensors are present, e.g. in the card on the left the values are missing even though the underlying sensors exists and have valid values.

image

This is due to a timing issue on start-up where sensors created before the plant entity will not be displayed until their value is updated. This is due to the initial state change event of the sensor being sent before the plant entity has been created and is able to listen for the event. Thus the plant entity has to wait until the next sensor event is generated before being able to populate its attribute (this could be hours or more if the sensor is slow moving). This PR adds initialization logic to work around this timing problem.

@ChristianKuehnel , this as as per our discussion in the related issue and includes the improvements you suggested. Appreciate any thoughts / view on the PR.

Related issue (if applicable): fixes #18574

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

Example entry for configuration.yaml (if applicable):

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 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.
@pvizeli

This comment has been minimized.

Copy link
Member

pvizeli commented Dec 16, 2018

Move this line/logic

async_track_state_change(hass, sensor_entity_ids, entity.state_changed)
also into this function and it should be fine.

PeteBa added some commits Dec 16, 2018

@MartinHjelmare

This comment has been minimized.

Copy link
Member

MartinHjelmare commented Dec 16, 2018

Test failure is unrelated and flaky.

@MartinHjelmare MartinHjelmare merged commit 9d4de2a into home-assistant:dev Dec 16, 2018

3 of 4 checks passed

continuous-integration/travis-ci/pr The Travis CI build failed
Details
Hound No violations found. Woof!
WIP ready for review
Details
cla-bot Everyone involved has signed the CLA

@wafflebot wafflebot bot removed the in progress label Dec 16, 2018

@PeteBa PeteBa deleted the PeteBa:fix-plant-initialisation branch Dec 16, 2018

@PeteBa

This comment has been minimized.

Copy link
Contributor

PeteBa commented Dec 16, 2018

Pascal/Martin, thanks for the review and feedback.

dshokouhi added a commit to dshokouhi/home-assistant that referenced this pull request Dec 25, 2018

Initialise plant attributes at startup (home-assistant#19315)
* Initialise plant attributes at startup

* Pvizeli review comments

* Martin review change

@balloob balloob referenced this pull request Jan 10, 2019

Merged

0.85.0 #19897

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment