feat(ems): EMS controller gets its own device identity and tailored dashboard#96
Conversation
… dashboard
An EMS config entry was modelled as an inverter: the device was named "GivEnergy
Inverter {serial}" (so its entities slugged givenergy_inverter_…), and the
generated dashboard emitted inverter views that render blank on an EMS — no
PV/battery/grid sensors, no inverter controls. Reported on #52.
- Device naming is now model-aware (sensor._device_kind): EMS → "GivEnergy EMS
{serial}", Gateway → "GivEnergy Gateway {serial}" (future-proofs #95); all
actual inverters unchanged. Fresh EMS installs derive givenergy_ems_ entity ids.
- generate_dashboard gains is_ems: an EMS plant gets a tailored pair — an EMS
Controls view (slot times + target SOC + Flexi switch) and a health-only
Diagnostics view — with givenergy_ems_ references. Inverter dashboards unchanged.
- Existing EMS installs realign via HA's native "Recreate entity IDs" action — we
don't auto-mutate the registry (it can't distinguish a user-customised id from a
renamed one). A self-clearing repair issue prompts recreate + dashboard
regenerate; the recorder preserves history across the rename.
- DASHBOARD_VERSION 4 → 5.
Forward step toward the typed-device model (modbus#106): _device_kind is the single
source-of-kind seam #106 will feed, and givenergy_ems_ is the stable end-state #106
keeps — so users migrate once, here.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Caution Review failedPull request was closed or merged during review No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (8)
📝 WalkthroughWalkthroughThis PR adds EMS (Energy Management System) support to the GivEnergy Home Assistant integration. The changes introduce device kind classification to differentiate between Inverter, EMS, and Gateway devices, generate EMS-specific Lovelace dashboards, detect legacy entity ID naming during setup, and guide users through migration with repair issues. The dashboard version is bumped to 5 with refactored integration health reporting and comprehensive test coverage. ChangesEMS Integration Support
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 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.
Code Review
This pull request introduces support for EMS (Energy Management System) plant controllers by giving them their own device identity and entity ID prefix (givenergy_ems_ instead of givenergy_inverter_). It adds a tailored EMS dashboard featuring scheduling controls and integration health, raises a repair issue prompting users to recreate entity IDs for existing installations, and updates corresponding tests and translations. The review feedback suggests adding a defensive None check on coordinator.data in __init__.py to prevent potential AttributeErrors if the coordinator's data has not yet been populated.
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.
|
I’ve started reviewing this PR. |
dewet22-codex
left a comment
There was a problem hiding this comment.
Approved. I reviewed the current head and do not have any actionable concerns. I ran uv run pytest -q (172 passed), uv run pytest tests/test_ems.py tests/test_dashboard.py -q (30 passed), uv lock --check, and targeted ruff on the changed files; GitHub checks are green apart from CodeRabbit still being in progress at review time.
Problem
An EMS config entry was modelled as an inverter throughout: the device was named
"GivEnergy Inverter {serial}" (so its entities slugged
givenergy_inverter_…), andgenerate_dashboardemitted the full inverter view set (Overview / Energy / Controls),which renders blank on an EMS — no PV/battery/grid sensors, no inverter controls. The
EMS's genuinely useful entities (scheduling controls) weren't in the generated dashboard
at all. Reported on #52 (confirmed against the reporter's real EMS plant snapshot).
Fix
Model-aware device naming (
sensor.py)The device is now named by kind:
"GivEnergy EMS {serial}"for EMS controllers,"GivEnergy Gateway {serial}"for gateways (future-proofs #95),"GivEnergy Inverter {serial}"for everything else (unchanged). Fresh EMS installs automatically derivegivenergy_ems_…entity ids from this name.EMS-tailored dashboard (
dashboard.py,DASHBOARD_VERSION4 → 5)generate_dashboard(…, is_ems=True)emits a two-view set instead of the inverter views:for charge / discharge / export slots 1–3.
do exist for an EMS).
The service handler passes
is_ems = coordinator.data.ems is not None. Inverterdashboards are completely unchanged.
Realignment for existing installs (§5 in the plan)
We deliberately do not auto-mutate the entity registry — the registry can't
distinguish a user-customised id from one we renamed, so auto-migration would either
clobber customisations or miss entity renames (not just device renames). Instead the
realignment path is HA's native "Recreate entity IDs" device action, which handles
both. A self-clearing repair issue (keyed on the dashboard version) prompts affected
users: run "Recreate entity IDs" on the EMS device, then regenerate the dashboard;
the recorder preserves history across the rename.
Alignment with modbus#106
_device_kind(model)is the single source-of-kind seam that modbus#106's typed-deviceenumeration will feed — when that lands, only that helper changes, not the naming,
dashboard branching, or prompt code.
givenergy_ems_is the stable end-state #106 keeps,so existing users migrate once here and never again.
Notes
unaffected.
regenerate the dashboard. Coordinating on Add EMS device support — sensor descriptors and config-entry handling #52 as part of the next batched reply.
🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Bug Fixes
Documentation