@gondalez/homebridge-solaredge-power-flow
v0.0.10
Published
Expose SolarEdge site power-flow data as Matter switches and a battery accessory.
Maintainers
Readme
@gondalez/homebridge-solaredge-power-flow
A Homebridge plugin that exposes your SolarEdge site power flow as Matter switches and a battery level fader — surfaced in the iOS 27+ Home app energy view.
What you get
Up to six Matter accessories, depending on what your SolarEdge site reports:
| Accessory | Device type | When shown |
|---|---|---|
| Grid | OnOffOutlet | GRID key present in the power flow response |
| Load | OnOffOutlet | LOAD key present |
| PV | OnOffOutlet | PV key present |
| Battery Charge | OnOffOutlet | STORAGE key present |
| Battery Discharge | OnOffOutlet | STORAGE key present |
| Battery (state of charge) | DimmableLight | STORAGE.chargeLevel present |
Plus one small HomeKit (HAP) switch — the refresh canary (default name SolarEdge Refresh) — that keeps the values fresh; see How updates work.
Each switch is on when its status is "Active" (or "Charging" / "Discharging" for the battery), off otherwise. Power flow direction is inferred from the API's connections[] array: importing from the grid is positive watts, exporting is negative; the battery's charge and discharge directions are reported on separate switches. The Battery Charge and Battery Discharge switches report a positive kW value regardless of direction.
The battery accessory is exposed to the iOS Home app as a DimmableLight: the fader position mirrors STORAGE.chargeLevel (0% = bottom, 100% = top). User changes to the fader are ignored — the next poll reverts the slider to the actual state of charge.
Requirements
- Homebridge v2.2.0 or later (the plugin uses the Matter
electricalPowerMeasurement/electricalEnergyMeasurementcluster support added in homebridge/homebridge@c2d9d7d) - Node 22+
- A SolarEdge API key (admin account → my.solaredge.com → Admin → API Access)
- A Matter-enabled bridge — either the main bridge or a dedicated child bridge
Installation
Once published:
npm install -g @gondalez/homebridge-solaredge-power-flowThen add a platform block to your Homebridge config.json:
{
"platforms": [
{
"name": "SolarEdge",
"apiKey": "YOUR_API_KEY",
"siteId": 12345,
"platform": "SolarEdgePowerFlow",
"_bridge": {
"name": "SolarEdge Power Flow",
"matter": { "enabled": true }
}
}
]
}Restart Homebridge. The plugin fires a single SolarEdge API request during startup to register the switch and battery accessories that match your site; after that, fetches are triggered by the refresh canary (see below).
Pairing: Matter and HomeKit
The Matter accessories appear once the bridge is commissioned via Matter. For values to keep updating after startup, also pair the same bridge with Apple Home over HomeKit (HAP): Home app → Add Accessory → choose the bridge → enter the HAP setup code shown in Homebridge. This is a separate pairing from the Matter commissioning and is what makes the refresh canary visible to the Home app.
How updates work
Homebridge's Matter API documents a per-accessory getState read hook, but no released Homebridge version (2.2.x) actually calls it — so reads of the Matter accessories alone can never trigger a fetch. The plugin works around this with a refresh canary: a small HAP switch that the iOS Home app does read.
- The plugin fetches once at startup so accessories register and show initial values.
- Every time the Home app reads the canary — opening the app, or viewing the room the canary tile is in — a fetch is triggered, and fresh values are pushed to the Matter accessories a moment later.
- Tap the canary switch to force a refresh. It flips itself back off after a second.
- Repeated reads are throttled by
onDemandCacheSeconds(default 30 s), so rapid re-opens cost at most one API call per window.
Keep the canary tile somewhere the Home app renders often (e.g. the same room as the energy tiles, or your default room). If it's buried in a room you never open, refreshes only happen when you open the app — iOS reads visible accessories. Set refreshCanary: false to disable the canary entirely; the plugin then only fetches once at startup.
Configuration
| Field | Type | Default | Description |
|---|---|---|---|
| name | string | "SolarEdge" | Platform name shown in Homebridge |
| apiKey | string | — | SolarEdge API key (required) |
| siteId | integer | — | SolarEdge site ID (required) |
| onDemandCacheSeconds | integer | 30 | How long to reuse a fetched response before refetching. Throttles canary-triggered fetches. 0 = refetch on every read. Range 0–3600. |
| refreshCanary | boolean | true | Register the HAP refresh-canary switch. false = only fetch once at startup. |
| accessoryNames.grid | string | "Grid" | Custom display name |
| accessoryNames.load | string | "Load" | |
| accessoryNames.pv | string | "PV" | |
| accessoryNames.batteryCharge | string | "Battery Charge" | |
| accessoryNames.batteryDischarge | string | "Battery Discharge" | |
| accessoryNames.battery | string | "Battery" | |
| accessoryNames.refreshCanary | string | "SolarEdge Refresh" | |
| _bridge.matter.enabled | boolean | true | Required for the plugin to work |
Migration note:
refreshIntervalSecondsfrom earlier versions is no longer used. The plugin no longer polls; it fetches on demand. A stalerefreshIntervalSecondsvalue in yourconfig.jsonis ignored with a one-time info log.
Behaviour notes
- On-demand reads — the plugin does not poll the SolarEdge API. It fires one SolarEdge request during startup so the switches and battery accessory are registered and visible under the bridge shortly after Homebridge boots, then only fetches again when the iOS Home app reads the refresh canary (see How updates work). Concurrent triggers are deduplicated into a single SolarEdge call, and the result is cached for
onDemandCacheSeconds(default 30 s) so repeated reads within that window cost no API call. If the startup request fails, the accessories still register on the first canary-triggered fetch. - API rate limit — the SolarEdge API limit is 300 requests per API key per day. Fetches only happen when the Home app reads the canary (app opens / room views / taps), throttled by
onDemandCacheSeconds. With typical use — a handful of app opens an hour — that's a few dozen requests a day at most. Keep the cache at or above the default unless you have a higher-tier API key. - Authentication failures (401 / 403) — polling stops, the plugin logs an error, and you'll need to fix the API key and restart Homebridge.
- Rate limiting (429) — the plugin honours the
Retry-Afterheader and immediately fails the request (no retry storm against a rate-limited endpoint). - Transient 5xx — three retries with 1 s / 3 s / 9 s backoff before giving up for that cycle.
- Missing metric in API response — the accessory is unregistered after two consecutive polls where its key is absent, so a brief inverter blip doesn't take down an accessory.
- Storage direction switches — Battery Charge and Battery Discharge switches are always registered as soon as
STORAGEis present in the response. Only the active direction ison; the other isoff, and the live kW is shown as a positive value on whichever switch is on. Live power is read fromelectricalPowerMeasurement.activePower(mW); no lifetime energy is tracked. - Power units —
currentPowervalues are normalised to watts using the top-levelunitfield in the SolarEdge response (W/kW/MW). Unknown units log a one-time warning and are treated as watts. - API request/response logging — every HTTP attempt to the SolarEdge API logs a line at
infolevel before the fetch (verb + URL) and another after the response (verb + URL + status + full body). The SolarEdge API key is included in the URL.
Development
npm install
npm test # runs all tests (vitest)
npm run lint # eslint
npm run watch # not used; the plugin has no build stepThe project is pure untyped ESM JavaScript — no TypeScript, no JSDoc, no // @ts-check. Tests use vitest and MSW for the HTTP client layer.
License
Apache 2.0
