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

Alter OpenUV to allow for automatic updating of the protection window sensor #101737

Closed
wants to merge 23 commits into from

Conversation

bachya
Copy link
Contributor

@bachya bachya commented Oct 10, 2023

Proposed change

OpenUV entities are manually updated by calling the homeassistant.update_entity service to protect API overruns. Recently, I learned that the protection window API response contains the datetimes at which the protection window begins and ends; this means we no longer need to call homeassistant.update_entity on this entity.

Therefore, this PR does two things:

  1. Introduces automatic updating of the protection window entity
  2. Creates repair items for every automation that references the protection window binary sensor

No. 2 is technically not a deprecation, as users are still free to update the sensor ad hoc with homeassistant.update_entity (I currently don't have plans to remove this capability).

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)
  • Deprecation (breaking change to happen in the future)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

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
  • I have followed the perfect PR recommendations
  • 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.
  • For the updated dependencies - a link to the changelog, or at minimum a diff between library versions is added to the PR description.
  • Untested files have been added to .coveragerc.

To help with the load of incoming pull requests:

@bachya bachya self-assigned this Oct 10, 2023
@bachya bachya added new-feature and removed deprecation Indicates a breaking change to happen in the future labels Oct 10, 2023
@bachya
Copy link
Contributor Author

bachya commented Oct 10, 2023

While in draft, jotting some notes about how the update logic will work for the protection_window coordinator:

  • On integration load, get the latest protection_window data.
  • Determine what events to schedule:
    • If we're before the from timeframe, schedule state updates for both from (on) and to (off).
    • If we're in the window, schedule a state update (off) for to.
    • If we're after the to timeframe, do nothing.
    • In all cases, schedule another API refresh at the next midnight and start this process over.

@bachya bachya added deprecation Indicates a breaking change to happen in the future new-feature and removed new-feature deprecation Indicates a breaking change to happen in the future labels Oct 14, 2023
@codyc1515
Copy link
Contributor

The most recent release (2023.11) is showing the Protection Window sensor as Unknown following the update. Wondering if this might fix that? Let me know if you want me to raise a full ticket for that.

@bachya
Copy link
Contributor Author

bachya commented Nov 2, 2023

@codyc1515 It should. My day job unfortunately made it so I couldn't get this into today's release, but I'll try to wrap it up for the next one.

Copy link

There hasn't been any activity on this pull request recently. This pull request has been automatically marked as stale because of that and will be closed if no further activity occurs within 7 days.
If you are the author of this PR, please leave a comment if you want to keep it open. Also, please rebase your PR onto the latest dev branch to ensure that it's up to date with the latest changes.
Thank you for your contribution!

@github-actions github-actions bot added the stale label Feb 19, 2024
@github-actions github-actions bot closed this Feb 26, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Feb 27, 2024
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.

Allow OpenUV protection window update without API call
2 participants