-
Notifications
You must be signed in to change notification settings - Fork 277
feat: Support update timer #981
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
Conversation
There was a problem hiding this 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 PR adds an update_timer
feature that allows button cards to automatically refresh at specified intervals. This is particularly useful for cards without entities or when triggers_update
is not suitable.
Key changes:
- Added new
update_timer
configuration option that accepts a number (>=100ms) or template - Implemented timer-based card refresh mechanism with proper cleanup
- Added comprehensive documentation and test examples
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
File | Description |
---|---|
src/types/types.ts | Added update_timer property to button card configuration interfaces |
src/button-card.ts | Implemented timer logic with timeout management and refresh mechanism |
test/ui-lovelace.yaml | Added test cases demonstrating static and template-based update timers |
README.md | Documented the new update_timer feature with usage guidelines |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Co-authored-by: Copilot <[email protected]>
Thanks! What about using https://www.npmjs.com/package/parse-duration to parse the field to make it a bit more user friendly? One thing however, I think that if |
I have implemented parse, also added as a helper Regarding when to update, I have left as is. Suppose a user is using an entity, which needs to update, but then also an update timer of say '1 minute' for a slow updating custom_field. In this case only updating on the updates_timer will miss the entity update. |
I do agree with the use case, but I'm pretty sure some users would want to ONLY update on interval 😄 Maybe an option to force only updating on interval? |
How about |
This has been added including to make sure that if update_timer is in use and hass updated that the duration is checked, and if not the same as active, then return true for shouldUpdate. New timer will be started after the update (existing) which makes sure not to intriduced any update loops. I think the doco makes sense. I tried not to be too wordy. |
## [5.0.0-dev.1](v4.3.0...v5.0.0-dev.1) (2025-09-16) ### ⚠ BREAKING CHANGES * **color:** Card background color will always be `var (--card-background-color)` when state is inactive and `color_type: card`. You can set card background with state. ### Features * Add `icon_*_action` support ([#984](#984)) ([4e02887](4e02887)), closes [#739](#739) * Support update timer ([#981](#981)) ([4717feb](4717feb)), closes [#436](#436) ### Bug Fixes * **color:** inactive card background no longer inactive color when `colour_type: card` and `color` set. ([#987](#987)) ([b4f00f9](b4f00f9)), closes [#754](#754) * Embedded light card handle issue ([#989](#989)) ([d01ef37](d01ef37)), closes [#427](#427) [#901](#901) * Hold action on picture entity ([#996](#996)) ([9f2501f](9f2501f)), closes [#994](#994) * Move while hold on touch devices ([#993](#993)) ([2c17386](2c17386))
🎉 This PR is included in version 5.0.0-dev.1 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
Closes custom-cards#436 https://github.com/user-attachments/assets/0c7db4d8-39bf-4d5a-8c7d-98a2d0a1a35d --------- Co-authored-by: Copilot <[email protected]> Co-authored-by: Jérôme Wiedemann <[email protected]>
## [5.0.0-dev.1](custom-cards/button-card@v4.3.0...v5.0.0-dev.1) (2025-09-16) ### ⚠ BREAKING CHANGES * **color:** Card background color will always be `var (--card-background-color)` when state is inactive and `color_type: card`. You can set card background with state. ### Features * Add `icon_*_action` support ([custom-cards#984](custom-cards#984)) ([4e02887](custom-cards@4e02887)), closes [custom-cards#739](custom-cards#739) * Support update timer ([custom-cards#981](custom-cards#981)) ([4717feb](custom-cards@4717feb)), closes [custom-cards#436](custom-cards#436) ### Bug Fixes * **color:** inactive card background no longer inactive color when `colour_type: card` and `color` set. ([custom-cards#987](custom-cards#987)) ([b4f00f9](custom-cards@b4f00f9)), closes [custom-cards#754](custom-cards#754) * Embedded light card handle issue ([custom-cards#989](custom-cards#989)) ([d01ef37](custom-cards@d01ef37)), closes [custom-cards#427](custom-cards#427) [custom-cards#901](custom-cards#901) * Hold action on picture entity ([custom-cards#996](custom-cards#996)) ([9f2501f](custom-cards@9f2501f)), closes [custom-cards#994](custom-cards#994) * Move while hold on touch devices ([custom-cards#993](custom-cards#993)) ([2c17386](custom-cards@2c17386))
Closes #436
Screen.Recording.2025-08-31.at.5.00.35.pm.mov