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

Initialise plant attributes at startup #19315

Merged
merged 3 commits into from Dec 16, 2018

Conversation

PeteBa
Copy link
Contributor

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

@ghost ghost added the in progress label Dec 15, 2018
@pvizeli
Copy link
Member

pvizeli commented Dec 16, 2018

@MartinHjelmare
Copy link
Member

Test failure is unrelated and flaky.

@MartinHjelmare MartinHjelmare merged commit 9d4de2a into home-assistant:dev Dec 16, 2018
@ghost ghost removed the in progress label Dec 16, 2018
@PeteBa PeteBa deleted the fix-plant-initialisation branch December 16, 2018 21:31
@PeteBa
Copy link
Contributor Author

PeteBa commented Dec 16, 2018

Pascal/Martin, thanks for the review and feedback.

dshokouhi pushed a commit to dshokouhi/home-assistant that referenced this pull request Dec 25, 2018
* Initialise plant attributes at startup

* Pvizeli review comments

* Martin review change
@balloob balloob mentioned this pull request Jan 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Plant monitor no values in plant card after reboot
4 participants