Compare commits
No commits in common. "6b6df9eaca1758bb38f9811fb03559aa24bf7cee" and "28fdd10e0aa56ddef7335bb4b4d8eff4c5cf6362" have entirely different histories.
6b6df9eaca
...
28fdd10e0a
56
src/api.rs
56
src/api.rs
@ -55,20 +55,6 @@ 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 {
|
||||||
@ -218,28 +204,6 @@ 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 {
|
||||||
@ -508,26 +472,6 @@ 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::Deserialize;
|
use serde::{de::IntoDeserializer, 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, UtcDateTime},
|
api::{ChargerOpMode, Context, OutputPhase, UtcDateTime},
|
||||||
signalr::{self, StreamError},
|
signalr::{self, StreamError},
|
||||||
stream::NegotiateError,
|
stream::NegotiateError,
|
||||||
};
|
};
|
||||||
@ -90,7 +90,6 @@ impl ObservationData {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
fn dynamic_type(&self) -> DataType {
|
fn dynamic_type(&self) -> DataType {
|
||||||
match self {
|
match self {
|
||||||
ObservationData::Boolean(_) => DataType::Boolean,
|
ObservationData::Boolean(_) => DataType::Boolean,
|
||||||
@ -99,7 +98,6 @@ 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)]
|
||||||
@ -280,8 +278,7 @@ impl Stream {
|
|||||||
loop {
|
loop {
|
||||||
let msg = self.inner.recv()?;
|
let msg = self.inner.recv()?;
|
||||||
match &msg {
|
match &msg {
|
||||||
Ping => continue,
|
Empty | Ping | InvocationResult { .. } => info!("Skipped message: {msg:?}"),
|
||||||
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