Skip to content

Best effort state initialization of bayesian binary sensor#30962

Merged
bachya merged 5 commits into
home-assistant:devfrom
jlmcgehee21:fix/bayesian_binary_initialization
Mar 31, 2020
Merged

Best effort state initialization of bayesian binary sensor#30962
bachya merged 5 commits into
home-assistant:devfrom
jlmcgehee21:fix/bayesian_binary_initialization

Conversation

@jlmcgehee21
Copy link
Copy Markdown
Contributor

@jlmcgehee21 jlmcgehee21 commented Jan 19, 2020

Why:

This change addresses the need by:

  • Running the main update logic eagerly for each entity being observed
    on async_added_to_hass.
  • Test of the new behavior.

Breaking Change:

Description:

Related issue (if applicable): fixes #

Pull request with documentation for home-assistant.io (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.
  • I have followed the development checklist

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly. Update and include derived files by running python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt by running python3 -m script.gen_requirements_all.
  • Untested files have been added to .coveragerc.

If the code does not interact with devices:

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

@jlmcgehee21 jlmcgehee21 requested a review from bachya January 19, 2020 02:22
@jlmcgehee21 jlmcgehee21 force-pushed the fix/bayesian_binary_initialization branch 3 times, most recently from 50a43d3 to 43bf9a7 Compare January 19, 2020 03:01
@MartinHjelmare MartinHjelmare changed the title Best effort state initialization of bayesian binary sensor. Best effort state initialization of bayesian binary sensor Jan 19, 2020
@jlmcgehee21 jlmcgehee21 force-pushed the fix/bayesian_binary_initialization branch from d1d5f49 to b87f54c Compare January 19, 2020 14:56
Copy link
Copy Markdown
Contributor

@bachya bachya left a comment

Choose a reason for hiding this comment

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

Code looks good to me. I ran this in a local HASS and it appears to work as expected. I approve pending CI passing.

@jlmcgehee21
Copy link
Copy Markdown
Contributor Author

Sorry for the communication gap here -- do I actually need to increase test coverage to get this through? My change ended up adding a new test case to test the functionality. The decrease in coverage is an artifact of a minor refactor. I don't think I added anything new that's untested.

Definitely willing to add more coverage is that's a true blocker, not trying to push against it. I've just got a lot of things on my todo list, and interested in checking this off.

@bachya
Copy link
Copy Markdown
Contributor

bachya commented Feb 7, 2020

@jlmcgehee21 You don't need to add new test coverage, but this PR drops it by 2%, so it's not maintaining existing coverage.

@jlmcgehee21
Copy link
Copy Markdown
Contributor Author

So if I don’t touch this, it will get merged in the next release?

@bachya
Copy link
Copy Markdown
Contributor

bachya commented Feb 7, 2020

No. A PR can't drop coverage below 94%.

@jlmcgehee21
Copy link
Copy Markdown
Contributor Author

Ok thank you for the clarification. I’ll fix.

@jlmcgehee21 jlmcgehee21 force-pushed the fix/bayesian_binary_initialization branch from 8edc139 to 8d7d168 Compare February 25, 2020 03:08
@springstan
Copy link
Copy Markdown
Member

@jlmcgehee21 please resolve the merge conflict :)

Why:

* home-assistant#30119

This change addresses the need by:

* Running the main update logic eagerly for each entity being observed
  on `async_added_to_hass`.
* Test of the new behavior.
Why:

* Because for some reason my commits decreased test coverage.

This change addresses the need by:

* Adding coverage for the case where a device returns `STATE_UNKNOWN`
* Adding coverage for configurations with templates
@jlmcgehee21 jlmcgehee21 force-pushed the fix/bayesian_binary_initialization branch from 8d7d168 to dbfbc8a Compare March 5, 2020 04:14
@jlmcgehee21
Copy link
Copy Markdown
Contributor Author

I just deleted some comments and got failed tests in some unrelated code concerning timezones. Didn't investigate in depth, but it may be due to daylight savings last night.

@jlmcgehee21
Copy link
Copy Markdown
Contributor Author

Can someone with authority, re-run these tests? I believe the failure was related to daylight savings (see previous comment) @bachya @springstan

@frenck
Copy link
Copy Markdown
Member

frenck commented Mar 31, 2020

/AzurePipelines run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@bachya bachya merged commit dd1608d into home-assistant:dev Mar 31, 2020
@bachya
Copy link
Copy Markdown
Contributor

bachya commented Mar 31, 2020

Thank you! 🎉

@jlmcgehee21
Copy link
Copy Markdown
Contributor Author

👍 -- sorry for the long turnaround. Glad I was able to chip away and give back to a project that has given me so much!

@lock lock Bot locked and limited conversation to collaborators Apr 2, 2020
Comment on lines +301 to +302
print(self.current_observations)
print(self.observations_by_entity)
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.

Here are two print statements.

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.

nevermind, just saw removed 5 hours ago in #33916

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants