Expand description
Solar API
Rust library for accessing the Solar Edge API. This library uses the API documentation found here
API Key and Site ID
To access the data of your installation, you need to get an API key. You can get this from the SolardEdge Monitoring Portal. Log in with your SolarEdge Account, go to the Admin section, Site Access tab and activate API access. Mark the checkbox and you will see the API Key and Site ID
Rate limited
Please be aware that the API is rate limited, i.e. it will block requests after reaching a maximum of requests in an hour. It will be available again after that hour. Also note that the measurements seem to be limited to one per fifteen minutes. You can consider scheduling a read of data ±15 minutes after the timestamp of last read measurement. For example you can use a duration of 15m 10s:
let next_update = last_updated_datetime + Duration::seconds(15 * 60 + 10);There is a convenience method to help with this:
let site_overview: Overview = overview(api_key, site_id);
let (next_update, duration_from_now) = site_overview.estimated_next_update();Please note that sometimes the API is a bit later. The duration_from_now can be negative then and you have to wait a bit more like in the example below. Please note that checked_add is needed here to handle adding negative duration_from_now.
let site_overview: Overview = overview(api_key, site_id);
let (next_update, duration_from_now) = site_overview.estimated_next_update();
let next = Instant::now()
.checked_add(Duration::from_secs(duration_from_now as u64))
.unwrap_or(Instant::now() + Duration::from_secs(30));
// wait next or set timeout at next_update before
// getting power or energy dataStructs
- The period defined by start_date and end_date that this site is producting energy
- Contains all values of the generated energy per time unit
- A timestamped
Energyvalue. The value may be None when there wasn’t a value at that timestamp - Generated power in Kw
- Contains all values of the generated power per time unit
- A timestamped
Powervalue. The value may be None when there wasn’t a value at that timestamp - Location of a site
- The overview of a site includes the site current power, daily energy, monthly energy, yearly energy and life time energy.
- The information about the model of the primary module of the site
- Setting showing if information about this site is public
- Amount of
Energyand optional the revenue of this energy
Enums
- Possible errors that this lib can return. The underlying errors are included, either being [
request::Error``] or [serde_json::Error`]
Functions
- Return the energy production start and end dates of the site
- Displays the site details, such as name, location, status, etc.
- Return the site energy measurements. Usage limitation: This API is limited to one year when using
time_unit=TimeUnit::Day(i.e., daily resolution) and to one month when usingtime_unit=TimeUnit::QuarterOfAnHourortime_unit=TimeUnit::Hour. This means that the period betweenperiod.end_timeandperiod.start_time` should not exceed one year or one month respectively. If the period is longer, the system will generate error - Display the site overview data.
- Return the site power measurements in 15 minutes resolution. This API is limited to one-month period. This means that the period between
end_datetimeandstart_datetimeshould not exceed one month. If the period is longer, the system will generate error .