Skip to content

Refactor Certificate Expiry Sensor#32066

Merged
jjlawren merged 15 commits intohome-assistant:devfrom
jjlawren:cert_expiry_refactor
Mar 2, 2020
Merged

Refactor Certificate Expiry Sensor#32066
jjlawren merged 15 commits intohome-assistant:devfrom
jjlawren:cert_expiry_refactor

Conversation

@jjlawren
Copy link
Copy Markdown
Contributor

@jjlawren jjlawren commented Feb 21, 2020

Breaking change

The name configuration option has been deprecated and is no longer used by the integration. An improved default entity & display naming scheme is provided. Name and entity_id overrides should be handled via the frontend.

Configurations using name will marked broken with the 0.109 release.

Proposed change

Based on feedback received in #32001, I've taken a different approach on fixing cert_expiry which has led to several changes:

  • Uses richer exceptions available in ssl starting with Python 3.7 and passes along new human-readable errors.
  • Allows adding currently failing domains via config flow
  • Retries temporary errors on startup to handle race conditions (e.g., checking HA's own cert)
  • Delays YAML imports until after HA is fully started (since imports do not retry)
  • Deprecates "name" configuration option and uses a descriptive default (non-breaking)
  • Gives entity names better defaults (sensor.cert_expiry_google_com instead of sensor.ssl_certificate_expiry or sensor.google)
  • Names config entries with domain instead of default of "SSL Certificate Expiry"

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Example entry for configuration.yaml:

# Example configuration.yaml
sensor:
  - platform: cert_expiry
    host: google.com

Additional information

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • The code has been formatted using Black (black --fast homeassistant tests)
  • Tests have been added to verify that the new code works.

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.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • Untested files have been added to .coveragerc.

The integration reached or maintains the following Integration Quality Scale:

  • No score or internal
  • 🥈 Silver
  • 🥇 Gold
  • 🏆 Platinum

@probot-home-assistant
Copy link
Copy Markdown

Hey there @cereal2nd, mind taking a look at this pull request as its been labeled with a integration (cert_expiry) you are listed as a codeowner for? Thanks!

@codecov
Copy link
Copy Markdown

codecov Bot commented Feb 21, 2020

Codecov Report

Merging #32066 into dev will increase coverage by 0.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##              dev   #32066      +/-   ##
==========================================
+ Coverage   94.74%   94.76%   +0.01%     
==========================================
  Files         768      777       +9     
  Lines       55639    56249     +610     
==========================================
+ Hits        52714    53302     +588     
- Misses       2925     2947      +22
Impacted Files Coverage Δ
homeassistant/components/cert_expiry/errors.py 100% <100%> (ø)
homeassistant/components/cert_expiry/sensor.py 100% <100%> (ø)
...omeassistant/components/cert_expiry/config_flow.py 100% <100%> (+1.63%) ⬆️
homeassistant/helpers/debounce.py 91.07% <0%> (-3.81%) ⬇️
homeassistant/helpers/storage.py 91.81% <0%> (-3.42%) ⬇️
...meassistant/components/websocket_api/connection.py 94.44% <0%> (-2.78%) ⬇️
...istant/components/google_assistant/report_state.py 83.33% <0%> (-1.67%) ⬇️
homeassistant/components/hue/bridge.py 70.68% <0%> (-1.39%) ⬇️
homeassistant/components/alexa/state_report.py 83.63% <0%> (-0.63%) ⬇️
homeassistant/components/tplink/light.py 95.97% <0%> (-0.58%) ⬇️
... and 63 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7c2765f...2f63069. Read the comment docs.

@springstan springstan changed the title Cert Expiry refactor Refactor Certificate Expiry Sensor Feb 21, 2020
Comment thread homeassistant/components/cert_expiry/config_flow.py Outdated
Comment thread homeassistant/components/cert_expiry/config_flow.py Outdated
Comment thread homeassistant/components/cert_expiry/config_flow.py Outdated
Comment thread homeassistant/components/cert_expiry/config_flow.py Outdated
Comment thread homeassistant/components/cert_expiry/config_flow.py Outdated
Comment thread homeassistant/components/cert_expiry/sensor.py Outdated
Comment thread homeassistant/components/cert_expiry/sensor.py Outdated
Comment thread homeassistant/components/cert_expiry/sensor.py Outdated
Comment thread homeassistant/components/cert_expiry/sensor.py Outdated
Comment thread tests/components/cert_expiry/test_config_flow.py Outdated
Comment thread tests/components/cert_expiry/test_config_flow.py Outdated
Comment thread homeassistant/components/cert_expiry/config_flow.py Outdated
Comment thread homeassistant/components/cert_expiry/helper.py Outdated
Comment thread tests/components/cert_expiry/test_init.py Outdated
Comment thread tests/components/cert_expiry/test_init.py Outdated
@jjlawren jjlawren force-pushed the cert_expiry_refactor branch from 7e28b76 to 91a7eb9 Compare February 25, 2020 05:11
Comment thread tests/components/cert_expiry/test_init.py Outdated
Comment thread tests/components/cert_expiry/test_init.py Outdated
Copy link
Copy Markdown
Member

@MartinHjelmare MartinHjelmare left a comment

Choose a reason for hiding this comment

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

Looks good!

@MartinHjelmare
Copy link
Copy Markdown
Member

Please write a breaking change paragraph about the name config item deprecation.

@MartinHjelmare
Copy link
Copy Markdown
Member

Should we merge?

@jjlawren jjlawren merged commit df3f768 into home-assistant:dev Mar 2, 2020
@jjlawren jjlawren deleted the cert_expiry_refactor branch March 4, 2020 04:11
@lock lock Bot locked and limited conversation to collaborators Mar 10, 2020
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.

Certificate Expiry sensor comes up as 'Unavailable' on every restart

4 participants