2 releases
0.0.2 | Dec 18, 2022 |
---|---|
0.0.1 | Dec 18, 2022 |
#20 in #solar
5MB
599 lines
huawei inverter client
Supported Devices
- Residential Inverter
- Power Sensor
Usage
use crate::client_impl::HuaweiClientImpl;
async fn do_something() {
let cl = HuaweiClientImpl::default(env!("HUAWEI_USER"), env!("HUAWEI_PASSWORD"));
let stations = cl.get_station_list().await.unwrap();
let station = stations.first().unwrap();
let realtime_data = cl.get_realtime_station_data(station.station_code.as_str()).await.unwrap();
println!("{:?}", realtime_data);
let devices = cl.get_device_list(station.station_code.as_str()).await.unwrap();
println!("{:?}", devices);
let power_sensor: &GetDevListData = devices.iter()
.filter(|device| device.dev_type_id == DeviceType::PowerSensor)
.collect::<Vec<&GetDevListData>>()
.first()
.unwrap();
let power_sensor_data = cl.get_realtime_power_sensor_data(power_sensor.id).await.unwrap();
println!("{:?}", power_sensor_data);
let inverter: &GetDevListData = devices.iter()
.filter(|device| device.dev_type_id == DeviceType::ResidentialInverter)
.collect::<Vec<&GetDevListData>>()
.first()
.unwrap();
let inverter_data = cl.get_realtime_residential_inverter_data(inverter.id).await.unwrap();
println!("{:?}", inverter_data);
}
Tests
env Variables:
- HUAWEI_USER
- HUAWEI_PASSWORD
Dependencies
~7–20MB
~287K SLoC