Feat: Set autlock default timings#566
Conversation
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)
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>
|
Codecov Report✅ All modified and coverable lines are covered by tests. 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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
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.