Skip to content

Commit 85c7c15

Browse files
committed
GH-27: Expose Humidity CC to MQTT
Forwarded: #27 Bug-SiliconLabs: UIC-3042 Bug-Github: #27
1 parent 0615358 commit 85c7c15

File tree

46 files changed

+14933
-5
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+14933
-5
lines changed

applications/dev_ui/dev_gui/zap-generated/src/cluster-types/cluster-type-attributes.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
//This file is generated automatically. Don't try to change something here.
22
//To add support for new clusters, modify addon-helper.js
33
//To change the stucture of the ClusterTypeAttrs, modify cluster-type-attributes.zapt
4-
5-
4+
5+
66
//generate ClusterTypes
77
export let ClusterTypeAttrs: any = {
88
Basic: {
@@ -15863,5 +15863,5 @@ export let ClusterTypeAttrs: any = {
1586315863
commands: [
1586415864
]
1586515865
}
15866-
}
15866+
},
1586715867
}
Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
// Humidity setpoint CC
2+
def zwHUMIDITY_CONTROL_SETPOINT_VERSION 0x6401
3+
def zwHUMIDITY_CONTROL_SUPPORTED_SETPOINT_SUPPORTED_TYPES 0x6402
4+
def zwHUMIDITY_CONTROL_SETPOINT_TYPE 0x6403
5+
def zwHUMIDITY_CONTROL_SETPOINT_VALUE 0x6405
6+
def zwHUMIDITY_CONTROL_SETPOINT_VALUE_SCALE 0x6406
7+
def zwHUMIDITY_CONTROL_SETPOINT_VALUE_PRECISION 0x6407
8+
def zwHUMIDITY_CONTROL_SETPOINT_MIN_VALUE 0x6408
9+
def zwHUMIDITY_CONTROL_SETPOINT_MIN_VALUE_SCALE 0x6409
10+
def zwHUMIDITY_CONTROL_SETPOINT_MIN_VALUE_PRECISION 0x640A
11+
def zwHUMIDITY_CONTROL_SETPOINT_MAX_VALUE 0x640B
12+
def zwHUMIDITY_CONTROL_SETPOINT_MAX_VALUE_SCALE 0x640C
13+
def zwHUMIDITY_CONTROL_SETPOINT_MAX_VALUE_PRECISION 0x640D
14+
15+
// Humidity Mode CC
16+
def zwHUMIDITY_CONTROL_MODE_VERSION 0x6D01
17+
def zwHUMIDITY_CONTROL_SUPPORTED_MODES 0x6D02
18+
def zwHUMIDITY_CONTROL_MODE 0x6D03
19+
20+
// Humidity Operating State CC
21+
def zwHUMIDITY_CONTROL_OPERATING_STATE_VERSION 0x6D01
22+
def zwHUMIDITY_CONTROL_OPERATING_STATE 0x6D02
23+
24+
25+
// Humidity Cluster
26+
def zb_ReportingMode 0xfda00001
27+
def zb_SupportedReportingMode 0xfda00002
28+
def zb_CurrentState 0xfda00003
29+
def zb_SupportedSetPoints 0xfda00004
30+
def zb_HumidifierSetpointMin 0xfda00005
31+
def zb_HumidifierSetpointMax 0xfda00006
32+
def zb_HumidifierSetpoint 0xfda00007
33+
def zb_HumidifierSetpointScale 0xfda00008
34+
def zb_HumidifierSetpointPrecision 0xfda00009
35+
def zb_DehumidifierSetpointMin 0xfda0000a
36+
def zb_DehumidifierSetpointMax 0xfda0000b
37+
def zb_DehumidifierSetpoint 0xfda0000c
38+
def zb_DehumidifierSetpointScale 0xfda0000d
39+
def zb_DehumidifierSetpointPrecision 0xfda0000e
40+
def zb_AutoSetpointMin 0xfda0000f
41+
def zb_AutoSetpointMax 0xfda00010
42+
def zb_AutoSetpoint 0xfda00011
43+
def zb_AutoSetpointScale 0xfda00012
44+
def zb_AutoSetpointPrecision 0xfda00013
45+
46+
def humidity_control_setpoint_humidify_exists (e'zwHUMIDITY_CONTROL_SETPOINT_TYPE[1])
47+
def humidity_control_setpoint_dehumidify_exists (e'zwHUMIDITY_CONTROL_SETPOINT_TYPE[2])
48+
def humidity_control_setpoint_auto_exists (e'zwHUMIDITY_CONTROL_SETPOINT_TYPE[3])
49+
50+
51+
scope 0 chain_reaction(0) {
52+
//// Setpoints
53+
54+
// Humidifier
55+
r'zb_HumidifierSetpoint =
56+
if (humidity_control_setpoint_humidify_exists)
57+
r'zwHUMIDITY_CONTROL_SETPOINT_TYPE[1].zwHUMIDITY_CONTROL_SETPOINT_VALUE
58+
undefined
59+
r'zb_HumidifierSetpointMin =
60+
if (humidity_control_setpoint_humidify_exists)
61+
r'zwHUMIDITY_CONTROL_SETPOINT_TYPE[1].zwHUMIDITY_CONTROL_SETPOINT_MIN_VALUE
62+
undefined
63+
r'zb_HumidifierSetpointMax =
64+
if (humidity_control_setpoint_humidify_exists)
65+
r'zwHUMIDITY_CONTROL_SETPOINT_TYPE[1].zwHUMIDITY_CONTROL_SETPOINT_MAX_VALUE
66+
undefined
67+
r'zb_HumidifierSetpointScale =
68+
if (humidity_control_setpoint_humidify_exists)
69+
r'zwHUMIDITY_CONTROL_SETPOINT_TYPE[1].zwHUMIDITY_CONTROL_SETPOINT_VALUE_SCALE
70+
undefined
71+
r'zb_HumidifierSetpointPrecision =
72+
if (humidity_control_setpoint_humidify_exists)
73+
r'zwHUMIDITY_CONTROL_SETPOINT_TYPE[1].zwHUMIDITY_CONTROL_SETPOINT_VALUE_PRECISION
74+
undefined
75+
76+
// Humidifier
77+
r'zb_DehumidifierSetpoint =
78+
if (humidity_control_setpoint_dehumidify_exists)
79+
r'zwHUMIDITY_CONTROL_SETPOINT_TYPE[2].zwHUMIDITY_CONTROL_SETPOINT_VALUE
80+
undefined
81+
r'zb_DehumidifierSetpointMin =
82+
if (humidity_control_setpoint_dehumidify_exists)
83+
r'zwHUMIDITY_CONTROL_SETPOINT_TYPE[2].zwHUMIDITY_CONTROL_SETPOINT_MIN_VALUE
84+
undefined
85+
r'zb_DehumidifierSetpointMax =
86+
if (humidity_control_setpoint_dehumidify_exists)
87+
r'zwHUMIDITY_CONTROL_SETPOINT_TYPE[2].zwHUMIDITY_CONTROL_SETPOINT_MAX_VALUE
88+
undefined
89+
r'zb_DehumidifierSetpointScale =
90+
if (humidity_control_setpoint_dehumidify_exists)
91+
r'zwHUMIDITY_CONTROL_SETPOINT_TYPE[2].zwHUMIDITY_CONTROL_SETPOINT_VALUE_SCALE
92+
undefined
93+
r'zb_DehumidifierSetpointPrecision =
94+
if (humidity_control_setpoint_dehumidify_exists)
95+
r'zwHUMIDITY_CONTROL_SETPOINT_TYPE[2].zwHUMIDITY_CONTROL_SETPOINT_VALUE_PRECISION
96+
undefined
97+
98+
// Humidifier
99+
r'zb_AutoSetpoint =
100+
if (humidity_control_setpoint_auto_exists)
101+
r'zwHUMIDITY_CONTROL_SETPOINT_TYPE[2].zwHUMIDITY_CONTROL_SETPOINT_VALUE
102+
undefined
103+
r'zb_AutoSetpointMin =
104+
if (humidity_control_setpoint_auto_exists)
105+
r'zwHUMIDITY_CONTROL_SETPOINT_TYPE[2].zwHUMIDITY_CONTROL_SETPOINT_MIN_VALUE
106+
undefined
107+
r'zb_AutoSetpointMax =
108+
if (humidity_control_setpoint_auto_exists)
109+
r'zwHUMIDITY_CONTROL_SETPOINT_TYPE[2].zwHUMIDITY_CONTROL_SETPOINT_MAX_VALUE
110+
undefined
111+
r'zb_AutoSetpointScale =
112+
if (humidity_control_setpoint_auto_exists)
113+
r'zwHUMIDITY_CONTROL_SETPOINT_TYPE[2].zwHUMIDITY_CONTROL_SETPOINT_VALUE_SCALE
114+
undefined
115+
r'zb_AutoSetpointPrecision =
116+
if (humidity_control_setpoint_auto_exists)
117+
r'zwHUMIDITY_CONTROL_SETPOINT_TYPE[2].zwHUMIDITY_CONTROL_SETPOINT_VALUE_PRECISION
118+
undefined
119+
120+
// Supported setpoints
121+
r'zb_SupportedSetPoints = r'zwHUMIDITY_CONTROL_SUPPORTED_SETPOINT_SUPPORTED_TYPES
122+
123+
//// State
124+
r'zb_CurrentState = r'zwHUMIDITY_CONTROL_OPERATING_STATE
125+
126+
//// Mode
127+
r'zb_ReportingMode = r'zwHUMIDITY_CONTROL_SUPPORTED_MODES
128+
// Since it is a writable attribute we need to update it this way too
129+
r'zwHUMIDITY_CONTROL_SUPPORTED_MODES = r'zb_ReportingMode
130+
131+
r'zb_SupportedReportingMode = r'zwHUMIDITY_CONTROL_MODE
132+
}
133+

applications/zpc/components/zcl_cluster_servers/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ add_library(
1414
src/zcl_cluster_servers_helpers.cpp
1515
src/zcl_OTA_cluster_server.cpp
1616
src/zcl_rf_telemetry_cluster_server.c
17-
src/zcl_scenes_cluster_server.cpp)
17+
src/zcl_scenes_cluster_server.cpp
18+
src/humidity_control_cluster_server.c
19+
)
1820

1921
target_include_directories(
2022
zcl_cluster_servers
Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
2+
/******************************************************************************
3+
* # License
4+
* <b>Copyright 2024 Silicon Laboratories Inc. www.silabs.com</b>
5+
******************************************************************************
6+
* The licensor of this software is Silicon Laboratories Inc. Your use of this
7+
* software is governed by the terms of Silicon Labs Master Software License
8+
* Agreement (MSLA) available at
9+
* www.silabs.com/about-us/legal/master-software-license-agreement. This
10+
* software is distributed to you in Source Code format and is governed by the
11+
* sections of the MSLA applicable to Source Code.
12+
*
13+
*****************************************************************************/
14+
// Includes from this component
15+
#include "humidity_control_cluster_server.h"
16+
17+
// Includes from Unify
18+
#include "sl_log.h"
19+
#include "sl_status.h"
20+
#include "attribute_store_helper.h"
21+
#include "zpc_attribute_store_network_helper.h"
22+
#include "zwave_command_class_humidity_control_types.h"
23+
24+
#include "attribute_store_defined_attribute_types.h"
25+
#include "unify_dotdot_defined_attribute_types.h"
26+
#include "unify_dotdot_attribute_store.h"
27+
#include "unify_dotdot_attribute_store_node_state.h"
28+
29+
// Includes from auto-generated files
30+
#include "dotdot_mqtt.h"
31+
32+
// Setup Log ID
33+
#define LOG_TAG "humidity_control_cluster_server"
34+
35+
sl_status_t zwave_humidity_control_mode_set(
36+
dotdot_unid_t unid,
37+
dotdot_endpoint_id_t endpoint,
38+
uic_mqtt_dotdot_callback_call_type_t call_type,
39+
ModeType mode)
40+
{
41+
attribute_store_node_t endpoint_node
42+
= attribute_store_network_helper_get_endpoint_node(unid, endpoint);
43+
44+
attribute_store_node_t current_mode_node
45+
= attribute_store_get_first_child_by_type(
46+
endpoint_node,
47+
ATTRIBUTE_COMMAND_CLASS_HUMIDITY_CONTROL_MODE_CURRENT_MODE);
48+
49+
// First check the call type. If this is a support check support call,
50+
// we check the attributes
51+
if (call_type == UIC_MQTT_DOTDOT_CALLBACK_TYPE_SUPPORT_CHECK) {
52+
// Check user option automatic_deduction_of_supported_commands
53+
return attribute_store_node_exists(current_mode_node) ? SL_STATUS_OK
54+
: SL_STATUS_FAIL;
55+
}
56+
57+
humidity_control_mode_t mode_value = mode;
58+
return attribute_store_set_desired(current_mode_node,
59+
&mode_value,
60+
sizeof(mode_value));
61+
}
62+
63+
sl_status_t zwave_humidity_control_setpoint_set(
64+
dotdot_unid_t unid,
65+
dotdot_endpoint_id_t endpoint,
66+
uic_mqtt_dotdot_callback_call_type_t call_type,
67+
SetpointType type,
68+
uint8_t precision,
69+
uint8_t scale,
70+
int32_t value)
71+
{
72+
// First check the call type. This command have too many requirements
73+
// so we support it by default
74+
if (call_type == UIC_MQTT_DOTDOT_CALLBACK_TYPE_SUPPORT_CHECK) {
75+
return SL_STATUS_OK;
76+
}
77+
78+
attribute_store_node_t endpoint_node
79+
= attribute_store_network_helper_get_endpoint_node(unid, endpoint);
80+
81+
humidity_control_setpoint_type_t setpoint_type = type;
82+
83+
attribute_store_node_t setpoint_type_node
84+
= attribute_store_get_node_child_by_value(
85+
endpoint_node,
86+
ATTRIBUTE_COMMAND_CLASS_HUMIDITY_CONTROL_SETPOINT_TYPE,
87+
REPORTED_ATTRIBUTE,
88+
&setpoint_type,
89+
sizeof(setpoint_type),
90+
0);
91+
92+
if (setpoint_type == ATTRIBUTE_STORE_INVALID_NODE) {
93+
sl_log_warning(LOG_TAG,
94+
"Can't find humidity setpoint type %d",
95+
setpoint_type);
96+
return SL_STATUS_FAIL;
97+
}
98+
99+
attribute_store_set_child_reported(
100+
setpoint_type_node,
101+
ATTRIBUTE_COMMAND_CLASS_HUMIDITY_CONTROL_SETPOINT_VALUE_PRECISION,
102+
&precision,
103+
sizeof(precision));
104+
105+
attribute_store_set_child_reported(
106+
setpoint_type_node,
107+
ATTRIBUTE_COMMAND_CLASS_HUMIDITY_CONTROL_SETPOINT_VALUE_SCALE,
108+
&scale,
109+
sizeof(scale));
110+
111+
return attribute_store_set_child_desired(
112+
setpoint_type_node,
113+
ATTRIBUTE_COMMAND_CLASS_HUMIDITY_CONTROL_SETPOINT_VALUE,
114+
&value,
115+
sizeof(value));
116+
}
117+
118+
///////////////////////////////////////////////////////////////////////////////
119+
// Init and teardown functions
120+
///////////////////////////////////////////////////////////////////////////////
121+
sl_status_t humidity_control_cluster_server_init()
122+
{
123+
sl_log_debug(LOG_TAG, "Humidity Control cluster (ZWave) server initialization");
124+
125+
// Listen to the BASIC Value attribute is created
126+
uic_mqtt_dotdot_z_wave_humidity_control_mode_set_callback_set(
127+
&zwave_humidity_control_mode_set);
128+
129+
uic_mqtt_dotdot_z_wave_humidity_control_setpoint_set_callback_set(
130+
&zwave_humidity_control_setpoint_set);
131+
132+
return SL_STATUS_OK;
133+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/******************************************************************************
2+
* # License
3+
* <b>Copyright 2024 Silicon Laboratories Inc. www.silabs.com</b>
4+
******************************************************************************
5+
* The licensor of this software is Silicon Laboratories Inc. Your use of this
6+
* software is governed by the terms of Silicon Labs Master Software License
7+
* Agreement (MSLA) available at
8+
* www.silabs.com/about-us/legal/master-software-license-agreement. This
9+
* software is distributed to you in Source Code format and is governed by the
10+
* sections of the MSLA applicable to Source Code.
11+
*
12+
*****************************************************************************/
13+
14+
#ifndef HUMIDITY_CONTROL_CLUSTER_SERVER_H
15+
#define HUMIDITY_CONTROL_CLUSTER_SERVER_H
16+
17+
// Generic includes
18+
#include "sl_status.h"
19+
20+
#ifdef __cplusplus
21+
extern "C" {
22+
#endif
23+
24+
/**
25+
* @brief Initialize the FanControl cluster server
26+
*
27+
* @returns true on success
28+
* @returns false on failure
29+
*
30+
*/
31+
sl_status_t humidity_control_cluster_server_init(void);
32+
33+
#ifdef __cplusplus
34+
}
35+
#endif
36+
37+
#endif //HUMIDITY_CONTROL_CLUSTER_SERVER_H
38+
/** @} end humidity_control_cluster_server */

applications/zpc/components/zcl_cluster_servers/test/CMakeLists.txt

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,4 +102,16 @@ target_add_unittest(
102102
zcl_cluster_servers_fixture_test.c
103103
DEPENDS
104104
unify
105-
zpc_config_mock)
105+
zpc_config_mock)
106+
107+
# Humidity Control Cluster Mapper test
108+
target_add_unittest(
109+
zcl_cluster_servers
110+
NAME
111+
humidity_control_cluster_server_test
112+
SOURCES
113+
humidity_control_cluster_server_test.c
114+
DEPENDS
115+
zpc_attribute_store_test_helper
116+
uic_dotdot_mqtt_mock
117+
unify_dotdot_attribute_store)

0 commit comments

Comments
 (0)