Add heating
Signed-off-by: Frank Villaro-Dixon <frank@villaro-dixon.eu>
This commit is contained in:
parent
4013b2239a
commit
4486e9617c
2 changed files with 54 additions and 6 deletions
|
@ -12,4 +12,7 @@ fn main() {
|
|||
|
||||
let tp = a.get_tank_parameters().unwrap();
|
||||
println!("Tank: {:?}", tp);
|
||||
|
||||
let hp = a.get_heating_parameters().unwrap();
|
||||
println!("Heating: {:?}", hp);
|
||||
}
|
||||
|
|
57
src/lib.rs
57
src/lib.rs
|
@ -21,14 +21,31 @@ pub struct DaikinAlthermaClient {
|
|||
|
||||
#[derive(Debug)]
|
||||
pub struct TankParameters {
|
||||
// The current temperature of the water tank
|
||||
temperature: f64,
|
||||
// The setpoint (wanted) temperature of the water tank
|
||||
setpoint_temperature: f64,
|
||||
// The current temperature of the water tank, in °C
|
||||
pub temperature: f64,
|
||||
// The setpoint (wanted) temperature of the water tank, in °C
|
||||
pub setpoint_temperature: f64,
|
||||
// Is the tank heating enabled
|
||||
enabled: bool,
|
||||
pub enabled: bool,
|
||||
// Is it on powerful (quick heating) mode
|
||||
powerful: bool,
|
||||
pub powerful: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct HeatingParameters {
|
||||
// The current indoor temperature, in °C
|
||||
pub indoor_temperature: f64,
|
||||
// The current outdoor temperature, in °C
|
||||
pub outdoor_temperature: f64,
|
||||
// The current indoor setpoint (target) temperature, in °C
|
||||
pub indoor_setpoint_temperature: f64,
|
||||
// The leaving water temperature, in °C
|
||||
pub leaving_water_temperature: f64,
|
||||
|
||||
// Is the heating enabled
|
||||
pub enabled: bool,
|
||||
// Is it on powerful (quick heating) mode
|
||||
//mode: ,
|
||||
}
|
||||
|
||||
trait FromJsonValue<T>: Sized {
|
||||
|
@ -143,6 +160,34 @@ impl DaikinAlthermaClient {
|
|||
})
|
||||
}
|
||||
|
||||
pub fn get_heating_parameters(&mut self) -> Result<HeatingParameters, DAError> {
|
||||
let indoor_temperature: f64 = self
|
||||
.request_value_hp_dft("1/Sensor/IndoorTemperature/la")
|
||||
.unwrap();
|
||||
|
||||
let outdoor_temperature: f64 = self
|
||||
.request_value_hp_dft("1/Sensor/OutdoorTemperature/la")
|
||||
.unwrap();
|
||||
|
||||
let indoor_setpoint_temperature: f64 = self
|
||||
.request_value_hp_dft("1/Operation/TargetTemperature/la")
|
||||
.unwrap();
|
||||
|
||||
let leaving_water_temperature: f64 = self
|
||||
.request_value_hp_dft("1/Sensor/LeavingWaterTemperatureCurrent/la")
|
||||
.unwrap();
|
||||
|
||||
let enabled_str: String = self.request_value_hp_dft("1/Operation/Power/la").unwrap();
|
||||
|
||||
Ok(HeatingParameters {
|
||||
indoor_temperature,
|
||||
outdoor_temperature,
|
||||
indoor_setpoint_temperature,
|
||||
leaving_water_temperature,
|
||||
enabled: enabled_str == "on",
|
||||
})
|
||||
}
|
||||
|
||||
fn request_value_hp_dft<T: FromJsonValue<T>>(&mut self, item: &str) -> Result<T, DAError> {
|
||||
let hp_item = format!("MNAE/{item}");
|
||||
let json_val = self
|
||||
|
|
Loading…
Reference in a new issue