1#![allow(clippy::too_many_arguments)]
7
8use crate::tlv;
9use anyhow;
10use serde_json;
11
12
13#[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
16#[repr(u8)]
17pub enum ControlMode {
18 Constantspeed = 0,
20 Constantpressure = 1,
22 Proportionalpressure = 2,
24 Constantflow = 3,
26 Constanttemperature = 5,
28 Automatic = 7,
30}
31
32impl ControlMode {
33 pub fn from_u8(value: u8) -> Option<Self> {
35 match value {
36 0 => Some(ControlMode::Constantspeed),
37 1 => Some(ControlMode::Constantpressure),
38 2 => Some(ControlMode::Proportionalpressure),
39 3 => Some(ControlMode::Constantflow),
40 5 => Some(ControlMode::Constanttemperature),
41 7 => Some(ControlMode::Automatic),
42 _ => None,
43 }
44 }
45
46 pub fn to_u8(self) -> u8 {
48 self as u8
49 }
50}
51
52impl From<ControlMode> for u8 {
53 fn from(val: ControlMode) -> Self {
54 val as u8
55 }
56}
57
58#[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
59#[repr(u8)]
60pub enum OperationMode {
61 Normal = 0,
63 Minimum = 1,
65 Maximum = 2,
67 Local = 3,
69}
70
71impl OperationMode {
72 pub fn from_u8(value: u8) -> Option<Self> {
74 match value {
75 0 => Some(OperationMode::Normal),
76 1 => Some(OperationMode::Minimum),
77 2 => Some(OperationMode::Maximum),
78 3 => Some(OperationMode::Local),
79 _ => None,
80 }
81 }
82
83 pub fn to_u8(self) -> u8 {
85 self as u8
86 }
87}
88
89impl From<OperationMode> for u8 {
90 fn from(val: OperationMode) -> Self {
91 val as u8
92 }
93}
94
95pub type PumpStatus = u16;
99
100pub mod pumpstatus {
102 pub const DEVICE_FAULT: u16 = 0x01;
104 pub const SUPPLY_FAULT: u16 = 0x02;
106 pub const SPEED_LOW: u16 = 0x04;
108 pub const SPEED_HIGH: u16 = 0x08;
110 pub const LOCAL_OVERRIDE: u16 = 0x10;
112 pub const RUNNING: u16 = 0x20;
114 pub const REMOTE_PRESSURE: u16 = 0x40;
116 pub const REMOTE_FLOW: u16 = 0x80;
118 pub const REMOTE_TEMPERATURE: u16 = 0x100;
120}
121
122pub fn decode_max_pressure(inp: &tlv::TlvItemValue) -> anyhow::Result<Option<i16>> {
126 if let tlv::TlvItemValue::Int(v) = inp {
127 Ok(Some(*v as i16))
128 } else {
129 Ok(None)
130 }
131}
132
133pub fn decode_max_speed(inp: &tlv::TlvItemValue) -> anyhow::Result<Option<u16>> {
135 if let tlv::TlvItemValue::Int(v) = inp {
136 Ok(Some(*v as u16))
137 } else {
138 Ok(None)
139 }
140}
141
142pub fn decode_max_flow(inp: &tlv::TlvItemValue) -> anyhow::Result<Option<u16>> {
144 if let tlv::TlvItemValue::Int(v) = inp {
145 Ok(Some(*v as u16))
146 } else {
147 Ok(None)
148 }
149}
150
151pub fn decode_min_const_pressure(inp: &tlv::TlvItemValue) -> anyhow::Result<Option<i16>> {
153 if let tlv::TlvItemValue::Int(v) = inp {
154 Ok(Some(*v as i16))
155 } else {
156 Ok(None)
157 }
158}
159
160pub fn decode_max_const_pressure(inp: &tlv::TlvItemValue) -> anyhow::Result<Option<i16>> {
162 if let tlv::TlvItemValue::Int(v) = inp {
163 Ok(Some(*v as i16))
164 } else {
165 Ok(None)
166 }
167}
168
169pub fn decode_min_comp_pressure(inp: &tlv::TlvItemValue) -> anyhow::Result<Option<i16>> {
171 if let tlv::TlvItemValue::Int(v) = inp {
172 Ok(Some(*v as i16))
173 } else {
174 Ok(None)
175 }
176}
177
178pub fn decode_max_comp_pressure(inp: &tlv::TlvItemValue) -> anyhow::Result<Option<i16>> {
180 if let tlv::TlvItemValue::Int(v) = inp {
181 Ok(Some(*v as i16))
182 } else {
183 Ok(None)
184 }
185}
186
187pub fn decode_min_const_speed(inp: &tlv::TlvItemValue) -> anyhow::Result<Option<u16>> {
189 if let tlv::TlvItemValue::Int(v) = inp {
190 Ok(Some(*v as u16))
191 } else {
192 Ok(None)
193 }
194}
195
196pub fn decode_max_const_speed(inp: &tlv::TlvItemValue) -> anyhow::Result<Option<u16>> {
198 if let tlv::TlvItemValue::Int(v) = inp {
199 Ok(Some(*v as u16))
200 } else {
201 Ok(None)
202 }
203}
204
205pub fn decode_min_const_flow(inp: &tlv::TlvItemValue) -> anyhow::Result<Option<u16>> {
207 if let tlv::TlvItemValue::Int(v) = inp {
208 Ok(Some(*v as u16))
209 } else {
210 Ok(None)
211 }
212}
213
214pub fn decode_max_const_flow(inp: &tlv::TlvItemValue) -> anyhow::Result<Option<u16>> {
216 if let tlv::TlvItemValue::Int(v) = inp {
217 Ok(Some(*v as u16))
218 } else {
219 Ok(None)
220 }
221}
222
223pub fn decode_min_const_temp(inp: &tlv::TlvItemValue) -> anyhow::Result<Option<i16>> {
225 if let tlv::TlvItemValue::Int(v) = inp {
226 Ok(Some(*v as i16))
227 } else {
228 Ok(None)
229 }
230}
231
232pub fn decode_max_const_temp(inp: &tlv::TlvItemValue) -> anyhow::Result<Option<i16>> {
234 if let tlv::TlvItemValue::Int(v) = inp {
235 Ok(Some(*v as i16))
236 } else {
237 Ok(None)
238 }
239}
240
241pub fn decode_pump_status(inp: &tlv::TlvItemValue) -> anyhow::Result<PumpStatus> {
243 if let tlv::TlvItemValue::Int(v) = inp {
244 Ok(*v as u16)
245 } else {
246 Err(anyhow::anyhow!("Expected Integer"))
247 }
248}
249
250pub fn decode_effective_operation_mode(inp: &tlv::TlvItemValue) -> anyhow::Result<OperationMode> {
252 if let tlv::TlvItemValue::Int(v) = inp {
253 OperationMode::from_u8(*v as u8).ok_or_else(|| anyhow::anyhow!("Invalid enum value"))
254 } else {
255 Err(anyhow::anyhow!("Expected Integer"))
256 }
257}
258
259pub fn decode_effective_control_mode(inp: &tlv::TlvItemValue) -> anyhow::Result<ControlMode> {
261 if let tlv::TlvItemValue::Int(v) = inp {
262 ControlMode::from_u8(*v as u8).ok_or_else(|| anyhow::anyhow!("Invalid enum value"))
263 } else {
264 Err(anyhow::anyhow!("Expected Integer"))
265 }
266}
267
268pub fn decode_capacity(inp: &tlv::TlvItemValue) -> anyhow::Result<Option<i16>> {
270 if let tlv::TlvItemValue::Int(v) = inp {
271 Ok(Some(*v as i16))
272 } else {
273 Ok(None)
274 }
275}
276
277pub fn decode_speed(inp: &tlv::TlvItemValue) -> anyhow::Result<Option<u16>> {
279 if let tlv::TlvItemValue::Int(v) = inp {
280 Ok(Some(*v as u16))
281 } else {
282 Ok(None)
283 }
284}
285
286pub fn decode_lifetime_running_hours(inp: &tlv::TlvItemValue) -> anyhow::Result<Option<u8>> {
288 if let tlv::TlvItemValue::Int(v) = inp {
289 Ok(Some(*v as u8))
290 } else {
291 Ok(None)
292 }
293}
294
295pub fn decode_power(inp: &tlv::TlvItemValue) -> anyhow::Result<Option<u8>> {
297 if let tlv::TlvItemValue::Int(v) = inp {
298 Ok(Some(*v as u8))
299 } else {
300 Ok(None)
301 }
302}
303
304pub fn decode_lifetime_energy_consumed(inp: &tlv::TlvItemValue) -> anyhow::Result<Option<u32>> {
306 if let tlv::TlvItemValue::Int(v) = inp {
307 Ok(Some(*v as u32))
308 } else {
309 Ok(None)
310 }
311}
312
313pub fn decode_operation_mode(inp: &tlv::TlvItemValue) -> anyhow::Result<OperationMode> {
315 if let tlv::TlvItemValue::Int(v) = inp {
316 OperationMode::from_u8(*v as u8).ok_or_else(|| anyhow::anyhow!("Invalid enum value"))
317 } else {
318 Err(anyhow::anyhow!("Expected Integer"))
319 }
320}
321
322pub fn decode_control_mode(inp: &tlv::TlvItemValue) -> anyhow::Result<ControlMode> {
324 if let tlv::TlvItemValue::Int(v) = inp {
325 ControlMode::from_u8(*v as u8).ok_or_else(|| anyhow::anyhow!("Invalid enum value"))
326 } else {
327 Err(anyhow::anyhow!("Expected Integer"))
328 }
329}
330
331pub fn decode_alarm_mask(inp: &tlv::TlvItemValue) -> anyhow::Result<u8> {
333 if let tlv::TlvItemValue::Int(v) = inp {
334 Ok(*v as u8)
335 } else {
336 Err(anyhow::anyhow!("Expected UInt8"))
337 }
338}
339
340
341pub fn decode_attribute_json(cluster_id: u32, attribute_id: u32, tlv_value: &crate::tlv::TlvItemValue) -> String {
353 if cluster_id != 0x0200 {
355 return format!("{{\"error\": \"Invalid cluster ID. Expected 0x0200, got {}\"}}", cluster_id);
356 }
357
358 match attribute_id {
359 0x0000 => {
360 match decode_max_pressure(tlv_value) {
361 Ok(value) => serde_json::to_string(&value).unwrap_or_else(|_| "null".to_string()),
362 Err(e) => format!("{{\"error\": \"{}\"}}", e),
363 }
364 }
365 0x0001 => {
366 match decode_max_speed(tlv_value) {
367 Ok(value) => serde_json::to_string(&value).unwrap_or_else(|_| "null".to_string()),
368 Err(e) => format!("{{\"error\": \"{}\"}}", e),
369 }
370 }
371 0x0002 => {
372 match decode_max_flow(tlv_value) {
373 Ok(value) => serde_json::to_string(&value).unwrap_or_else(|_| "null".to_string()),
374 Err(e) => format!("{{\"error\": \"{}\"}}", e),
375 }
376 }
377 0x0003 => {
378 match decode_min_const_pressure(tlv_value) {
379 Ok(value) => serde_json::to_string(&value).unwrap_or_else(|_| "null".to_string()),
380 Err(e) => format!("{{\"error\": \"{}\"}}", e),
381 }
382 }
383 0x0004 => {
384 match decode_max_const_pressure(tlv_value) {
385 Ok(value) => serde_json::to_string(&value).unwrap_or_else(|_| "null".to_string()),
386 Err(e) => format!("{{\"error\": \"{}\"}}", e),
387 }
388 }
389 0x0005 => {
390 match decode_min_comp_pressure(tlv_value) {
391 Ok(value) => serde_json::to_string(&value).unwrap_or_else(|_| "null".to_string()),
392 Err(e) => format!("{{\"error\": \"{}\"}}", e),
393 }
394 }
395 0x0006 => {
396 match decode_max_comp_pressure(tlv_value) {
397 Ok(value) => serde_json::to_string(&value).unwrap_or_else(|_| "null".to_string()),
398 Err(e) => format!("{{\"error\": \"{}\"}}", e),
399 }
400 }
401 0x0007 => {
402 match decode_min_const_speed(tlv_value) {
403 Ok(value) => serde_json::to_string(&value).unwrap_or_else(|_| "null".to_string()),
404 Err(e) => format!("{{\"error\": \"{}\"}}", e),
405 }
406 }
407 0x0008 => {
408 match decode_max_const_speed(tlv_value) {
409 Ok(value) => serde_json::to_string(&value).unwrap_or_else(|_| "null".to_string()),
410 Err(e) => format!("{{\"error\": \"{}\"}}", e),
411 }
412 }
413 0x0009 => {
414 match decode_min_const_flow(tlv_value) {
415 Ok(value) => serde_json::to_string(&value).unwrap_or_else(|_| "null".to_string()),
416 Err(e) => format!("{{\"error\": \"{}\"}}", e),
417 }
418 }
419 0x000A => {
420 match decode_max_const_flow(tlv_value) {
421 Ok(value) => serde_json::to_string(&value).unwrap_or_else(|_| "null".to_string()),
422 Err(e) => format!("{{\"error\": \"{}\"}}", e),
423 }
424 }
425 0x000B => {
426 match decode_min_const_temp(tlv_value) {
427 Ok(value) => serde_json::to_string(&value).unwrap_or_else(|_| "null".to_string()),
428 Err(e) => format!("{{\"error\": \"{}\"}}", e),
429 }
430 }
431 0x000C => {
432 match decode_max_const_temp(tlv_value) {
433 Ok(value) => serde_json::to_string(&value).unwrap_or_else(|_| "null".to_string()),
434 Err(e) => format!("{{\"error\": \"{}\"}}", e),
435 }
436 }
437 0x0010 => {
438 match decode_pump_status(tlv_value) {
439 Ok(value) => serde_json::to_string(&value).unwrap_or_else(|_| "null".to_string()),
440 Err(e) => format!("{{\"error\": \"{}\"}}", e),
441 }
442 }
443 0x0011 => {
444 match decode_effective_operation_mode(tlv_value) {
445 Ok(value) => serde_json::to_string(&value).unwrap_or_else(|_| "null".to_string()),
446 Err(e) => format!("{{\"error\": \"{}\"}}", e),
447 }
448 }
449 0x0012 => {
450 match decode_effective_control_mode(tlv_value) {
451 Ok(value) => serde_json::to_string(&value).unwrap_or_else(|_| "null".to_string()),
452 Err(e) => format!("{{\"error\": \"{}\"}}", e),
453 }
454 }
455 0x0013 => {
456 match decode_capacity(tlv_value) {
457 Ok(value) => serde_json::to_string(&value).unwrap_or_else(|_| "null".to_string()),
458 Err(e) => format!("{{\"error\": \"{}\"}}", e),
459 }
460 }
461 0x0014 => {
462 match decode_speed(tlv_value) {
463 Ok(value) => serde_json::to_string(&value).unwrap_or_else(|_| "null".to_string()),
464 Err(e) => format!("{{\"error\": \"{}\"}}", e),
465 }
466 }
467 0x0015 => {
468 match decode_lifetime_running_hours(tlv_value) {
469 Ok(value) => serde_json::to_string(&value).unwrap_or_else(|_| "null".to_string()),
470 Err(e) => format!("{{\"error\": \"{}\"}}", e),
471 }
472 }
473 0x0016 => {
474 match decode_power(tlv_value) {
475 Ok(value) => serde_json::to_string(&value).unwrap_or_else(|_| "null".to_string()),
476 Err(e) => format!("{{\"error\": \"{}\"}}", e),
477 }
478 }
479 0x0017 => {
480 match decode_lifetime_energy_consumed(tlv_value) {
481 Ok(value) => serde_json::to_string(&value).unwrap_or_else(|_| "null".to_string()),
482 Err(e) => format!("{{\"error\": \"{}\"}}", e),
483 }
484 }
485 0x0020 => {
486 match decode_operation_mode(tlv_value) {
487 Ok(value) => serde_json::to_string(&value).unwrap_or_else(|_| "null".to_string()),
488 Err(e) => format!("{{\"error\": \"{}\"}}", e),
489 }
490 }
491 0x0021 => {
492 match decode_control_mode(tlv_value) {
493 Ok(value) => serde_json::to_string(&value).unwrap_or_else(|_| "null".to_string()),
494 Err(e) => format!("{{\"error\": \"{}\"}}", e),
495 }
496 }
497 0x0022 => {
498 match decode_alarm_mask(tlv_value) {
499 Ok(value) => serde_json::to_string(&value).unwrap_or_else(|_| "null".to_string()),
500 Err(e) => format!("{{\"error\": \"{}\"}}", e),
501 }
502 }
503 _ => format!("{{\"error\": \"Unknown attribute ID: {}\"}}", attribute_id),
504 }
505}
506
507pub fn get_attribute_list() -> Vec<(u32, &'static str)> {
512 vec![
513 (0x0000, "MaxPressure"),
514 (0x0001, "MaxSpeed"),
515 (0x0002, "MaxFlow"),
516 (0x0003, "MinConstPressure"),
517 (0x0004, "MaxConstPressure"),
518 (0x0005, "MinCompPressure"),
519 (0x0006, "MaxCompPressure"),
520 (0x0007, "MinConstSpeed"),
521 (0x0008, "MaxConstSpeed"),
522 (0x0009, "MinConstFlow"),
523 (0x000A, "MaxConstFlow"),
524 (0x000B, "MinConstTemp"),
525 (0x000C, "MaxConstTemp"),
526 (0x0010, "PumpStatus"),
527 (0x0011, "EffectiveOperationMode"),
528 (0x0012, "EffectiveControlMode"),
529 (0x0013, "Capacity"),
530 (0x0014, "Speed"),
531 (0x0015, "LifetimeRunningHours"),
532 (0x0016, "Power"),
533 (0x0017, "LifetimeEnergyConsumed"),
534 (0x0020, "OperationMode"),
535 (0x0021, "ControlMode"),
536 (0x0022, "AlarmMask"),
537 ]
538}
539
540pub async fn read_max_pressure(conn: &crate::controller::Connection, endpoint: u16) -> anyhow::Result<Option<i16>> {
544 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?;
545 decode_max_pressure(&tlv)
546}
547
548pub async fn read_max_speed(conn: &crate::controller::Connection, endpoint: u16) -> anyhow::Result<Option<u16>> {
550 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?;
551 decode_max_speed(&tlv)
552}
553
554pub async fn read_max_flow(conn: &crate::controller::Connection, endpoint: u16) -> anyhow::Result<Option<u16>> {
556 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?;
557 decode_max_flow(&tlv)
558}
559
560pub async fn read_min_const_pressure(conn: &crate::controller::Connection, endpoint: u16) -> anyhow::Result<Option<i16>> {
562 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?;
563 decode_min_const_pressure(&tlv)
564}
565
566pub async fn read_max_const_pressure(conn: &crate::controller::Connection, endpoint: u16) -> anyhow::Result<Option<i16>> {
568 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?;
569 decode_max_const_pressure(&tlv)
570}
571
572pub async fn read_min_comp_pressure(conn: &crate::controller::Connection, endpoint: u16) -> anyhow::Result<Option<i16>> {
574 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?;
575 decode_min_comp_pressure(&tlv)
576}
577
578pub async fn read_max_comp_pressure(conn: &crate::controller::Connection, endpoint: u16) -> anyhow::Result<Option<i16>> {
580 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?;
581 decode_max_comp_pressure(&tlv)
582}
583
584pub async fn read_min_const_speed(conn: &crate::controller::Connection, endpoint: u16) -> anyhow::Result<Option<u16>> {
586 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?;
587 decode_min_const_speed(&tlv)
588}
589
590pub async fn read_max_const_speed(conn: &crate::controller::Connection, endpoint: u16) -> anyhow::Result<Option<u16>> {
592 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?;
593 decode_max_const_speed(&tlv)
594}
595
596pub async fn read_min_const_flow(conn: &crate::controller::Connection, endpoint: u16) -> anyhow::Result<Option<u16>> {
598 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?;
599 decode_min_const_flow(&tlv)
600}
601
602pub async fn read_max_const_flow(conn: &crate::controller::Connection, endpoint: u16) -> anyhow::Result<Option<u16>> {
604 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?;
605 decode_max_const_flow(&tlv)
606}
607
608pub async fn read_min_const_temp(conn: &crate::controller::Connection, endpoint: u16) -> anyhow::Result<Option<i16>> {
610 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?;
611 decode_min_const_temp(&tlv)
612}
613
614pub async fn read_max_const_temp(conn: &crate::controller::Connection, endpoint: u16) -> anyhow::Result<Option<i16>> {
616 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?;
617 decode_max_const_temp(&tlv)
618}
619
620pub async fn read_pump_status(conn: &crate::controller::Connection, endpoint: u16) -> anyhow::Result<PumpStatus> {
622 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?;
623 decode_pump_status(&tlv)
624}
625
626pub async fn read_effective_operation_mode(conn: &crate::controller::Connection, endpoint: u16) -> anyhow::Result<OperationMode> {
628 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?;
629 decode_effective_operation_mode(&tlv)
630}
631
632pub async fn read_effective_control_mode(conn: &crate::controller::Connection, endpoint: u16) -> anyhow::Result<ControlMode> {
634 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?;
635 decode_effective_control_mode(&tlv)
636}
637
638pub async fn read_capacity(conn: &crate::controller::Connection, endpoint: u16) -> anyhow::Result<Option<i16>> {
640 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?;
641 decode_capacity(&tlv)
642}
643
644pub async fn read_speed(conn: &crate::controller::Connection, endpoint: u16) -> anyhow::Result<Option<u16>> {
646 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?;
647 decode_speed(&tlv)
648}
649
650pub async fn read_lifetime_running_hours(conn: &crate::controller::Connection, endpoint: u16) -> anyhow::Result<Option<u8>> {
652 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?;
653 decode_lifetime_running_hours(&tlv)
654}
655
656pub async fn read_power(conn: &crate::controller::Connection, endpoint: u16) -> anyhow::Result<Option<u8>> {
658 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?;
659 decode_power(&tlv)
660}
661
662pub async fn read_lifetime_energy_consumed(conn: &crate::controller::Connection, endpoint: u16) -> anyhow::Result<Option<u32>> {
664 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?;
665 decode_lifetime_energy_consumed(&tlv)
666}
667
668pub async fn read_operation_mode(conn: &crate::controller::Connection, endpoint: u16) -> anyhow::Result<OperationMode> {
670 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?;
671 decode_operation_mode(&tlv)
672}
673
674pub async fn read_control_mode(conn: &crate::controller::Connection, endpoint: u16) -> anyhow::Result<ControlMode> {
676 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?;
677 decode_control_mode(&tlv)
678}
679
680pub async fn read_alarm_mask(conn: &crate::controller::Connection, endpoint: u16) -> anyhow::Result<u8> {
682 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?;
683 decode_alarm_mask(&tlv)
684}
685