Crates.io | solar-api |
lib.rs | solar-api |
version | 0.1.3 |
source | src |
created_at | 2023-11-09 16:41:27.399852 |
updated_at | 2023-12-04 09:26:10.358773 |
description | Rust library for accessing the SolarEdge Monitoring API |
homepage | |
repository | https://github.com/lrbalt/solar-api |
max_upload_size | |
id | 1030277 |
size | 70,376 |
Rust library for accessing the Solar Edge API. This library uses the API documentation found here
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
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
The example will call several API methods. To run it, use
cargo run --example use_api -- <API_KEY> <SITE_ID>
To see the http request and response use
RUST_LOG=solar_api=trace cargo run --example use_api -- <API_KEY> <SITE_ID>