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

Fix Mi Flora median calculation #16085

merged 9 commits into from Sep 4, 2018


None yet
4 participants

PaulAnnekov commented Aug 20, 2018


miflora library caches values for 20 minutes. miflora HA component updates values each 30 seconds. Component gets 3 value updates, calculates median and sets state. During 20 minutes we get the same values from cache which makes median calculation totally useless - all values will be the same.

  • Removed cache_value conf in favor of native scan_interval, which is now set to 1200 seconds and used for both update interval and cache timeout in the library.
  • Added initial value on component start, to show at least anything before 40+ minutes will past and median will be calculated
  • Added support for PlatformNotReady to don't delay HA startup
  • Removed ble_timeout and retries, they are not used in miflora library anymore and, actually, we don't need them

Pull request in with documentation (if applicable): home-assistant/

Breaking changes:

Removed retries and timeout config parameters, they were not used for several months. Replaced cache_value config with scan_interval to fix a bug in the PR.


  • Update docs.
  • Deal with initial value, so user won't wait 1 hour to see first data.
  • The code change is tested and works locally.

PaulAnnekov added some commits Sep 2, 2018

@PaulAnnekov PaulAnnekov referenced this pull request Sep 2, 2018


Update Miflora documentation #6163

2 of 2 tasks complete

@PaulAnnekov PaulAnnekov changed the title from (WIP) Fixed Mi Flora calculated median from the same cached values to Fixed Mi Flora calculated median from the same cached values Sep 2, 2018



Please add a paragraph about the breaking change in the PR description for the release notes.


This comment has been minimized.

Show comment
Hide comment

PaulAnnekov commented Sep 3, 2018

@MartinHjelmare MartinHjelmare changed the title from Fixed Mi Flora calculated median from the same cached values to Fix Mi Flora median calculation Sep 4, 2018

@MartinHjelmare MartinHjelmare merged commit e1501c8 into home-assistant:dev Sep 4, 2018

5 checks passed

Hound No violations found. Woof!
WIP ready for review
cla-bot Everyone involved has signed the CLA
continuous-integration/travis-ci/pr The Travis CI build passed
coverage/coveralls Coverage decreased (-0.007%) to 93.759%

@wafflebot wafflebot bot removed the in progress label Sep 4, 2018

cyberjacob pushed a commit to cyberjacob/home-assistant that referenced this pull request Sep 4, 2018

Fix Mi Flora median calculation (home-assistant#16085)
* fixed median was based on 1.5 minute interval, not 1 hour

* ignore median and set state from first value, when previous state was None

* update before add, removed unused 'retries' and 'ble_timeout', check if platform ready

* added missing blank line

* fixed too long line

* using modern python 3.5 features, changed comment to be less verbose

* continuation line fix

* removed DEFAULT_SCAN_INTERVAL in favor of existing SCAN_INTERVAL

@balloob balloob referenced this pull request Sep 17, 2018


0.78.0 #16666

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