-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
Add range support to icon translations #145340
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
base: dev
Are you sure you want to change the base?
Conversation
Hey there @home-assistant/core, mind taking a look at this pull request as it has been labeled with an integration ( Code owner commandsCode owners of
|
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
Adds support for numeric range-based icons in the icon translation schema and enriches the battery sensor with range definitions.
- Introduces
range_key_validator
andensure_range_is_sorted
inscript/hassfest/icons.py
to validate numeric keys and enforce ascending order. - Extends the
icon_schema_slug
to accept an optional top‐levelrange
mapping and applies sorting checks understate_attributes
. - Provides a new
battery
icon definition withrange
entries inhomeassistant/components/sensor/icons.json
.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
File | Description |
---|---|
script/hassfest/icons.py | Added numeric‐key and sorted‐range validators; integrated range into the icon schema |
homeassistant/components/sensor/icons.json | Added battery sensor with a range of icons based on percentage |
Comments suppressed due to low confidence (2)
script/hassfest/icons.py:61
- Add unit tests for
ensure_range_is_sorted
to cover both valid (sorted) and invalid (unsorted or non‐numeric) range definitions.
def ensure_range_is_sorted(value: dict) -> dict:
homeassistant/components/sensor/icons.json:18
- [nitpick] This adds a
range
mapping for icons; please update the developer documentation to explain how to define and use range‐based icons in integration translation files.
"battery": {
Proposed change
Add range support to icon translations, meaning we can now provide icons based on the numeric state through the icons translation files.
Implements the proposal from architectural discussion: home-assistant/architecture#1190
As an example, the battery sensor has been enriched with range definitions, for which I've adjusted and cleaned up the frontend.
Type of change
Additional information
Checklist
ruff format homeassistant tests
)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest
.requirements_all.txt
.Updated by running
python3 -m script.gen_requirements_all
.To help with the load of incoming pull requests: