Repository navigation
Add a read-only SolarEdge Basic Monitoring V2 client - #151
stefanodecillis wants to merge 3 commits into
Conversation
Add aiosolaredge.v2 (SolarEdgeV2) and aiosolaredge.monitoring (BasicMonitoring) for the SolarEdge Basic Monitoring API 2.1.0 with caller-owned OAuth bearer tokens: - site metadata, onboard lifetime-energy counter and the latest 15-minute average power sample (null stays null; not instantaneous) - site-zone day/month/year overview ranges and directional daily energy - explicit device inventory types and per-battery daily first-to-last observed counter deltas; interior counter resets, duplicate or out-of-window samples and unknown storage membership are rejected - unit normalization to Wh/W with null, overflow and negative checks - bounded, redacted errors; HTTP 401/403/429 typed with http_status; 429 keeps allowlisted quota headers and Retry-After, no retry - optional before_request hook so callers can reserve request budget before any I/O; site IDs restricted to ASCII digits No Advanced/paid or control endpoints are called. Tests use synthetic fixtures only and run on Python 3.10+.
|
I ran this against a real site (AU, SE5000H + SE-MTR-3Y import/export meter, no battery): I captured the live V2 responses and replayed them through a147eac.
I'm happy to help with the fix directly if that's useful. I can send a PR against your branch for the inventory handling, with a test built from this site's (anonymised) |
|
Sure! |
A live site (SE5000H with an SE-MTR-3Y import/export meter) returns /devices with two calculated meters (form "virtual", meterType SelfConsumption and Consumption) whose serialNumber is null. It also lists its one physical meter twice under the same serial (meterType FeedIn and Purchased). inventory() rejected both cases, so it raised InvalidResponseError on sites like this one. Meters are now keyed by (type, serialNumber, meterType), and a null serial is accepted only for METER entries with form "virtual". Every other device still needs a non-empty, unique serial. Batteries in particular stay strict, because callers bind entities to battery serials. The published DeviceData schema types serialNumber as a string and describes form as "a physical device or a virtual (calculated) meter". The null serial is what the API actually returns for the latter. Refs: Solarlibs#151 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
I opened the inventory fix against your branch: stefanodecillis#1. Meters are keyed by role, and a null serial is allowed only for virtual meters; everything else stays strict. The test results and the offline replay of the real site are in the description. |
fix(monitoring): accept virtual and multi-role meters in inventory
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Fix merged as ce7be55. Inventory keys meters by role. Null serial only for virtual meters. Tests cover all reported shapes. |
PR Review — Add a read-only SolarEdge Basic Monitoring V2 clientSolid, carefully bounded V2 client. One error-handling gap on Python 3.10 should be fixed before merge. Strengths:
Needs attention:
🟢 Suggestions
1. Non-JSON 200 body is reported as a connection failure
|
halibsbot
left a comment
There was a problem hiding this comment.
Tip
No blocking issues found — ready to merge.
Summary
Add a read-only client for SolarEdge's Basic Monitoring API V2 alongside the existing V1 client. The existing
SolarEdgeAPI and package version are unchanged.SolarEdgeV2: site metadata, onboard lifetime-energy counters and timestamped 15-minute average power samples.BasicMonitoring: site-timezone day/month/year energy, directional daily energy, device inventory and per-battery first-to-last observed daily counter deltas.before_requesthook for reserving a shared request budget before I/O.Only Basic read endpoints are used. No paid Advanced endpoints, device controls, historical-TOTAL diagnostics or token acquisition/refresh implementation are included. Average power is not presented as an instantaneous measurement; observed storage deltas do not claim complete midnight-to-now coverage.
Validation
Related work
This client is reusable independently of the integration approach chosen by Home Assistant. Versioning and release remain with the library maintainer's existing release process.