#![allow(clippy::too_many_arguments)]
use crate::tlv;
use anyhow;
use serde_json;
#[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
#[repr(u8)]
pub enum ControlMode {
Constantspeed = 0,
Constantpressure = 1,
Proportionalpressure = 2,
Constantflow = 3,
Constanttemperature = 5,
Automatic = 7,
}
impl ControlMode {
pub fn from_u8(value: u8) -> Option<Self> {
match value {
0 => Some(ControlMode::Constantspeed),
1 => Some(ControlMode::Constantpressure),
2 => Some(ControlMode::Proportionalpressure),
3 => Some(ControlMode::Constantflow),
5 => Some(ControlMode::Constanttemperature),
7 => Some(ControlMode::Automatic),
_ => None,
}
}
pub fn to_u8(self) -> u8 {
self as u8
}
}
impl From<ControlMode> for u8 {
fn from(val: ControlMode) -> Self {
val as u8
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
#[repr(u8)]
pub enum OperationMode {
Normal = 0,
Minimum = 1,
Maximum = 2,
Local = 3,
}
impl OperationMode {
pub fn from_u8(value: u8) -> Option<Self> {
match value {
0 => Some(OperationMode::Normal),
1 => Some(OperationMode::Minimum),
2 => Some(OperationMode::Maximum),
3 => Some(OperationMode::Local),
_ => None,
}
}
pub fn to_u8(self) -> u8 {
self as u8
}
}
impl From<OperationMode> for u8 {
fn from(val: OperationMode) -> Self {
val as u8
}
}
pub type PumpStatus = u16;
pub mod pumpstatus {
pub const DEVICE_FAULT: u16 = 0x01;
pub const SUPPLY_FAULT: u16 = 0x02;
pub const SPEED_LOW: u16 = 0x04;
pub const SPEED_HIGH: u16 = 0x08;
pub const LOCAL_OVERRIDE: u16 = 0x10;
pub const RUNNING: u16 = 0x20;
pub const REMOTE_PRESSURE: u16 = 0x40;
pub const REMOTE_FLOW: u16 = 0x80;
pub const REMOTE_TEMPERATURE: u16 = 0x100;
}
pub fn decode_max_pressure(inp: &tlv::TlvItemValue) -> anyhow::Result<Option<i16>> {
if let tlv::TlvItemValue::Int(v) = inp {
Ok(Some(*v as i16))
} else {
Ok(None)
}
}
pub fn decode_max_speed(inp: &tlv::TlvItemValue) -> anyhow::Result<Option<u16>> {
if let tlv::TlvItemValue::Int(v) = inp {
Ok(Some(*v as u16))
} else {
Ok(None)
}
}
pub fn decode_max_flow(inp: &tlv::TlvItemValue) -> anyhow::Result<Option<u16>> {
if let tlv::TlvItemValue::Int(v) = inp {
Ok(Some(*v as u16))
} else {
Ok(None)
}
}
pub fn decode_min_const_pressure(inp: &tlv::TlvItemValue) -> anyhow::Result<Option<i16>> {
if let tlv::TlvItemValue::Int(v) = inp {
Ok(Some(*v as i16))
} else {
Ok(None)
}
}
pub fn decode_max_const_pressure(inp: &tlv::TlvItemValue) -> anyhow::Result<Option<i16>> {
if let tlv::TlvItemValue::Int(v) = inp {
Ok(Some(*v as i16))
} else {
Ok(None)
}
}
pub fn decode_min_comp_pressure(inp: &tlv::TlvItemValue) -> anyhow::Result<Option<i16>> {
if let tlv::TlvItemValue::Int(v) = inp {
Ok(Some(*v as i16))
} else {
Ok(None)
}
}
pub fn decode_max_comp_pressure(inp: &tlv::TlvItemValue) -> anyhow::Result<Option<i16>> {
if let tlv::TlvItemValue::Int(v) = inp {
Ok(Some(*v as i16))
} else {
Ok(None)
}
}
pub fn decode_min_const_speed(inp: &tlv::TlvItemValue) -> anyhow::Result<Option<u16>> {
if let tlv::TlvItemValue::Int(v) = inp {
Ok(Some(*v as u16))
} else {
Ok(None)
}
}
pub fn decode_max_const_speed(inp: &tlv::TlvItemValue) -> anyhow::Result<Option<u16>> {
if let tlv::TlvItemValue::Int(v) = inp {
Ok(Some(*v as u16))
} else {
Ok(None)
}
}
pub fn decode_min_const_flow(inp: &tlv::TlvItemValue) -> anyhow::Result<Option<u16>> {
if let tlv::TlvItemValue::Int(v) = inp {
Ok(Some(*v as u16))
} else {
Ok(None)
}
}
pub fn decode_max_const_flow(inp: &tlv::TlvItemValue) -> anyhow::Result<Option<u16>> {
if let tlv::TlvItemValue::Int(v) = inp {
Ok(Some(*v as u16))
} else {
Ok(None)
}
}
pub fn decode_min_const_temp(inp: &tlv::TlvItemValue) -> anyhow::Result<Option<i16>> {
if let tlv::TlvItemValue::Int(v) = inp {
Ok(Some(*v as i16))
} else {
Ok(None)
}
}
pub fn decode_max_const_temp(inp: &tlv::TlvItemValue) -> anyhow::Result<Option<i16>> {
if let tlv::TlvItemValue::Int(v) = inp {
Ok(Some(*v as i16))
} else {
Ok(None)
}
}
pub fn decode_pump_status(inp: &tlv::TlvItemValue) -> anyhow::Result<PumpStatus> {
if let tlv::TlvItemValue::Int(v) = inp {
Ok(*v as u16)
} else {
Err(anyhow::anyhow!("Expected Integer"))
}
}
pub fn decode_effective_operation_mode(inp: &tlv::TlvItemValue) -> anyhow::Result<OperationMode> {
if let tlv::TlvItemValue::Int(v) = inp {
OperationMode::from_u8(*v as u8).ok_or_else(|| anyhow::anyhow!("Invalid enum value"))
} else {
Err(anyhow::anyhow!("Expected Integer"))
}
}
pub fn decode_effective_control_mode(inp: &tlv::TlvItemValue) -> anyhow::Result<ControlMode> {
if let tlv::TlvItemValue::Int(v) = inp {
ControlMode::from_u8(*v as u8).ok_or_else(|| anyhow::anyhow!("Invalid enum value"))
} else {
Err(anyhow::anyhow!("Expected Integer"))
}
}
pub fn decode_capacity(inp: &tlv::TlvItemValue) -> anyhow::Result<Option<i16>> {
if let tlv::TlvItemValue::Int(v) = inp {
Ok(Some(*v as i16))
} else {
Ok(None)
}
}
pub fn decode_speed(inp: &tlv::TlvItemValue) -> anyhow::Result<Option<u16>> {
if let tlv::TlvItemValue::Int(v) = inp {
Ok(Some(*v as u16))
} else {
Ok(None)
}
}
pub fn decode_lifetime_running_hours(inp: &tlv::TlvItemValue) -> anyhow::Result<Option<u8>> {
if let tlv::TlvItemValue::Int(v) = inp {
Ok(Some(*v as u8))
} else {
Ok(None)
}
}
pub fn decode_power(inp: &tlv::TlvItemValue) -> anyhow::Result<Option<u8>> {
if let tlv::TlvItemValue::Int(v) = inp {
Ok(Some(*v as u8))
} else {
Ok(None)
}
}
pub fn decode_lifetime_energy_consumed(inp: &tlv::TlvItemValue) -> anyhow::Result<Option<u32>> {
if let tlv::TlvItemValue::Int(v) = inp {
Ok(Some(*v as u32))
} else {
Ok(None)
}
}
pub fn decode_operation_mode(inp: &tlv::TlvItemValue) -> anyhow::Result<OperationMode> {
if let tlv::TlvItemValue::Int(v) = inp {
OperationMode::from_u8(*v as u8).ok_or_else(|| anyhow::anyhow!("Invalid enum value"))
} else {
Err(anyhow::anyhow!("Expected Integer"))
}
}
pub fn decode_control_mode(inp: &tlv::TlvItemValue) -> anyhow::Result<ControlMode> {
if let tlv::TlvItemValue::Int(v) = inp {
ControlMode::from_u8(*v as u8).ok_or_else(|| anyhow::anyhow!("Invalid enum value"))
} else {
Err(anyhow::anyhow!("Expected Integer"))
}
}
pub fn decode_alarm_mask(inp: &tlv::TlvItemValue) -> anyhow::Result<u8> {
if let tlv::TlvItemValue::Int(v) = inp {
Ok(*v as u8)
} else {
Err(anyhow::anyhow!("Expected UInt8"))
}
}
pub fn decode_attribute_json(cluster_id: u32, attribute_id: u32, tlv_value: &crate::tlv::TlvItemValue) -> String {
if cluster_id != 0x0200 {
return format!("{{\"error\": \"Invalid cluster ID. Expected 0x0200, got {}\"}}", cluster_id);
}
match attribute_id {
0x0000 => {
match decode_max_pressure(tlv_value) {
Ok(value) => serde_json::to_string(&value).unwrap_or_else(|_| "null".to_string()),
Err(e) => format!("{{\"error\": \"{}\"}}", e),
}
}
0x0001 => {
match decode_max_speed(tlv_value) {
Ok(value) => serde_json::to_string(&value).unwrap_or_else(|_| "null".to_string()),
Err(e) => format!("{{\"error\": \"{}\"}}", e),
}
}
0x0002 => {
match decode_max_flow(tlv_value) {
Ok(value) => serde_json::to_string(&value).unwrap_or_else(|_| "null".to_string()),
Err(e) => format!("{{\"error\": \"{}\"}}", e),
}
}
0x0003 => {
match decode_min_const_pressure(tlv_value) {
Ok(value) => serde_json::to_string(&value).unwrap_or_else(|_| "null".to_string()),
Err(e) => format!("{{\"error\": \"{}\"}}", e),
}
}
0x0004 => {
match decode_max_const_pressure(tlv_value) {
Ok(value) => serde_json::to_string(&value).unwrap_or_else(|_| "null".to_string()),
Err(e) => format!("{{\"error\": \"{}\"}}", e),
}
}
0x0005 => {
match decode_min_comp_pressure(tlv_value) {
Ok(value) => serde_json::to_string(&value).unwrap_or_else(|_| "null".to_string()),
Err(e) => format!("{{\"error\": \"{}\"}}", e),
}
}
0x0006 => {
match decode_max_comp_pressure(tlv_value) {
Ok(value) => serde_json::to_string(&value).unwrap_or_else(|_| "null".to_string()),
Err(e) => format!("{{\"error\": \"{}\"}}", e),
}
}
0x0007 => {
match decode_min_const_speed(tlv_value) {
Ok(value) => serde_json::to_string(&value).unwrap_or_else(|_| "null".to_string()),
Err(e) => format!("{{\"error\": \"{}\"}}", e),
}
}
0x0008 => {
match decode_max_const_speed(tlv_value) {
Ok(value) => serde_json::to_string(&value).unwrap_or_else(|_| "null".to_string()),
Err(e) => format!("{{\"error\": \"{}\"}}", e),
}
}
0x0009 => {
match decode_min_const_flow(tlv_value) {
Ok(value) => serde_json::to_string(&value).unwrap_or_else(|_| "null".to_string()),
Err(e) => format!("{{\"error\": \"{}\"}}", e),
}
}
0x000A => {
match decode_max_const_flow(tlv_value) {
Ok(value) => serde_json::to_string(&value).unwrap_or_else(|_| "null".to_string()),
Err(e) => format!("{{\"error\": \"{}\"}}", e),
}
}
0x000B => {
match decode_min_const_temp(tlv_value) {
Ok(value) => serde_json::to_string(&value).unwrap_or_else(|_| "null".to_string()),
Err(e) => format!("{{\"error\": \"{}\"}}", e),
}
}
0x000C => {
match decode_max_const_temp(tlv_value) {
Ok(value) => serde_json::to_string(&value).unwrap_or_else(|_| "null".to_string()),
Err(e) => format!("{{\"error\": \"{}\"}}", e),
}
}
0x0010 => {
match decode_pump_status(tlv_value) {
Ok(value) => serde_json::to_string(&value).unwrap_or_else(|_| "null".to_string()),
Err(e) => format!("{{\"error\": \"{}\"}}", e),
}
}
0x0011 => {
match decode_effective_operation_mode(tlv_value) {
Ok(value) => serde_json::to_string(&value).unwrap_or_else(|_| "null".to_string()),
Err(e) => format!("{{\"error\": \"{}\"}}", e),
}
}
0x0012 => {
match decode_effective_control_mode(tlv_value) {
Ok(value) => serde_json::to_string(&value).unwrap_or_else(|_| "null".to_string()),
Err(e) => format!("{{\"error\": \"{}\"}}", e),
}
}
0x0013 => {
match decode_capacity(tlv_value) {
Ok(value) => serde_json::to_string(&value).unwrap_or_else(|_| "null".to_string()),
Err(e) => format!("{{\"error\": \"{}\"}}", e),
}
}
0x0014 => {
match decode_speed(tlv_value) {
Ok(value) => serde_json::to_string(&value).unwrap_or_else(|_| "null".to_string()),
Err(e) => format!("{{\"error\": \"{}\"}}", e),
}
}
0x0015 => {
match decode_lifetime_running_hours(tlv_value) {
Ok(value) => serde_json::to_string(&value).unwrap_or_else(|_| "null".to_string()),
Err(e) => format!("{{\"error\": \"{}\"}}", e),
}
}
0x0016 => {
match decode_power(tlv_value) {
Ok(value) => serde_json::to_string(&value).unwrap_or_else(|_| "null".to_string()),
Err(e) => format!("{{\"error\": \"{}\"}}", e),
}
}
0x0017 => {
match decode_lifetime_energy_consumed(tlv_value) {
Ok(value) => serde_json::to_string(&value).unwrap_or_else(|_| "null".to_string()),
Err(e) => format!("{{\"error\": \"{}\"}}", e),
}
}
0x0020 => {
match decode_operation_mode(tlv_value) {
Ok(value) => serde_json::to_string(&value).unwrap_or_else(|_| "null".to_string()),
Err(e) => format!("{{\"error\": \"{}\"}}", e),
}
}
0x0021 => {
match decode_control_mode(tlv_value) {
Ok(value) => serde_json::to_string(&value).unwrap_or_else(|_| "null".to_string()),
Err(e) => format!("{{\"error\": \"{}\"}}", e),
}
}
0x0022 => {
match decode_alarm_mask(tlv_value) {
Ok(value) => serde_json::to_string(&value).unwrap_or_else(|_| "null".to_string()),
Err(e) => format!("{{\"error\": \"{}\"}}", e),
}
}
_ => format!("{{\"error\": \"Unknown attribute ID: {}\"}}", attribute_id),
}
}
pub fn get_attribute_list() -> Vec<(u32, &'static str)> {
vec![
(0x0000, "MaxPressure"),
(0x0001, "MaxSpeed"),
(0x0002, "MaxFlow"),
(0x0003, "MinConstPressure"),
(0x0004, "MaxConstPressure"),
(0x0005, "MinCompPressure"),
(0x0006, "MaxCompPressure"),
(0x0007, "MinConstSpeed"),
(0x0008, "MaxConstSpeed"),
(0x0009, "MinConstFlow"),
(0x000A, "MaxConstFlow"),
(0x000B, "MinConstTemp"),
(0x000C, "MaxConstTemp"),
(0x0010, "PumpStatus"),
(0x0011, "EffectiveOperationMode"),
(0x0012, "EffectiveControlMode"),
(0x0013, "Capacity"),
(0x0014, "Speed"),
(0x0015, "LifetimeRunningHours"),
(0x0016, "Power"),
(0x0017, "LifetimeEnergyConsumed"),
(0x0020, "OperationMode"),
(0x0021, "ControlMode"),
(0x0022, "AlarmMask"),
]
}
pub async fn read_max_pressure(conn: &crate::controller::Connection, endpoint: u16) -> anyhow::Result<Option<i16>> {
let tlv = conn.read_request2(endpoint, crate::clusters::defs::CLUSTER_ID_PUMP_CONFIGURATION_AND_CONTROL, crate::clusters::defs::CLUSTER_PUMP_CONFIGURATION_AND_CONTROL_ATTR_ID_MAXPRESSURE).await?;
decode_max_pressure(&tlv)
}
pub async fn read_max_speed(conn: &crate::controller::Connection, endpoint: u16) -> anyhow::Result<Option<u16>> {
let tlv = conn.read_request2(endpoint, crate::clusters::defs::CLUSTER_ID_PUMP_CONFIGURATION_AND_CONTROL, crate::clusters::defs::CLUSTER_PUMP_CONFIGURATION_AND_CONTROL_ATTR_ID_MAXSPEED).await?;
decode_max_speed(&tlv)
}
pub async fn read_max_flow(conn: &crate::controller::Connection, endpoint: u16) -> anyhow::Result<Option<u16>> {
let tlv = conn.read_request2(endpoint, crate::clusters::defs::CLUSTER_ID_PUMP_CONFIGURATION_AND_CONTROL, crate::clusters::defs::CLUSTER_PUMP_CONFIGURATION_AND_CONTROL_ATTR_ID_MAXFLOW).await?;
decode_max_flow(&tlv)
}
pub async fn read_min_const_pressure(conn: &crate::controller::Connection, endpoint: u16) -> anyhow::Result<Option<i16>> {
let tlv = conn.read_request2(endpoint, crate::clusters::defs::CLUSTER_ID_PUMP_CONFIGURATION_AND_CONTROL, crate::clusters::defs::CLUSTER_PUMP_CONFIGURATION_AND_CONTROL_ATTR_ID_MINCONSTPRESSURE).await?;
decode_min_const_pressure(&tlv)
}
pub async fn read_max_const_pressure(conn: &crate::controller::Connection, endpoint: u16) -> anyhow::Result<Option<i16>> {
let tlv = conn.read_request2(endpoint, crate::clusters::defs::CLUSTER_ID_PUMP_CONFIGURATION_AND_CONTROL, crate::clusters::defs::CLUSTER_PUMP_CONFIGURATION_AND_CONTROL_ATTR_ID_MAXCONSTPRESSURE).await?;
decode_max_const_pressure(&tlv)
}
pub async fn read_min_comp_pressure(conn: &crate::controller::Connection, endpoint: u16) -> anyhow::Result<Option<i16>> {
let tlv = conn.read_request2(endpoint, crate::clusters::defs::CLUSTER_ID_PUMP_CONFIGURATION_AND_CONTROL, crate::clusters::defs::CLUSTER_PUMP_CONFIGURATION_AND_CONTROL_ATTR_ID_MINCOMPPRESSURE).await?;
decode_min_comp_pressure(&tlv)
}
pub async fn read_max_comp_pressure(conn: &crate::controller::Connection, endpoint: u16) -> anyhow::Result<Option<i16>> {
let tlv = conn.read_request2(endpoint, crate::clusters::defs::CLUSTER_ID_PUMP_CONFIGURATION_AND_CONTROL, crate::clusters::defs::CLUSTER_PUMP_CONFIGURATION_AND_CONTROL_ATTR_ID_MAXCOMPPRESSURE).await?;
decode_max_comp_pressure(&tlv)
}
pub async fn read_min_const_speed(conn: &crate::controller::Connection, endpoint: u16) -> anyhow::Result<Option<u16>> {
let tlv = conn.read_request2(endpoint, crate::clusters::defs::CLUSTER_ID_PUMP_CONFIGURATION_AND_CONTROL, crate::clusters::defs::CLUSTER_PUMP_CONFIGURATION_AND_CONTROL_ATTR_ID_MINCONSTSPEED).await?;
decode_min_const_speed(&tlv)
}
pub async fn read_max_const_speed(conn: &crate::controller::Connection, endpoint: u16) -> anyhow::Result<Option<u16>> {
let tlv = conn.read_request2(endpoint, crate::clusters::defs::CLUSTER_ID_PUMP_CONFIGURATION_AND_CONTROL, crate::clusters::defs::CLUSTER_PUMP_CONFIGURATION_AND_CONTROL_ATTR_ID_MAXCONSTSPEED).await?;
decode_max_const_speed(&tlv)
}
pub async fn read_min_const_flow(conn: &crate::controller::Connection, endpoint: u16) -> anyhow::Result<Option<u16>> {
let tlv = conn.read_request2(endpoint, crate::clusters::defs::CLUSTER_ID_PUMP_CONFIGURATION_AND_CONTROL, crate::clusters::defs::CLUSTER_PUMP_CONFIGURATION_AND_CONTROL_ATTR_ID_MINCONSTFLOW).await?;
decode_min_const_flow(&tlv)
}
pub async fn read_max_const_flow(conn: &crate::controller::Connection, endpoint: u16) -> anyhow::Result<Option<u16>> {
let tlv = conn.read_request2(endpoint, crate::clusters::defs::CLUSTER_ID_PUMP_CONFIGURATION_AND_CONTROL, crate::clusters::defs::CLUSTER_PUMP_CONFIGURATION_AND_CONTROL_ATTR_ID_MAXCONSTFLOW).await?;
decode_max_const_flow(&tlv)
}
pub async fn read_min_const_temp(conn: &crate::controller::Connection, endpoint: u16) -> anyhow::Result<Option<i16>> {
let tlv = conn.read_request2(endpoint, crate::clusters::defs::CLUSTER_ID_PUMP_CONFIGURATION_AND_CONTROL, crate::clusters::defs::CLUSTER_PUMP_CONFIGURATION_AND_CONTROL_ATTR_ID_MINCONSTTEMP).await?;
decode_min_const_temp(&tlv)
}
pub async fn read_max_const_temp(conn: &crate::controller::Connection, endpoint: u16) -> anyhow::Result<Option<i16>> {
let tlv = conn.read_request2(endpoint, crate::clusters::defs::CLUSTER_ID_PUMP_CONFIGURATION_AND_CONTROL, crate::clusters::defs::CLUSTER_PUMP_CONFIGURATION_AND_CONTROL_ATTR_ID_MAXCONSTTEMP).await?;
decode_max_const_temp(&tlv)
}
pub async fn read_pump_status(conn: &crate::controller::Connection, endpoint: u16) -> anyhow::Result<PumpStatus> {
let tlv = conn.read_request2(endpoint, crate::clusters::defs::CLUSTER_ID_PUMP_CONFIGURATION_AND_CONTROL, crate::clusters::defs::CLUSTER_PUMP_CONFIGURATION_AND_CONTROL_ATTR_ID_PUMPSTATUS).await?;
decode_pump_status(&tlv)
}
pub async fn read_effective_operation_mode(conn: &crate::controller::Connection, endpoint: u16) -> anyhow::Result<OperationMode> {
let tlv = conn.read_request2(endpoint, crate::clusters::defs::CLUSTER_ID_PUMP_CONFIGURATION_AND_CONTROL, crate::clusters::defs::CLUSTER_PUMP_CONFIGURATION_AND_CONTROL_ATTR_ID_EFFECTIVEOPERATIONMODE).await?;
decode_effective_operation_mode(&tlv)
}
pub async fn read_effective_control_mode(conn: &crate::controller::Connection, endpoint: u16) -> anyhow::Result<ControlMode> {
let tlv = conn.read_request2(endpoint, crate::clusters::defs::CLUSTER_ID_PUMP_CONFIGURATION_AND_CONTROL, crate::clusters::defs::CLUSTER_PUMP_CONFIGURATION_AND_CONTROL_ATTR_ID_EFFECTIVECONTROLMODE).await?;
decode_effective_control_mode(&tlv)
}
pub async fn read_capacity(conn: &crate::controller::Connection, endpoint: u16) -> anyhow::Result<Option<i16>> {
let tlv = conn.read_request2(endpoint, crate::clusters::defs::CLUSTER_ID_PUMP_CONFIGURATION_AND_CONTROL, crate::clusters::defs::CLUSTER_PUMP_CONFIGURATION_AND_CONTROL_ATTR_ID_CAPACITY).await?;
decode_capacity(&tlv)
}
pub async fn read_speed(conn: &crate::controller::Connection, endpoint: u16) -> anyhow::Result<Option<u16>> {
let tlv = conn.read_request2(endpoint, crate::clusters::defs::CLUSTER_ID_PUMP_CONFIGURATION_AND_CONTROL, crate::clusters::defs::CLUSTER_PUMP_CONFIGURATION_AND_CONTROL_ATTR_ID_SPEED).await?;
decode_speed(&tlv)
}
pub async fn read_lifetime_running_hours(conn: &crate::controller::Connection, endpoint: u16) -> anyhow::Result<Option<u8>> {
let tlv = conn.read_request2(endpoint, crate::clusters::defs::CLUSTER_ID_PUMP_CONFIGURATION_AND_CONTROL, crate::clusters::defs::CLUSTER_PUMP_CONFIGURATION_AND_CONTROL_ATTR_ID_LIFETIMERUNNINGHOURS).await?;
decode_lifetime_running_hours(&tlv)
}
pub async fn read_power(conn: &crate::controller::Connection, endpoint: u16) -> anyhow::Result<Option<u8>> {
let tlv = conn.read_request2(endpoint, crate::clusters::defs::CLUSTER_ID_PUMP_CONFIGURATION_AND_CONTROL, crate::clusters::defs::CLUSTER_PUMP_CONFIGURATION_AND_CONTROL_ATTR_ID_POWER).await?;
decode_power(&tlv)
}
pub async fn read_lifetime_energy_consumed(conn: &crate::controller::Connection, endpoint: u16) -> anyhow::Result<Option<u32>> {
let tlv = conn.read_request2(endpoint, crate::clusters::defs::CLUSTER_ID_PUMP_CONFIGURATION_AND_CONTROL, crate::clusters::defs::CLUSTER_PUMP_CONFIGURATION_AND_CONTROL_ATTR_ID_LIFETIMEENERGYCONSUMED).await?;
decode_lifetime_energy_consumed(&tlv)
}
pub async fn read_operation_mode(conn: &crate::controller::Connection, endpoint: u16) -> anyhow::Result<OperationMode> {
let tlv = conn.read_request2(endpoint, crate::clusters::defs::CLUSTER_ID_PUMP_CONFIGURATION_AND_CONTROL, crate::clusters::defs::CLUSTER_PUMP_CONFIGURATION_AND_CONTROL_ATTR_ID_OPERATIONMODE).await?;
decode_operation_mode(&tlv)
}
pub async fn read_control_mode(conn: &crate::controller::Connection, endpoint: u16) -> anyhow::Result<ControlMode> {
let tlv = conn.read_request2(endpoint, crate::clusters::defs::CLUSTER_ID_PUMP_CONFIGURATION_AND_CONTROL, crate::clusters::defs::CLUSTER_PUMP_CONFIGURATION_AND_CONTROL_ATTR_ID_CONTROLMODE).await?;
decode_control_mode(&tlv)
}
pub async fn read_alarm_mask(conn: &crate::controller::Connection, endpoint: u16) -> anyhow::Result<u8> {
let tlv = conn.read_request2(endpoint, crate::clusters::defs::CLUSTER_ID_PUMP_CONFIGURATION_AND_CONTROL, crate::clusters::defs::CLUSTER_PUMP_CONFIGURATION_AND_CONTROL_ATTR_ID_ALARMMASK).await?;
decode_alarm_mask(&tlv)
}