Add Homey Energy Tab support for IQ Battery driver - #2
Open
SerrII wants to merge 1 commit into
Open
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:"energy": { "batteries": ["INTERNAL"] }with"energy": { "homeBattery": true, "meterPowerImportedCapability": ..., "meterPowerExportedCapability": ... }, sincebatteriesis meant fordevices that are themselves powered by a battery (e.g. sensors), not for
home battery storage systems.
homeBattery: trueis the capability Homeyexpects for this device type.
meter_power.chargedandmeter_power.dischargedcapabilities,wired up as
meterPowerImportedCapability/meterPowerExportedCapability.Changes in
drivers/iqbattery/device.ts:accumulateLifetimeMeter()helper that turns Enphase'sdaily-resetting "today" charge/discharge totals into a proper
ever-increasing lifetime meter, as required by Homey's
meter_powersemantics (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.
iqbattery_charge/iqbattery_dischargecapabilities(daily totals, for display) are left untouched.
measure_power(live charge/discharge wattage) is intentionally notincluded yet — the previous attempt using
latest_powerwas alreadydisabled 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 installfails locally with a 401 error, because
package-lock.jsonpins mostpackages 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 deletingpackage-lock.jsonworks around it locally, but I didn't want to touch thelock 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.