Skip to content

Add Homey Energy Tab support for IQ Battery driver - #2

Open
SerrII wants to merge 1 commit into
Drenso:mainfrom
SerrII:main
Open

Add Homey Energy Tab support for IQ Battery driver#2
SerrII wants to merge 1 commit into
Drenso:mainfrom
SerrII:main

Conversation

@SerrII

@SerrII SerrII commented Aug 14, 2026

Copy link
Copy Markdown

What this does

Adds proper Homey Energy Tab integration for the IQ Battery driver, so the
battery shows up in the Energy Tab / energy flow diagram instead of being
invisible there.

Changes in drivers/iqbattery/driver.compose.json:

  • Replaced "energy": { "batteries": ["INTERNAL"] } with
    "energy": { "homeBattery": true, "meterPowerImportedCapability": ..., "meterPowerExportedCapability": ... }, since batteries is meant for
    devices that are themselves powered by a battery (e.g. sensors), not for
    home battery storage systems. homeBattery: true is the capability Homey
    expects for this device type.
  • Added meter_power.charged and meter_power.discharged capabilities,
    wired up as meterPowerImportedCapability / meterPowerExportedCapability.

Changes in drivers/iqbattery/device.ts:

  • Added an accumulateLifetimeMeter() helper that turns Enphase's
    daily-resetting "today" charge/discharge totals into a proper
    ever-increasing lifetime meter, as required by Homey's meter_power
    semantics (must never decrease/reset). It tracks the last seen "today"
    value in the device store and adds the delta on each poll, handling the
    midnight rollover (when today's value drops back to ~0) by treating the
    full new value as the delta.
  • The existing iqbattery_charge / iqbattery_discharge capabilities
    (daily totals, for display) are left untouched.

measure_power (live charge/discharge wattage) is intentionally not
included yet — the previous attempt using latest_power was already
disabled because the values didn't match actual behaviour. Happy to help
investigate a reliable source for that in a follow-up if you can point me
at the right API field/endpoint.

Testing

Unfortunately I could not test this on an actual Homey yet: npm install
fails locally with a 401 error, because package-lock.json pins most
packages to https://npm.drenso.dev/... (what looks like an internal/
private registry), which I don't have access to as an external contributor.
Running npm install --registry=https://registry.npmjs.org/ after deleting
package-lock.json works around it locally, but I didn't want to touch the
lock file as part of this PR without checking with you first — let me know
if you'd like that as a separate PR.

Given that, please treat this as a draft that needs review/testing on a
real device before merging. Happy to adjust based on feedback.

Convert Enphase daily "today" Wh counters into non-resetting meter_power (kWh) for Homey Energy. Added accumulateLifetimeMeter helper to drivers/iqbattery/device.ts and call it for charge/discharge values (store keys: lifetimeChargeBaseline, lifetimeDischargeBaseline). Updated drivers/iqbattery/driver.compose.json to expose meter_power.charged and meter_power.discharged and configure energy: homeBattery true with meterPowerImported/ExportedCapability mappings.

Co-authored-by: Copilot <223556219+Copilot@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.

1 participant