Compare commits
2 Commits
28fdd10e0a
...
6b6df9eaca
Author | SHA1 | Date | |
---|---|---|---|
6b6df9eaca | |||
4470f281fc |
56
src/api.rs
56
src/api.rs
@ -55,6 +55,20 @@ impl<'de> Deserialize<'de> for UtcDateTime {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Copy, Serialize, Deserialize)]
|
||||||
|
pub struct Current {
|
||||||
|
pub phase1: f64,
|
||||||
|
pub phase2: f64,
|
||||||
|
pub phase3: f64,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Copy, Serialize)]
|
||||||
|
pub struct SetCurrent {
|
||||||
|
pub time_to_live: Option<i32>,
|
||||||
|
#[serde(flatten)]
|
||||||
|
pub current: Current
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Deserialize, Eq, Ord, PartialEq, PartialOrd)]
|
#[derive(Clone, Debug, Deserialize, Eq, Ord, PartialEq, PartialOrd)]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
pub struct Charger {
|
pub struct Charger {
|
||||||
@ -204,6 +218,28 @@ pub struct Site {
|
|||||||
pub installer_alias: Option<String>,
|
pub installer_alias: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Deserialize)]
|
||||||
|
#[serde(rename_all = "camelCase")]
|
||||||
|
pub struct SiteDetails {
|
||||||
|
#[serde(flatten)]
|
||||||
|
pub site: Site,
|
||||||
|
pub circuits: Vec<Circuit>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Deserialize)]
|
||||||
|
#[serde(rename_all = "camelCase")]
|
||||||
|
pub struct Circuit {
|
||||||
|
pub id: i64,
|
||||||
|
pub uuid: String,
|
||||||
|
pub site_id: i64,
|
||||||
|
pub circuit_panel_id: i64,
|
||||||
|
pub panel_name: String,
|
||||||
|
pub rated_current: f64,
|
||||||
|
pub fuse: f64,
|
||||||
|
pub chargers: Vec<Charger>,
|
||||||
|
pub use_dynamic_master: bool,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Deserialize)]
|
#[derive(Clone, Debug, Deserialize)]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
pub struct LoginResponse {
|
pub struct LoginResponse {
|
||||||
@ -472,6 +508,26 @@ impl Site {
|
|||||||
pub fn lifetime_energy(&self, ctx: &mut Context) -> Result<Vec<MeterReading>, ApiError> {
|
pub fn lifetime_energy(&self, ctx: &mut Context) -> Result<Vec<MeterReading>, ApiError> {
|
||||||
ctx.get(&format!("sites/{}/energy", self.id))
|
ctx.get(&format!("sites/{}/energy", self.id))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn details(&self, ctx: &mut Context) -> Result<SiteDetails, ApiError> {
|
||||||
|
ctx.get(&format!("sites/{}", self.id))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Circuit {
|
||||||
|
|
||||||
|
fn dynamic_current_path(&self) -> String {
|
||||||
|
format!("sites/{}/circuits/{}/dynamicCurrent",
|
||||||
|
self.site_id, self.id)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn dynamic_current(&self, ctx: &mut Context) -> Result<Current, ApiError> {
|
||||||
|
ctx.get(&self.dynamic_current_path())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn set_dynamic_current(&self, ctx: &mut Context, current: SetCurrent) -> Result<(), ApiError> {
|
||||||
|
ctx.post(&self.dynamic_current_path(), ¤t)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Charger {
|
impl Charger {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use serde::{de::IntoDeserializer, Deserialize};
|
use serde::Deserialize;
|
||||||
use serde_repr::Deserialize_repr;
|
use serde_repr::Deserialize_repr;
|
||||||
use std::num::{ParseFloatError, ParseIntError};
|
use std::num::{ParseFloatError, ParseIntError};
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
@ -6,7 +6,7 @@ use tracing::info;
|
|||||||
use ureq::json;
|
use ureq::json;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
api::{ChargerOpMode, Context, OutputPhase, UtcDateTime},
|
api::{ChargerOpMode, Context, UtcDateTime},
|
||||||
signalr::{self, StreamError},
|
signalr::{self, StreamError},
|
||||||
stream::NegotiateError,
|
stream::NegotiateError,
|
||||||
};
|
};
|
||||||
@ -90,6 +90,7 @@ impl ObservationData {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
fn dynamic_type(&self) -> DataType {
|
fn dynamic_type(&self) -> DataType {
|
||||||
match self {
|
match self {
|
||||||
ObservationData::Boolean(_) => DataType::Boolean,
|
ObservationData::Boolean(_) => DataType::Boolean,
|
||||||
@ -98,6 +99,7 @@ impl ObservationData {
|
|||||||
ObservationData::String(_) => DataType::String,
|
ObservationData::String(_) => DataType::String,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
|
||||||
@ -278,7 +280,8 @@ impl Stream {
|
|||||||
loop {
|
loop {
|
||||||
let msg = self.inner.recv()?;
|
let msg = self.inner.recv()?;
|
||||||
match &msg {
|
match &msg {
|
||||||
Empty | Ping | InvocationResult { .. } => info!("Skipped message: {msg:?}"),
|
Ping => continue,
|
||||||
|
Empty | InvocationResult { .. } => info!("Skipped message: {msg:?}"),
|
||||||
Invocation { target, arguments } if target == "ProductUpdate" => {
|
Invocation { target, arguments } if target == "ProductUpdate" => {
|
||||||
if arguments.len() != 1 {
|
if arguments.len() != 1 {
|
||||||
return de(msg);
|
return de(msg);
|
||||||
|
Loading…
Reference in New Issue
Block a user