Skip to content

feat: Add hide-when-zero and fix unavailable display on value slots#107

Merged
edwardtfn merged 4 commits intomainfrom
v9999.99.9
Apr 10, 2026
Merged

feat: Add hide-when-zero and fix unavailable display on value slots#107
edwardtfn merged 4 commits intomainfrom
v9999.99.9

Conversation

@edwardtfn
Copy link
Copy Markdown
Owner

@edwardtfn edwardtfn commented Apr 10, 2026

What changed

Two improvements to value slots (*display_value) across Home page, Climate page, Water Heater page, and Entity pages:

Hide when zero (closes #104)

A new setting "Values - Hide when zero" has been added to the Advanced Settings section of the Blueprint. When enabled, any numeric entity whose state rounds to 0 will have both its value text and icon hidden from the display. The slot reappears automatically when the value returns to non-zero.

Only numeric states are affected — non-numeric states (e.g. off, idle) are never suppressed by this setting.

Fix unavailable display (closes #105)

Previously, when an entity became unavailable or unknown, the value slot continued to show the last known value. The localized "unavailable" string is now shown in the value slot instead of stale data.

Migration notes

  • No breaking changes. The new "Values - Hide when zero" input defaults to false, preserving existing behaviour.

Known limitations

  • On the Home page, value slot visibility is not yet persisted across page transitions. Hidden slots may reappear briefly on page reload until the next state update fires. Full persistence requires a future TFT and ESPHome update (tracked separately).

Summary by CodeRabbit

  • New Features

    • Option to hide value displays and their icons when numeric value is zero.
    • Visibility controls added for four additional value fields across layouts.
  • Bug Fixes / Improvements

    • Consistent handling for unavailable/unknown values and icon visibility.
    • Refined visibility update behavior so changes apply reliably when pages are visible.
  • Chores

    • UI/firmware version bumped to 17.1.
    • Updated UART synchronization behavior and sensor update interval.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 10, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 7629dcf7-ad57-4c09-a93e-ccf0917750c9

📥 Commits

Reviewing files that changed from the base of the PR and between 54d5917 and 65ca7f6.

📒 Files selected for processing (1)
  • nspanel_easy_blueprint.yaml

📝 Walkthrough

Walkthrough

Extended visibility handling and UI variables: added four vis_value globals and home bindings; blueprint adds hide-if-zero behavior for value+icon and updates version metadata; ESPHome API suppresses persistent vis_* updates for additional icon IDs; UART script renamed to wait_for_uart_drain and baud_rate_active sensor gets an update interval.

Changes

Cohort / File(s) Summary
Blueprint & Versioning
nspanel_easy_blueprint.yaml, esphome/nspanel_esphome_version.yaml
Added value_hide_when_zero input and zero/unavailable handling that hides/restores value+icon; bumped blueprint runtime version to 9999.99.9; changed min_blueprint_version${version} and min_tft_version17.1.
HMI Boot Version Updates
hmi/dev/nspanel_easy_landscape/boot.txt, hmi/dev/nspanel_landscape_code/boot.txt, hmi/dev/nspanel_portrait_code/boot.txt
Updated global version text from 17.017.1.
HMI Visibility State Declarations
hmi/dev/nspanel_landscape_code/Program.s.txt, hmi/dev/nspanel_portrait_code/Program.s.txt
Added globals: int vis_value01=0, vis_value02=0, vis_value03=0, vis_value04=0.
HMI Home Page Bindings
hmi/dev/nspanel_landscape_code/home.txt, hmi/dev/nspanel_portrait_code/home.txt
Added Preinitialize Event bindings for value01value04 and value01_iconvalue04_icon to their vis_value* variables.
ESPHome API visibility logic
esphome/nspanel_esphome_api.yaml
Extended action_component_visibility to suppress persistent vis_* updates for value01_iconvalue04_icon (in addition to existing exclusions).
UART config / script rename
esphome/nspanel_esphome_hw_uart.yaml
Renamed script id wait_for_uart_availablewait_for_uart_drain, updated script stop logic and stop_all calls, and added update_interval: 111min to baud_rate_active text sensor.

Sequence Diagram(s)

sequenceDiagram
    participant Blueprint as NSPanel Blueprint
    participant ESPHome as ESPHome API
    participant HMI as NSPanel HMI

    Note over Blueprint: Entity state update arrives
    Blueprint->>Blueprint: parse state -> to_float -> round -> value_is_zero?
    alt value available
        alt hide_if_zero && value_is_zero
            Blueprint->>ESPHome: set_visibility(value_id, false)
            Blueprint->>ESPHome: set_visibility(icon_id, false)
            ESPHome->>HMI: hide components
        else
            Blueprint->>ESPHome: set_visibility(value_id, true)
            Blueprint->>ESPHome: update_value_text(...)
            ESPHome->>HMI: show value & icon
        end
    else value unavailable
        Blueprint->>ESPHome: set_text(value_id, "_{_unavailable_}_")
        Blueprint->>ESPHome: set_visibility(value_id, true)
        Blueprint->>ESPHome: set_visibility(icon_id, true)
        ESPHome->>HMI: show placeholder and icon
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested labels

Improvement

🐰 I hopped through code and found the light,
Values quiet when the numbers bite,
Scripts renamed, versions set to new,
Icons hide when zeros come into view,
A cheerful nibble, then the panel's right ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title clearly summarizes the main changes: adding a hide-when-zero feature and fixing unavailable value display for value slots.
Linked Issues check ✅ Passed The PR addresses both linked issues: #104 (hide when zero) and #105 (show unavailable instead of zero) through blueprint changes and component visibility logic.
Out of Scope Changes check ✅ Passed All changes are in scope: version updates, visibility variable additions, and the core blueprint logic for hiding zero values and handling unavailable states.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • 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
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

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@esphome/nspanel_esphome_version.yaml`:
- Around line 17-21: The change raises the compatibility floor by updating
min_blueprint_version and min_tft_version which contradicts the "no update
required" migration; either revert the bumps so min_blueprint_version and
min_tft_version keep their prior values to remain non-breaking, or if the bump
is intentional, update the migration/PR notes to explicitly state the new
required minimums and that installations below those values will set
version_check_ok = false; locate the keys min_blueprint_version and
min_tft_version in nspanel_esphome_version.yaml and apply one of these two fixes
consistently.

In `@nspanel_easy_blueprint.yaml`:
- Around line 7460-7481: The template currently only re-shows the value slot
when hide_if_zero is true and always hides both value and icon on unavailable,
causing slots to remain hidden after recovery; update the logic so that the
recovery branch (the block that runs when a non-zero/valid value appears) always
sets the value slot (repeat.item.component) visible regardless of hide_if_zero
while only applying hide_if_zero behavior to the icon if needed, and change the
unavailable/unknown branch to hide only the icon (repeat.item.component_icon)
while leaving the value slot visibility untouched so the localized unavailable
marker can be shown. Ensure changes target the same actions calling esphome.{{
nspanel_name }}_components_visibility and the ids repeat.item.component and
repeat.item.component_icon.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: de8a0b1b-a521-41bc-8b97-35afdd675107

📥 Commits

Reviewing files that changed from the base of the PR and between c4e7959 and 744d5af.

📒 Files selected for processing (17)
  • esphome/nspanel_esphome_api.yaml
  • esphome/nspanel_esphome_hw_uart.yaml
  • esphome/nspanel_esphome_version.yaml
  • hmi/dev/nspanel_easy_landscape/boot.txt
  • hmi/dev/nspanel_landscape_code/Program.s.txt
  • hmi/dev/nspanel_landscape_code/boot.txt
  • hmi/dev/nspanel_landscape_code/home.txt
  • hmi/dev/nspanel_portrait_code/Program.s.txt
  • hmi/dev/nspanel_portrait_code/boot.txt
  • hmi/dev/nspanel_portrait_code/home.txt
  • hmi/nspanel_easy_landscape.hmi
  • hmi/nspanel_easy_landscape.tft
  • hmi/nspanel_landscape.hmi
  • hmi/nspanel_landscape.tft
  • hmi/nspanel_portrait.hmi
  • hmi/nspanel_portrait.tft
  • nspanel_easy_blueprint.yaml

@edwardtfn edwardtfn enabled auto-merge April 10, 2026 12:14
@edwardtfn edwardtfn merged commit b84f863 into main Apr 10, 2026
25 of 35 checks passed
@edwardtfn edwardtfn deleted the v9999.99.9 branch April 10, 2026 12:26
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.

Enhancement Show unavailable values not as zero - perhaps as '-' instead Enhancement hide icon and/or value when zero

1 participant