Skip to content

Rebuild home_valueXX_icon_color engine#10

Merged
edwardtfn merged 26 commits intomainfrom
v9999.99.9
Feb 5, 2026
Merged

Rebuild home_valueXX_icon_color engine#10
edwardtfn merged 26 commits intomainfrom
v9999.99.9

Conversation

@edwardtfn
Copy link
Copy Markdown
Owner

@edwardtfn edwardtfn commented Feb 4, 2026

Fixes Blackymas/NSPanel_HA_Blueprint#3226

Summary by CodeRabbit

  • Refactor

    • Home page values now validate inputs, use a centralized default color (with per-item overrides) and support per-entry icon/color overrides; Home Assistant minimum bumped to 2025.12.0.
  • New Features

    • Automated versioning and tagging workflow, plus a bump script and unified external version source.
  • Documentation

    • Added versioning README and removed the old compatibility matrix.
  • Tests

    • Extensive unit tests for the new versioning system and workflow.
  • Chores

    • Updated funding metadata.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Feb 4, 2026

Warning

Rate limit exceeded

@edwardtfn has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 6 minutes and 10 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📝 Walkthrough

Walkthrough

Centralizes default home value color via a YAML anchor and refactors per-item templating for Home Values 01–04; adds a time-based versioning system (VERSION files, bump script, README), extensive unit tests, a GitHub Actions workflow to automate version bumps/tags, and makes ESPHome include the version YAML.

Changes

Cohort / File(s) Summary
Home page blueprint
nspanel_easy_blueprint.yaml
Add &default_home_value_color anchor; replace repeated [200, 204, 200] literals; add per-item validation and templated conditional steps for label color, icon color, icon rendering, and propagate default_color for Home Values 01–04.
Versioning workflow & automation
.github/workflows/versioning.yml, versioning/bump_version.sh, versioning/VERSION, versioning/VERSION_YAML, versioning/README.md
Introduce time-based versioning: bump_version.sh computes/writes YYYY.MM.seq to VERSION/VERSION_YAML, commits with skip marker and tags; workflow executes bump, builds tag message, pushes commits/tags and optionally updates stable/latest tags; README documents usage and format.
ESPhome version include
esphome/nspanel_esphome_version.yaml
Replace hardcoded substitutions.version with an include/reference to versioning/VERSION_YAML; adjust minimum version fields.
Tests
.test/unit/test_versioning.py, .test/unit/test_versioning_advanced.py
Add comprehensive unit tests covering VERSION/VERSION_YAML formats, bump script behavior, workflow structure, ESPHome inclusion, README content, edge cases, security, and integration scenarios.
Docs cleanup
docs/version_compatibility.md
Remove the existing version compatibility table content.
Funding metadata
.github/FUNDING.yml
Replace commented placeholders with explicit single-line sponsorship entries and add YAML document start marker.
Misc (manifest)
manifest (and related small metadata edits)
Adjustments consistent with version/minimum updates reported in summaries.

Sequence Diagram(s)

sequenceDiagram
  participant GH as GitHub Actions (versioning.yml)
  participant Repo as Repository
  participant Script as bump_version.sh
  participant Remote as Git Remote

  GH->>Repo: checkout code
  GH->>Repo: determine PR or push metadata
  GH->>Script: execute bump_version.sh
  Script->>Repo: read versioning/VERSION
  Script-->>Script: validate format & compute next version
  Script->>Repo: write VERSION and VERSION_YAML
  Script->>Repo: git add/commit (with [skip-versioning])
  Script->>Repo: git tag vX.Y.Z
  GH->>Remote: push commit and tags
  GH->>Remote: optionally update stable/latest tags
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

🐰 I hopped through YAML and left an anchor clear,
I painted tiny values so each color may appear,
A script counts months and tags into the night,
Tests keep watch while workflows push things right,
I twitch my nose — the repo feels light.

🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning The PR includes significant out-of-scope changes unrelated to fixing the home_valueXX color rendering issue: versioning system files (bump_version.sh, VERSION, VERSION_YAML, GitHub Actions workflow), extensive test suites (test_versioning.py, test_versioning_advanced.py), documentation updates, and FUNDING.yml modifications. Separate versioning system implementation, test suites, and unrelated documentation changes into a dedicated PR; keep this PR focused solely on fixing the home_valueXX color engine issue.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Rebuild home_valueXX_icon_color engine' directly reflects the main change in the PR - refactoring the color and icon rendering logic for home value entries in the blueprint YAML.
Linked Issues check ✅ Passed The PR comprehensively addresses issue #3226 by refactoring the Home page Values rendering block with per-item validation, per-item color templates, and conditional logic to enable per-entry color overrides, fixing the ignored home_value02_label_color and home_value02_icon_color configuration issue.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch v9999.99.9

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d560931fcd

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@nspanel_easy_blueprint.yaml`:
- Around line 9373-9422: The condition blocks use invalid YAML/Jinja: replace
the bare "- condition:" list at the top with explicit template conditions (each
item should be a condition: template with value_template: "..." or convert the
list of Jinja booleans into separate template condition entries), and remove the
invalid "{{ if ... }}" wrappers inside the three nested "if:" lists (alias "Text
color", "Icon color", "Icon") — instead use plain templates (e.g.
value_template: "{{ repeat.item.label_color_rgb is defined }}", value_template:
"{{ repeat.item.icon is defined }}", etc.) so the template conditions evaluate
correctly for repeat.item and the actions (esphome.{{ nspanel_name
}}_component_color / _text with ids like '{{ repeat.item.component }}' and '{{
repeat.item.component }}_icon') execute as intended.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 Fix all issues with AI agents
In @.github/workflows/versioning.yml:
- Around line 6-33: Add an explicit permissions: block for the workflow so
GITHUB_TOKEN has push/tag and PR lookup rights; insert a top-level permissions:
mapping (near the top of the workflow) that grants at minimum contents: write
and pull-requests: read to allow the version-and-tag job to git push
tags/commits and call listPullRequestsAssociatedWithCommit using GITHUB_TOKEN;
ensure the block uses the literal keys "permissions:", "contents: write", and
"pull-requests: read" so the version-and-tag job can operate correctly.

In `@versioning/README.md`:
- Around line 33-38: Update the README example to reference the correct project
(replace the incorrect TX-Ultimate-Easy-ESPHome_core.yaml reference with the
NSPanel-Easy project name) and fix the YAML snippet by removing the invalid
merge operator so the substitutions entry uses a simple include for the scalar
version value (change the line with "version: <<: !include
../versioning/VERSION" to "version: !include ../versioning/VERSION").

In `@versioning/VERSION_YAML`:
- Line 1: Add explicit YAML document markers around the existing version entry
to satisfy the linter: prepend a document start marker "---" before the line
"version: 9999.99.9" and append a document end marker "..." (or at minimum a
trailing newline) after it in VERSION_YAML so the file becomes a proper YAML
document with start and end markers.
🧹 Nitpick comments (1)
versioning/README.md (1)

29-29: Consider active voice for clarity.

The passive construction "is needed" could be reworded to active voice for slightly stronger prose.

✍️ Suggested rewording
-- No manual intervention is needed for versioning.
+- The workflow requires no manual intervention for versioning.

…in permissions

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In @.github/workflows/versioning.yml:
- Around line 125-131: The workflow step "Push Changes and Tags" currently
force-pushes all tags which can rewrite unrelated history; change the push logic
to push only the branch and the specific new tag instead of "--tags --force" —
use the existing branch push (git push origin main) and replace the global force
push with a targeted push of the newly created tag (e.g., git push origin
<NEW_VERSION_TAG>) and avoid using --force unless you intentionally need to
overwrite a well-known stable/latest tag (in that case only force that one tag
by name). Locate the commands in the "Push Changes and Tags" step and update
them to push the single tag variable used by your bump script and remove the
blanket --force.
🧹 Nitpick comments (1)
.github/workflows/versioning.yml (1)

145-149: Clarify or implement tag backups

The “Backup existing tag” blocks only record the SHA and don’t create a backup tag, which can be misleading. Either create backup tags or clarify the comment to match the behavior.

✍️ Minimal clarification
-          # Backup existing tag
+          # Capture existing tag SHA for logging
           if git rev-parse --verify stable >/dev/null 2>&1; then
             OLD_STABLE=$(git rev-parse stable)
             echo "Backing up current stable tag ($OLD_STABLE)"
           fi
-          # Backup existing tag
+          # Capture existing tag SHA for logging
           if git rev-parse --verify latest >/dev/null 2>&1; then
             OLD_LATEST=$(git rev-parse latest)
             echo "Backing up current latest tag ($OLD_LATEST)"
           fi

Also applies to: 171-174

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Feb 5, 2026

Note

Unit test generation is a public access feature. Expect some limitations and changes as we gather feedback and continue to improve it.


Generating unit tests... This may take up to 20 minutes.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Feb 5, 2026

13 INTERNAL: Received RST_STREAM with code 2 (Internal server error)

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Feb 5, 2026

Note

Unit test generation is a public access feature. Expect some limitations and changes as we gather feedback and continue to improve it.


Generating unit tests... This may take up to 20 minutes.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In @.github/workflows/versioning.yml:
- Around line 101-120: The tag_message step currently writes PR title/body via
an unquoted heredoc in the run block of the tag_message job, which allows shell
expansions; update the tag_message generation in the GitHub Actions step (the
"Create tag message" step with id tag_message) to safely handle PR content by
either using a quoted heredoc delimiter (e.g., <<'EOF') for the heredoc blocks
that create tag_message.txt or, preferably, export the PR title and body from
steps.pr_info.outputs into safe environment variables and use printf to write
tag_message.txt with those variables (ensuring you reference
steps.pr_info.outputs.result when extracting title/body). Ensure both the push
branch (uses fromJson(steps.pr_info.outputs.result).title/body) and the
manual-dispatch branch are updated the same way to prevent command injection.

In `@versioning/README.md`:
- Around line 15-19: Update the README.md section that describes the versioning
workflow to remove or revise the incorrect steps about temporary branch
creation, merging, and cleanup; instead document the actual behavior:
versioning.yml checks out main, bump_version.sh updates VERSION and VERSION_YAML
and commits directly to the current branch with the [skip-versioning] marker,
then pushes main and the version tag. Locate the paragraph mentioning temporary
branches (lines referencing "Temporary Branch Creation", "Merge into Main", and
"Branch Cleanup") and replace it with a concise description of the direct-commit
flow referencing versioning.yml and bump_version.sh so the docs match the
implementation.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Feb 5, 2026

✅ Unit tests committed locally. Commit: 253845dda90bc80130d7b08b1e79d521de011a8c

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🤖 Fix all issues with AI agents
In @.github/workflows/versioning.yml:
- Around line 101-124: The YAML lint error is caused by excessive spacing after
the colon in the environment variable declaration (PR_BODY) within the "Create
tag message" step; edit that step so the env keys use a single space after the
colon (e.g., change "PR_BODY:  ${{ ... }}" to "PR_BODY: ${{ ... }}"), and ensure
the same spacing convention is applied to "PR_TITLE" and other env entries to
satisfy YAML style checks.

In @.test/unit/test_versioning_advanced.py:
- Around line 214-222: The test test_workflow_commit_message_has_skip_marker
assigns an unused variable content from WORKFLOW_PATH.read_text(); remove that
unused assignment (the symbol content) to eliminate the dead variable, or if
intended, use WORKFLOW_PATH (or content) in the assertion—most simply delete the
line "content = self.WORKFLOW_PATH.read_text()" so only script_content is read
and used in the test.

In @.test/unit/test_versioning.py:
- Around line 60-66: The assertion for month currently allows 1-99 which is
incorrect for calendar months; update the test to enforce 1 <= month <= 12
(replace the line asserting 1 <= month <= 99) so the month validation is strict,
keeping the existing positive sequence check (assert sequence >= 1) unchanged;
if the wider range was intentional, instead add an explicit comment explaining
why month can exceed 12 rather than leaving the permissive range unannotated.
- Around line 16-21: Replace hardcoded absolute paths (e.g.,
TestVersionFiles.VERSION_FILE and TestVersionFiles.VERSION_YAML_FILE) with paths
computed relative to the repository root or via a pytest fixture; create a
repo_root fixture (or compute Path(__file__).resolve().parents[n]) and use it to
set class attributes like TestBumpVersionScript.SCRIPT_PATH,
TestVersioningREADME.README_PATH, TestVersioningWorkflow.WORKFLOW_PATH,
TestESPHomeVersionYAML.YAML_PATH and any hardcoded paths in test methods so
tests are portable across environments. Ensure all references use the new
computed Path joins instead of literal absolute strings and update import/usage
sites in the tests to reference these attributes or the fixture.
🧹 Nitpick comments (5)
.test/unit/test_versioning.py (2)

6-14: Remove unused imports.

tempfile and shutil are imported but not used in this file.

♻️ Proposed fix
 import pytest
 import yaml
 import re
 import subprocess
-import tempfile
-import shutil
 from pathlib import Path
 from datetime import datetime

784-796: Avoid catching bare Exception.

Catching Exception is overly broad and can mask unexpected errors. In this test context, consider catching yaml.YAMLError and IOError specifically, or re-raising unexpected exceptions.

♻️ Proposed fix
     def test_esphome_yaml_syntax_valid(self):
         """Test ESPHome YAML has no syntax errors"""
         yaml_file = Path("/home/jailuser/git/esphome/nspanel_esphome_version.yaml")
-        try:
-            with open(yaml_file, 'r') as f:
-                # Note: !include and !extend are ESPHome-specific, might fail
-                content = f.read()
-                # Just verify it's parseable YAML structure
-                assert 'substitutions:' in content
-                assert 'esphome:' in content
-        except Exception as e:
-            pytest.fail(f"ESPHome YAML has issues: {e}")
+        with open(yaml_file, 'r') as f:
+            # Note: !include and !extend are ESPHome-specific, so we check structure
+            content = f.read()
+            # Just verify it's parseable YAML structure
+            assert 'substitutions:' in content, "Missing 'substitutions:' section"
+            assert 'esphome:' in content, "Missing 'esphome:' section"
.test/unit/test_versioning_advanced.py (3)

6-11: Remove unused imports.

tempfile and shutil are imported but not used in this file.

♻️ Proposed fix
 import pytest
-import tempfile
-import shutil
 from pathlib import Path
 import subprocess

247-261: Unused loop variable i.

The loop variable i from enumerate(lines) is not used. Either remove the enumeration or prefix with underscore to indicate intentional non-use.

♻️ Proposed fix
-        for i, line in enumerate(lines):
+        for line in lines:
             # Look for VERSION file check in stable or latest tag steps
             if 'if [ ! -f' in line and 'VERSION' in line:
                 found_validation = True

69-78: Test for duplicate keys is inherently limited by YAML parsing.

The test checks that keys.count('version') == 1, but yaml.safe_load already deduplicates keys (keeping the last value). This test will pass even if the source file has duplicate keys.

If you need to detect duplicate keys in the raw file, consider parsing the file content directly with regex or using a YAML loader that reports duplicates.

♻️ Alternative approach to detect actual duplicates in source
def test_version_yaml_no_duplicate_keys(self):
    """Test VERSION_YAML doesn't have duplicate version keys"""
    version_yaml = Path("/home/jailuser/git/versioning/VERSION_YAML")
    content = version_yaml.read_text()
    
    # Count 'version:' occurrences in raw content
    import re
    matches = re.findall(r'^version:', content, re.MULTILINE)
    assert len(matches) == 1, "VERSION_YAML should have exactly one 'version:' key"

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In @.github/FUNDING.yml:
- Line 2: The YAML document markers are inverted: the end marker '...' currently
appears before the document start marker '---'; fix by either removing both
markers entirely or placing them in the correct order so '---' appears before
the YAML content and '...' after it, ensuring the markers '...' and '---' are
corrected or omitted to allow proper YAML parsing.

In @.github/workflows/versioning.yml:
- Around line 114-121: The heredoc that writes tag_message.txt preserves the
leading indentation, so the generated tag message will contain unwanted leading
spaces; update the heredoc usage in the block that writes tag_message.txt (the
<< EOF ... EOF that references NEW_VERSION) to either use a dedenting heredoc
(change to <<-EOF and ensure indentation uses tabs) or remove the indentation
around the heredoc body so the lines have no leading spaces, ensuring the final
tag_message.txt contains a clean "v${NEW_VERSION} - Manual tag update" and
message lines.

edwardtfn and others added 4 commits February 5, 2026 08:32
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@edwardtfn
Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Feb 5, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In @.test/unit/test_versioning_advanced.py:
- Around line 16-17: Introduce a REPO_ROOT Path constant (same pattern as in
.test/unit/test_versioning.py) and replace hardcoded "/home/jailuser/git" usages
by deriving file paths from REPO_ROOT (e.g., set VERSION_FILE = REPO_ROOT /
"versioning" / "VERSION" and update the other file constants at the locations
flagged — the symbols to change include VERSION_FILE and the other file-path
constants around the commented lines — so all tests compute paths from REPO_ROOT
instead of using absolute paths).

In @.test/unit/test_versioning.py:
- Around line 626-635: The test test_version_format_consistency defines
VERSION_FILE and VERSION_YAML_FILE but then uses undefined version_file and
version_yaml_file, causing NameError; rename the defined constants to the
lowercase names used in the test (or update references to use
VERSION_FILE/VERSION_YAML_FILE) so the same variable is used consistently—update
either the declaration (change VERSION_FILE -> version_file and
VERSION_YAML_FILE -> version_yaml_file) or the usages in
test_version_format_consistency to reference the existing symbols.

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
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.

Bug home_value02_label_color and icon_color ignored

2 participants