feat: dashboard PR A — Smart Load, AC-Coupled, mode controls, battery totals#121
Conversation
… totals Closes high-priority gaps between exposed entities and the generated dashboard: - Smart Load slots 1–10 on Controls (`has_smart_load` kwarg; defaults open until givenergy-modbus exposes a capability we can gate on per #181 / 2.1.3 — wired through with a TODO). - AC-Coupled card on Controls (export priority, EPS, AC charge/discharge limits) gated by `has_ac_config_block` from PlantCapabilities. - Mode card additions: Real Time Control, Inverter Max Output Power. - Energy → All-Time Totals: Battery Charged / Battery Discharged. - Bumps DASHBOARD_VERSION to 8 so the Repairs prompt fires on existing installs. Refs #52, #76, #83, #89, #90, #106.
|
Warning Review limit reached
More reviews will be available in 42 minutes and 7 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the 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 include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThis PR extends the Lovelace dashboard generator to conditionally render AC-Coupled and Smart Load control cards based on inverter capabilities. The service handler now derives ChangesDashboard Capability-Driven Conditional Controls
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
🚥 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 |
|
|
Overall Grade |
Security Reliability Complexity Hygiene |
Code Review Summary
| Analyzer | Status | Updated (UTC) | Details |
|---|---|---|---|
| Python | Jun 4, 2026 6:12a.m. | Review ↗ |
Important
AI Review is run only on demand for your team. We're only showing results of static analysis review right now. To trigger AI Review, comment @deepsourcebot review on this thread.
There was a problem hiding this comment.
Code Review
This pull request updates the dashboard generation to conditionally include AC-coupled controls and Smart Load slot scheduling based on device capabilities, while also adding new entities like battery charge/discharge totals and real-time control switches. The review feedback suggests dynamically joining the optional cards to ensure clean and consistent spacing in the generated YAML when cards are disabled.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| ac_coupled_card = _ac_coupled_card(inv) if has_ac_config_block else "" | ||
| smart_load_card = _smart_load_card(inv) if has_smart_load else "" |
There was a problem hiding this comment.
To prevent inconsistent spacing and empty lines in the generated YAML when some cards are disabled (or when both are disabled), we can dynamically collect the active cards in a list, strip any leading/trailing newlines, and join them with double newlines. This ensures that there is always exactly one empty line separating the cards.
cards = []
if has_ac_config_block:
cards.append(_ac_coupled_card(inv).strip("\n"))
if has_smart_load:
cards.append(_smart_load_card(inv).strip("\n"))
extra_cards = "\n" + "\n\n".join(cards) + "\n" if cards else "\n"| - entity: time.givenergy_inverter_{inv}_discharge_slot_2_end | ||
| name: Slot 2 End | ||
|
|
||
| {ac_coupled_card}{smart_load_card} |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@custom_components/givenergy_local/__init__.py`:
- Around line 568-570: The AC-coupled dashboard flag is computed from
coordinator.data.capabilities as has_ac_config_block without excluding
three-phase systems, but the AC-coupled entities in switch.py are only created
when not caps.is_three_phase, causing UI cards with missing entities; change the
computation in __init__.py (where caps = coordinator.data.capabilities and
has_ac_config_block is set) to include the three-phase exclusion (i.e., set
has_ac_config_block only when caps exists, caps.has_ac_config_block is true, and
caps.is_three_phase is false) so the dashboard gating aligns with the entity
registration logic in switch.py.
In `@custom_components/givenergy_local/dashboard.py`:
- Around line 101-109: Docstrings for the dashboard options (e.g., the
has_ac_config_block and has_smart_load entries) contain Unicode EN DASH
characters (“–”) which trigger RUF002; replace those EN DASH characters with
plain ASCII hyphens/minus ("-") in the docstrings around the referenced blocks
and the other occurrence (~lines 663-684) so all ranges use '-' instead of '–',
then run the project formatting/lint fix commands (uv run ruff check --fix && uv
run ruff format) to ensure the warning is resolved and formatting is consistent.
🪄 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 Plus
Run ID: fbe05bcf-2757-47a4-a0fb-6fa71d8d882e
📒 Files selected for processing (4)
custom_components/givenergy_local/__init__.pycustom_components/givenergy_local/dashboard.pydashboard/template.yamltests/test_dashboard.py
Exclude three-phase systems from the AC-coupled card — switch.py and number.py both gate AC-coupled entities on `not caps.is_three_phase`, so the dashboard flag must match. Also replace EN DASH characters in docstrings with plain ASCII hyphens (ruff RUF002). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
|
Overall Grade |
Security Reliability Complexity Hygiene |
Code Review Summary
| Analyzer | Status | Updated (UTC) | Details |
|---|---|---|---|
| Python | Jun 4, 2026 6:30a.m. | Review ↗ |
Important
AI Review is run only on demand for your team. We're only showing results of static analysis review right now. To trigger AI Review, comment @deepsourcebot review on this thread.
|
CodeRabbit's two findings addressed in b273e0a:
Gemini's spacing suggestion: the generated YAML already produces exactly one blank line between cards in all combinations (both absent, one present, both present) — verified by inspecting the output. No change needed there. |
Summary
Closes the highest-priority gaps between entities the integration exposes and what the generated dashboard surfaces:
generate_dashboard(has_smart_load=…); defaults to True for inverter installs untilgivenergy-modbusexposes a capability we can gate on (modbus #181, targeted at 2.1.3). The Repairs prompt has shown for some users that the Smart Load section was sitting unused — it now has a home. Until the capability lands, plants without Smart Load hardware will see the rows render as 'unavailable'; the gating story tightens up once the modbus side ships.capabilities.has_ac_config_blockfromPlantCapabilities— present on AC-coupled / All-in-One, absent on hybrids.e_battery_charge_total/e_battery_discharge_totalsensors (gated server-side byskip_if_none).DASHBOARD_VERSION→ 8 so the existing Repairs issue prompts users on existing installs to regenerate.dashboard/template.yamlfor manual-setup users, with inline comments noting that the AC-Coupled and Smart Load cards should be removed by users whose hardware doesn't carry the corresponding capability.Refs #52, #76, #83, #89, #90, #106.
Test plan
uv run pytest): 235 passed (was 228 + 7 new).🤖 Generated with Claude Code
Summary by CodeRabbit