Skip to main content

sma_sunny_boy/
lib.rs

1//! Async client for SMA Sunny Boy inverters exposing the WebConnect JSON API.
2//!
3//! The client talks directly to the inverter over the local network.
4//! [`SmaClient::new`] reads public dashboard values without login. Configure
5//! credentials and call [`SmaClient::authenticate`] only for protected endpoints.
6
7mod client;
8mod error;
9mod metric;
10
11pub use chrono::NaiveDate;
12pub use chrono_tz::Tz;
13pub use client::{DailyYield, RawReading, SmaClient, SmaClientBuilder, Snapshot};
14pub use error::{Error, Result};
15pub use metric::{Metric, metrics};
16
17/// SMA WebConnect login role.
18#[derive(Clone, Copy, Debug, Eq, PartialEq)]
19pub enum Role {
20    User,
21    Installer,
22}
23
24impl Role {
25    pub(crate) const fn as_api_value(self) -> &'static str {
26        match self {
27            Self::User => "usr",
28            Self::Installer => "istl",
29        }
30    }
31}