mysolenso.services.reports.powerbystation - Daily power aggregation service
MySolenso per-station daily power aggregation service.
Provides the MySolensoPowerByStation class, which queries the
/report_select_power_by_station Solenso endpoint and exposes the aggregated power
data for a single station over a given date range.
Unlike powerbyday, which uses the Hoymiles API
and returns an intra-day power curve (HH:MM samples), this service
uses the Solenso API and returns a single aggregated record per station
per day - useful for day-level energy dashboards.
By default the service loads data for today (or yesterday if the local
hour is before 01:00, to avoid an empty dataset at midnight). Use
set_day() to query any historical date.
This module is intended to be instantiated by MySolenso
and accessed via client.powerbaystation.
Example
client = MySolenso(username="user", token="tok")
data = client.powerbaystation.all_data
print(data)
# Query a specific date
client.powerbaystation.set_day("2026-01-01")
data = client.powerbaystation.all_data
# Refresh without changing station or date
client.powerbaystation.get_power_station_refresh()
- class mysolenso.services.reports.powerbystation.MySolensoPowerByStation(parent)[source]
Bases:
objectDaily aggregated power record for a single PV station.
Queries the
/report_select_power_by_stationSolenso endpoint with a station ID and a date range (start = end = target date) and caches the first element of the response list asall_data.- Parameters:
parent – Instance of
MySolensoproviding access to theauthandstationsub-modules.- Raises:
MySolensoException – If
parent.station.station_idisNone(no active station resolved), or if the API call fails during instantiation.
- parent
Reference to the parent
MySolensoobject.
Note
Unlike
MySolensoPowerByDay, this class does not automatically fetch data at construction - callget_power_station_refresh()orset_day()to trigger the first request.Example
client = MySolenso(username="admin", token="tok") pb = client.powerbaystation pb.get_power_station_refresh() print(pb.all_data) pb.set_day("2026-05-22") print(pb.all_data)
- set_station(id, refresh=True)[source]
Switch the active station and optionally reload power data.
The provided
idis validated against the station list fromstations.- Parameters:
- Raises:
MySolensoException – If
idis not found in the account’s station list, or if the subsequent API call fails.- Return type:
Example
client.powerbaystation.set_station(43) print(client.powerbaystation.all_data)
- set_day(day, refresh=True)[source]
Set the queried date and optionally reload power data.
- Parameters:
- Raises:
MySolensoException – If
dayis not inYYYY-MM-DDformat, is outside the allowed range, or if the API call fails.- Return type:
Example
client.powerbaystation.set_day("2026-05-22") print(client.powerbaystation.all_data)
- get_power_station_refresh()[source]
Re-fetch power data for the current station and date.
Triggers a new call to
_get_power_by_station()without changing the active station ID or the queried date. Useful for polling the latest values during the day.Example
# Poll every 5 minutes import time while True: client.powerbaystation.get_power_station_refresh() print(client.powerbaystation.all_data) time.sleep(300)
- Return type:
- property all_data: dict
Full raw record returned by the
/report_select_power_by_stationendpoint.Contains the aggregated power fields for the active station on the queried date (fields depend on the API version; typically include production totals, peak power, and timestamps).
- Data Example:
{ “sid”: 9876543, “name”: “DOE JOHN”, “tz_name”: “UTC+01”, “is_reflux”: 0, “is_balance”: 0, “meter_location”: 0, “classify”: 1, “dw”: null, “data_list”: [
- {
“date”: “06:15”, “pv_power”: “26”, “consumption_power”: “0”, “meter_c_power”: “0”, “grid_p_power”: “0”, “bms_power”: “0”, “meter_location”: 0
- {
“date”: “22:00”, “pv_power”: “0”, “consumption_power”: “0”, “meter_c_power”: “0”, “grid_p_power”: “0”, “bms_power”: “0”, “meter_location”: 0
}, {
“date”: “22:15”, “pv_power”: “0”, “consumption_power”: “0”, “meter_c_power”: “0”, “grid_p_power”: “0”, “bms_power”: “0”, “meter_location”: 0
}
]
}
- Returns:
First element of the API response list for the active station and date.
- Return type:
- Raises:
AttributeError – If
get_power_station_refresh()orset_day()has not been called yet (_all_datanot initialised).
Example
client.powerbaystation.get_power_station_refresh() data = client.powerbaystation.all_data print(data)
- property extract_power_data: list[dict]
Extracts only: - date - power (from pv_power)
Expected output example: [
{“date”: “06:15”, “power”: 26}, {“date”: “06:30”, “power”: 56},
]
- Returns:
A simplified list containing only date and power values.
- Return type:
- Raises:
ValueError – If data_list is missing or empty.