matc/clusters/codec/
operational_state_oven.rs1#![allow(clippy::too_many_arguments)]
7
8use anyhow;
9use serde_json;
10
11
12pub fn get_command_list() -> Vec<(u32, &'static str)> {
17 vec![
18 (0x00, "Pause"),
19 (0x01, "Stop"),
20 (0x02, "Start"),
21 (0x03, "Resume"),
22 (0x04, "OperationalCommandResponse"),
23 ]
24}
25
26pub fn get_command_name(cmd_id: u32) -> Option<&'static str> {
27 match cmd_id {
28 0x00 => Some("Pause"),
29 0x01 => Some("Stop"),
30 0x02 => Some("Start"),
31 0x03 => Some("Resume"),
32 0x04 => Some("OperationalCommandResponse"),
33 _ => None,
34 }
35}
36
37pub fn get_command_schema(cmd_id: u32) -> Option<Vec<crate::clusters::codec::CommandField>> {
38 match cmd_id {
39 0x00 => Some(vec![]),
40 0x01 => Some(vec![]),
41 0x02 => Some(vec![]),
42 0x03 => Some(vec![]),
43 0x04 => Some(vec![]),
44 _ => None,
45 }
46}
47
48pub fn encode_command_json(cmd_id: u32, _args: &serde_json::Value) -> anyhow::Result<Vec<u8>> {
49 match cmd_id {
50 0x00 => Ok(vec![]),
51 0x01 => Ok(vec![]),
52 0x02 => Ok(vec![]),
53 0x03 => Ok(vec![]),
54 0x04 => Ok(vec![]),
55 _ => Err(anyhow::anyhow!("unknown command ID: 0x{:02X}", cmd_id)),
56 }
57}
58
59pub async fn pause(conn: &crate::controller::Connection, endpoint: u16) -> anyhow::Result<()> {
63 conn.invoke_request(endpoint, crate::clusters::defs::CLUSTER_ID_OVEN_CAVITY_OPERATIONAL_STATE, crate::clusters::defs::CLUSTER_OVEN_CAVITY_OPERATIONAL_STATE_CMD_ID_PAUSE, &[]).await?;
64 Ok(())
65}
66
67pub async fn stop(conn: &crate::controller::Connection, endpoint: u16) -> anyhow::Result<()> {
69 conn.invoke_request(endpoint, crate::clusters::defs::CLUSTER_ID_OVEN_CAVITY_OPERATIONAL_STATE, crate::clusters::defs::CLUSTER_OVEN_CAVITY_OPERATIONAL_STATE_CMD_ID_STOP, &[]).await?;
70 Ok(())
71}
72
73pub async fn start(conn: &crate::controller::Connection, endpoint: u16) -> anyhow::Result<()> {
75 conn.invoke_request(endpoint, crate::clusters::defs::CLUSTER_ID_OVEN_CAVITY_OPERATIONAL_STATE, crate::clusters::defs::CLUSTER_OVEN_CAVITY_OPERATIONAL_STATE_CMD_ID_START, &[]).await?;
76 Ok(())
77}
78
79pub async fn resume(conn: &crate::controller::Connection, endpoint: u16) -> anyhow::Result<()> {
81 conn.invoke_request(endpoint, crate::clusters::defs::CLUSTER_ID_OVEN_CAVITY_OPERATIONAL_STATE, crate::clusters::defs::CLUSTER_OVEN_CAVITY_OPERATIONAL_STATE_CMD_ID_RESUME, &[]).await?;
82 Ok(())
83}
84
85pub async fn operational_command_response(conn: &crate::controller::Connection, endpoint: u16) -> anyhow::Result<()> {
87 conn.invoke_request(endpoint, crate::clusters::defs::CLUSTER_ID_OVEN_CAVITY_OPERATIONAL_STATE, crate::clusters::defs::CLUSTER_OVEN_CAVITY_OPERATIONAL_STATE_CMD_ID_OPERATIONALCOMMANDRESPONSE, &[]).await?;
88 Ok(())
89}
90