Skip to content

Feat: Set autlock default timings#566

Merged
tykeal merged 2 commits intoFutureTense:mainfrom
tykeal:default_autolock
Feb 26, 2026
Merged

Feat: Set autlock default timings#566
tykeal merged 2 commits intoFutureTense:mainfrom
tykeal:default_autolock

Conversation

@tykeal
Copy link
Collaborator

@tykeal tykeal commented Feb 26, 2026

  • feat: set default autolock timer values on first enable
  • feat: set max autolock timer value to 24 hours (1440 min)

tykeal and others added 2 commits February 26, 2026 04:14
When the autolock switch is enabled for the first time, populate
autolock_min_day (120 min) and autolock_min_night (15 min) with sane
defaults so the number entities are editable from dashboards without
requiring service calls or device-level workarounds.

Values are only set when None, so user-modified settings persist across
disable/re-enable cycles. Also updates DEFAULT_AUTOLOCK_MIN_NIGHT from
5 to 15 minutes.

Co-authored-by: GitHub Copilot <copilot@github.com>
Signed-off-by: Andrew Grimberg <tykeal@bardicgrove.org>
Add native_max_value=1440 to both day and night autolock number entities
to cap the allowed range at 24 hours.

Co-Authored-By: GitHub Copilot <copilot@github.com>
Signed-off-by: Andrew Grimberg <tykeal@bardicgrove.org>
@tykeal tykeal requested a review from Copilot February 26, 2026 12:18
@codecov-commenter
Copy link

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 84.60%. Comparing base (cdb4922) to head (459686d).
⚠️ Report is 34 commits behind head on main.
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #566      +/-   ##
==========================================
+ Coverage   84.14%   84.60%   +0.46%     
==========================================
  Files          10       25      +15     
  Lines         801     2735    +1934     
==========================================
+ Hits          674     2314    +1640     
- Misses        127      421     +294     
Flag Coverage Δ
python 84.60% <100.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request adds default timing values for the autolock feature and sets a maximum autolock timer value. When autolock is enabled for the first time, default values (120 minutes for day, 15 minutes for night) are automatically set. The PR also caps the maximum autolock timer at 24 hours (1440 minutes) and increases the default night autolock from 5 to 15 minutes.

Changes:

  • Set default autolock timer values on first enable (120 min day, 15 min night)
  • Increase default night autolock from 5 to 15 minutes
  • Add 24-hour (1440 minute) maximum limit for autolock timers

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
custom_components/keymaster/const.py Updated DEFAULT_AUTOLOCK_MIN_NIGHT from 5 to 15 minutes
custom_components/keymaster/number.py Added native_max_value=1440 to both day and night autolock number entities
custom_components/keymaster/switch.py Added logic to set default autolock timer values only when None (first enable)
tests/test_switch.py Added comprehensive tests for default value setting and user value persistence

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Collaborator

@firstof9 firstof9 left a comment

Choose a reason for hiding this comment

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

LGTM

@tykeal tykeal merged commit af52234 into FutureTense:main Feb 26, 2026
10 checks passed
@tykeal tykeal deleted the default_autolock branch February 26, 2026 21:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants