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 data
Structs§
- Data
Period - The period defined by start_date and end_date that this site is producting energy
- Generated
Energy - Contains all values of the generated energy per time unit
- Generated
Energy Value - A timestamped
Energy
value. The value may be None when there wasn’t a value at that timestamp - Generated
Power - Generated power in Kw
- Generated
Power PerTime Unit - Contains all values of the generated power per time unit
- Generated
Power Value - A timestamped
Power
value. The value may be None when there wasn’t a value at that timestamp - Location
- Location of a site
- Overview
- The overview of a site includes the site current power, daily energy, monthly energy, yearly energy and life time energy.
- Primary
Module - The information about the model of the primary module of the site
- Public
Settings - Setting showing if information about this site is public
- Site
- Time
Data - Amount of
Energy
and optional the revenue of this energy
Enums§
- Solar
ApiError - Possible errors that this lib can return. The underlying errors are included,
either being [
request::Error``] or [
serde_json::Error`] - Time
Unit
Functions§
- data_
period - Return the energy production start and end dates of the site
- details
- Displays the site details, such as name, location, status, etc.
- energy
- 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::QuarterOfAnHour
ortime_unit=
TimeUnit::Hour
. This means that the period between
period.end_timeand
period.start_time` should not exceed one year or one month respectively. If the period is longer, the system will generate error - list
- List all sites of customer. Each
Site
has an id that can be used to retrieve detailled information using for exampleenergy
- overview
- Display the site overview data.
- power
- Return the site power measurements in 15 minutes resolution. This API is
limited to one-month period. This means that the period between
end_datetime
andstart_datetime
should not exceed one month. If the period is longer, the system will generate error .