feat: Add hide-when-zero and fix unavailable display on value slots#107
feat: Add hide-when-zero and fix unavailable display on value slots#107
Conversation
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughExtended 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 Changes
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
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested labels
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
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
📒 Files selected for processing (17)
esphome/nspanel_esphome_api.yamlesphome/nspanel_esphome_hw_uart.yamlesphome/nspanel_esphome_version.yamlhmi/dev/nspanel_easy_landscape/boot.txthmi/dev/nspanel_landscape_code/Program.s.txthmi/dev/nspanel_landscape_code/boot.txthmi/dev/nspanel_landscape_code/home.txthmi/dev/nspanel_portrait_code/Program.s.txthmi/dev/nspanel_portrait_code/boot.txthmi/dev/nspanel_portrait_code/home.txthmi/nspanel_easy_landscape.hmihmi/nspanel_easy_landscape.tfthmi/nspanel_landscape.hmihmi/nspanel_landscape.tfthmi/nspanel_portrait.hmihmi/nspanel_portrait.tftnspanel_easy_blueprint.yaml
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
0will 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
false, preserving existing behaviour.Known limitations
Summary by CodeRabbit
New Features
Bug Fixes / Improvements
Chores