Using the counter helper can allow you to scroll through a series of scenes using only one or two buttons, but sadly it doesn’t have the ability currently to wrap around once you have reached the maximum value.
This means that you manually have to check if you have reached the end in your automation, and then set the counter to the beginning or the end, depending on which direction you are going.
Having the option build in to wrap around automatically would make this a lot easier, as then you don’t have to do this manually in your automation. This also means that you don’t have to store the maximum value in the automation itself.
In case someone else sees this post, I’ve created a pull request to implement this functionality.
Core PR
home-assistant:dev
← CrazyVito11:dev
opened 07:06PM - 07 Dec 24 UTC
<!--
You are amazing! Thanks for contributing to our project!
Please, DO N… OT DELETE ANY TEXT from this template! (unless instructed).
-->
## Proposed change
<!--
Describe the big picture of your changes here to communicate to the
maintainers why we should accept this pull request. If it fixes a bug
or resolves a feature request, be sure to link to that issue in the
additional information section.
-->
This PR implements my own [feature request I made on the community form](https://community.home-assistant.io/t/add-an-option-for-the-counter-helper-to-wrap-around/681557) a couple of months ago.
It adds an option to allow the counter component to wrap around once it reached it's minimum or maximum value.
The idea here is that it allows you to make it easier to wrap through lists, like for example a button that lists through scenes.
Right now I already have an automation that does this scene switching, but I have to manually reset the counter once I reach the end. This PR should automate that.
## Type of change
<!--
What type of change does your PR introduce to Home Assistant?
NOTE: Please, check only 1! box!
If your PR requires multiple boxes to be checked, you'll most likely need to
split it into multiple PRs. This makes things easier and faster to code review.
-->
- [ ] Dependency upgrade
- [ ] Bugfix (non-breaking change which fixes an issue)
- [ ] New integration (thank you!)
- [x] 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
<!--
Details are important, and help maintainers processing your PR.
Please be sure to fill out additional details, if applicable.
-->
- This PR fixes or closes issue: fixes #
- This PR is related to issue: https://community.home-assistant.io/t/add-an-option-for-the-counter-helper-to-wrap-around/681557
- Link to documentation pull request: https://github.com/home-assistant/home-assistant.io/pull/36217
- Link to frontend pull request: https://github.com/home-assistant/frontend/pull/23207
## Checklist
<!--
Put an `x` in the boxes that apply. You can also fill these out after
creating the PR. If you're unsure about any of them, don't hesitate to ask.
We're here to help! This is simply a reminder of what we are going to look
for before merging your code.
-->
- [x] The code change is tested and works locally.
- [x] Local tests pass. **Your PR cannot be merged unless tests pass**
- [x] There is no commented out code in this PR.
- [x] I have followed the [development checklist][dev-checklist]
- [x] I have followed the [perfect PR recommendations][perfect-pr]
- [x] The code has been formatted using Ruff (`ruff format homeassistant tests`)
- [x] Tests have been added to verify that the new code works.
If user exposed functionality or configuration variables are added/changed:
- [x] Documentation added/updated for [www.home-assistant.io][docs-repository]
If the code communicates with devices, web services, or third-party tools:
- [ ] The [manifest file][manifest-docs] 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.
<!--
This project is very active and we have a high turnover of pull requests.
Unfortunately, the number of incoming pull requests is higher than what our
reviewers can review and merge so there is a long backlog of pull requests
waiting for review. You can help here!
By reviewing another pull request, you will help raise the code quality of
that pull request and the final review will be faster. This way the general
pace of pull request reviews will go up and your wait time will go down.
When picking a pull request to review, try to choose one that hasn't yet
been reviewed.
Thanks for helping out!
-->
To help with the load of incoming pull requests:
- [x] I have reviewed two other [open pull requests][prs] in this repository.
[prs]: https://github.com/home-assistant/core/pulls?q=is%3Aopen+is%3Apr+-author%3A%40me+-draft%3Atrue+-label%3Awaiting-for-upstream+sort%3Acreated-desc+review%3Anone+-status%3Afailure
<!--
Thank you for contributing <3
Below, some useful links you could explore:
-->
[dev-checklist]: https://developers.home-assistant.io/docs/development_checklist/
[manifest-docs]: https://developers.home-assistant.io/docs/creating_integration_manifest/
[quality-scale]: https://developers.home-assistant.io/docs/integration_quality_scale_index/
[docs-repository]: https://github.com/home-assistant/home-assistant.io
[perfect-pr]: https://developers.home-assistant.io/docs/review-process/#creating-the-perfect-pr
Front-End PR
home-assistant:dev
← CrazyVito11:dev
opened 11:51PM - 07 Dec 24 UTC
<!--
You are amazing! Thanks for contributing to our project!
Please, DO N… OT DELETE ANY TEXT from this template! (unless instructed).
-->
## Proposed change
<!--
Describe the big picture of your changes here to communicate to the
maintainers why we should accept this pull request. If it fixes a bug
or resolves a feature request, be sure to link to that issue or discussion
in the additional information section.
-->
This change allows users to configure the new wrap around option in the `counter` component.
The idea here is that it allows you to make it easier to wrap through lists, like for example a button that lists through scenes.
> [!WARNING]
> The required core changes haven't been released yet at the time of writing this.
> See the related Core PR at **Additional information**
![image](https://github.com/user-attachments/assets/14f05db9-6440-4a93-a056-9fc682304bb6)
![image](https://github.com/user-attachments/assets/08939310-2369-4406-9bae-4df2926d95fb)
## Type of change
<!--
What type of change does your PR introduce to the Home Assistant frontend?
NOTE: Please, check only 1! box!
If your PR requires multiple boxes to be checked, you'll most likely need to
split it into multiple PRs. This makes things easier and faster to code review.
-->
- [ ] Dependency upgrade
- [ ] Bugfix (non-breaking change which fixes an issue)
- [x] New feature (thank you!)
- [ ] Breaking change (fix/feature causing existing functionality to break)
- [ ] Code quality improvements to existing code or addition of tests
## Example configuration
<!--
Supplying a configuration snippet, makes it easier for a maintainer to test
your PR.
-->
```yaml
counter:
bedroom_scene_switcher:
name: Bedroom scene switcher counter
initial: 0
step: 1
minimum: 0
maximum: 3
wrap_around: true
```
## Additional information
<!--
Details are important, and help maintainers processing your PR.
Please be sure to fill out additional details, if applicable.
-->
- This PR fixes or closes issue: fixes #
- This PR is related to issue or discussion: https://community.home-assistant.io/t/add-an-option-for-the-counter-helper-to-wrap-around/681557
- Link to documentation pull request: https://github.com/home-assistant/home-assistant.io/pull/36217
- Related core PR: https://github.com/home-assistant/core/pull/132575
## Checklist
<!--
Put an `x` in the boxes that apply. You can also fill these out after
creating the PR. If you're unsure about any of them, don't hesitate to ask.
We're here to help! This is simply a reminder of what we are going to look
for before merging your code.
-->
- [x] The code change is tested and works locally.
- [x] There is no commented out code in this PR.
- [x] Tests have been added to verify that the new code works.
If user exposed functionality or configuration variables are added/changed:
- [x] Documentation added/updated for [www.home-assistant.io][docs-repository]
<!--
Thank you for contributing <3
-->
[docs-repository]: https://github.com/home-assistant/home-assistant.io
Documentation PR
home-assistant:next
← CrazyVito11:next
opened 12:12AM - 08 Dec 24 UTC
<!--
You are amazing! Thanks for contributing to our project!
Please, DO N… OT DELETE ANY TEXT from this template! (unless instructed).
Before submitting your pull request, please verify that you have chosen the correct target branch,
and that the PR preview looks fine and does not include unrelated changes.
-->
## Proposed change
<!--
Describe the big picture of your changes here to communicate to the
maintainers why we should accept this pull request. If it fixes a bug
or resolves a feature request, be sure to link to that issue in the
additional information section.
-->
This change allows users to configure the new wrap around option in the `counter` component.
The idea here is that it allows you to make it easier to wrap through lists, like for example a button that lists through scenes.
## Type of change
<!--
What types of changes does your PR introduce to our documentation/website?
Put an `x` in the boxes that apply. You can also fill these out after
creating the PR.
-->
- [ ] Spelling, grammar or other readability improvements (`current` branch).
- [ ] Adjusted missing or incorrect information in the current documentation (`current` branch).
- [ ] Added documentation for a new integration I'm adding to Home Assistant (`next` branch).
- [ ] I've opened up a PR to add logos and icons in [Brands repository](https://github.com/home-assistant/brands).
- [x] Added documentation for a new feature I'm adding to Home Assistant (`next` branch).
- [ ] Removed stale or deprecated documentation.
## Additional information
<!--
Details are important, and help maintainers processing your PR.
Please be sure to fill out additional details, if applicable.
-->
- Link to parent pull request in the codebase: https://github.com/home-assistant/core/pull/132575
- Link to parent pull request in the Brands repository:
- This PR fixes or closes issue: fixes #
## Checklist
<!--
Put an `x` in the boxes that apply. You can also fill these out after
creating the PR. If you're unsure about any of them, don't hesitate to ask.
We're here to help! This is simply a reminder of what we are going to look
for before merging your code.
-->
- [x] This PR uses the correct branch, based on one of the following:
- I made a change to the existing documentation and used the `current` branch.
- I made a change that is related to an upcoming version of Home Assistant and used the `next` branch.
- [x] The documentation follows the Home Assistant documentation [standards].
[standards]: https://developers.home-assistant.io/docs/documenting/standards
## Summary by CodeRabbit
- **New Features**
- Introduced a new optional parameter, `wrap_around`, for the Counter integration configuration, allowing the counter to wrap around at its limits.
- **Documentation**
- Enhanced clarity and completeness of the Counter integration documentation, including updated descriptions for `minimum` and `maximum` parameters.
- Improved examples and explanations for better readability and understanding of the `restore` feature.