feat: add site-data API endpoints (PR 1)#126
Conversation
Adds the SolarEdge Monitoring API "Site Data" endpoints that were not
yet wrapped by the client:
- get_sites -> /sites/list
- get_data_period -> /site/{id}/dataPeriod
- get_data_period_bulk -> /sites/{ids}/dataPeriod
- get_energy -> /site/{id}/energy
- get_energy_bulk -> /sites/{ids}/energy
- get_time_frame_energy[_bulk] -> /site|sites/.../timeFrameEnergy
- get_power -> /site/{id}/power
- get_power_bulk -> /sites/{ids}/power
- get_overview_bulk -> /sites/{ids}/overview
- get_power_details -> /site/{id}/powerDetails
- get_environmental_benefits -> /site/{id}/envBenefits
Introduces shared infrastructure reused by later endpoint PRs: the
Meter/TimeUnit/SystemUnits/SortOrder Literal aliases, the
_format_date/_format_datetime/_join_ids helpers (so methods accept
date, datetime or pre-formatted str), and the _get_sites_url builder
for bulk calls.
One PR in a series splitting the full endpoint coverage work into
reviewable pieces.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
@bluetoothbot review |
|
❌ Permission denied. Only users with write access can trigger bot commands. |
|
@bdraco I also have this open since a while now. As you said there is much on your plate. No worries. My intend was to just draw your attention to this that it doesn't fall through the cracks either. |
PR Review — feat: add site-data API endpoints (PR 1)Solid, well-structured endpoint additions blocked by a test-framework mismatch with current main. The source code is clean and merges cleanly: the shared
🔴 Blocking
1. New tests use aioresponses, which main has removed
|
bluetoothbot
left a comment
There was a problem hiding this comment.
Blocking issues found.
- New tests use aioresponses, which main has removed
- Query-param regexes assume alphabetical param ordering
There was a problem hiding this comment.
Pull request overview
Adds SolarEdge Monitoring API “Site Data” endpoints to the async client, plus shared helpers/types to support date/datetime coercion and bulk-site URL construction.
Changes:
- Implemented new Site Data API methods (single-site and bulk variants) on
SolarEdge. - Added shared helpers (
_format_date,_format_datetime,_join_ids,_get_sites_url) and Literal aliases for common parameter domains. - Extended test coverage with new async tests for the added endpoints.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 9 comments.
| File | Description |
|---|---|
src/aiosolaredge/solaredge.py |
Adds site-data endpoint wrappers plus shared helper/type infrastructure for query formatting and bulk URL building. |
tests/test_init.py |
Adds tests covering the new endpoints and their URL/query construction. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| pattern = re.compile( | ||
| r"^https://monitoringapi\.solaredge\.com/sites/list\?.*" | ||
| r"searchText=Lyon.*size=5.*sortOrder=DESC.*sortProperty=Name.*" | ||
| r"startIndex=10.*status=Active" | ||
| ) |
| pattern = re.compile( | ||
| r"^https://monitoringapi\.solaredge\.com/site/123/energy\?.*" | ||
| r"endDate=2013-05-30.*startDate=2013-05-01.*timeUnit=DAY" | ||
| ) |
| pattern = re.compile( | ||
| r"^https://monitoringapi\.solaredge\.com/site/123/energy\?.*" | ||
| r"endDate=2013-05-30.*startDate=2013-05-01.*timeUnit=HOUR" | ||
| ) |
| pattern = re.compile( | ||
| r"^https://monitoringapi\.solaredge\.com/sites/1,4/energy\?.*" | ||
| r"endDate=2013-05-30.*startDate=2013-05-01" | ||
| ) |
| pattern = re.compile( | ||
| r"^https://monitoringapi\.solaredge\.com/site/123/timeFrameEnergy\?.*" | ||
| r"endDate=2013-05-06.*startDate=2013-05-01" | ||
| ) |
| pattern = re.compile( | ||
| r"^https://monitoringapi\.solaredge\.com/sites/1,4/timeFrameEnergy\?.*" | ||
| r"endDate=2013-05-06.*startDate=2013-05-01" | ||
| ) |
| pattern = re.compile( | ||
| r"^https://monitoringapi\.solaredge\.com/site/123/power\?.*" | ||
| r"endTime=2013-06-04.*startTime=2013-06-04" | ||
| ) |
| Meter = Literal["PRODUCTION", "CONSUMPTION", "SELFCONSUMPTION", "FEEDIN", "PURCHASED"] | ||
| TimeUnit = Literal["QUARTER_OF_AN_HOUR", "HOUR", "DAY", "WEEK", "MONTH", "YEAR"] | ||
| SystemUnits = Literal["Metrics", "Imperial"] | ||
| SortOrder = Literal["ASC", "DESC"] |
| def _join_ids(site_ids: Iterable[int | str]) -> str: | ||
| """Join site IDs with a comma for bulk API calls.""" | ||
| return ",".join(str(site_id) for site_id in site_ids) |
Adds the SolarEdge Monitoring API "Site Data" endpoints that were not yet wrapped by the client:
Introduces shared infrastructure reused by later endpoint PRs: the Meter/TimeUnit/SystemUnits/SortOrder Literal aliases, the _format_date/_format_datetime/_join_ids helpers (so methods accept date, datetime or pre-formatted str), and the _get_sites_url builder for bulk calls.
One PR in a series splitting the full endpoint coverage work into reviewable pieces.