Skip to content

Commit

Permalink
SiliconLabsGH-27: Expose Humidity CC to MQTT
Browse files Browse the repository at this point in the history
Forwarded: SiliconLabs#27
Bug-SiliconLabs: UIC-3042
Bug-Github: SiliconLabs#27
  • Loading branch information
silabs-borisl committed Feb 16, 2024
1 parent 0615358 commit 85c7c15
Show file tree
Hide file tree
Showing 46 changed files with 14,933 additions and 5 deletions.
@@ -1,8 +1,8 @@
//This file is generated automatically. Don't try to change something here.
//To add support for new clusters, modify addon-helper.js
//To change the stucture of the ClusterTypeAttrs, modify cluster-type-attributes.zapt



//generate ClusterTypes
export let ClusterTypeAttrs: any = {
Basic: {
Expand Down Expand Up @@ -15863,5 +15863,5 @@ export let ClusterTypeAttrs: any = {
commands: [
]
}
}
},
}
133 changes: 133 additions & 0 deletions applications/zpc/components/dotdot_mapper/rules/Humidity.uam
@@ -0,0 +1,133 @@
// Humidity setpoint CC
def zwHUMIDITY_CONTROL_SETPOINT_VERSION 0x6401
def zwHUMIDITY_CONTROL_SUPPORTED_SETPOINT_SUPPORTED_TYPES 0x6402
def zwHUMIDITY_CONTROL_SETPOINT_TYPE 0x6403
def zwHUMIDITY_CONTROL_SETPOINT_VALUE 0x6405
def zwHUMIDITY_CONTROL_SETPOINT_VALUE_SCALE 0x6406
def zwHUMIDITY_CONTROL_SETPOINT_VALUE_PRECISION 0x6407
def zwHUMIDITY_CONTROL_SETPOINT_MIN_VALUE 0x6408
def zwHUMIDITY_CONTROL_SETPOINT_MIN_VALUE_SCALE 0x6409
def zwHUMIDITY_CONTROL_SETPOINT_MIN_VALUE_PRECISION 0x640A
def zwHUMIDITY_CONTROL_SETPOINT_MAX_VALUE 0x640B
def zwHUMIDITY_CONTROL_SETPOINT_MAX_VALUE_SCALE 0x640C
def zwHUMIDITY_CONTROL_SETPOINT_MAX_VALUE_PRECISION 0x640D

// Humidity Mode CC
def zwHUMIDITY_CONTROL_MODE_VERSION 0x6D01
def zwHUMIDITY_CONTROL_SUPPORTED_MODES 0x6D02
def zwHUMIDITY_CONTROL_MODE 0x6D03

// Humidity Operating State CC
def zwHUMIDITY_CONTROL_OPERATING_STATE_VERSION 0x6D01
def zwHUMIDITY_CONTROL_OPERATING_STATE 0x6D02


// Humidity Cluster
def zb_ReportingMode 0xfda00001
def zb_SupportedReportingMode 0xfda00002
def zb_CurrentState 0xfda00003
def zb_SupportedSetPoints 0xfda00004
def zb_HumidifierSetpointMin 0xfda00005
def zb_HumidifierSetpointMax 0xfda00006
def zb_HumidifierSetpoint 0xfda00007
def zb_HumidifierSetpointScale 0xfda00008
def zb_HumidifierSetpointPrecision 0xfda00009
def zb_DehumidifierSetpointMin 0xfda0000a
def zb_DehumidifierSetpointMax 0xfda0000b
def zb_DehumidifierSetpoint 0xfda0000c
def zb_DehumidifierSetpointScale 0xfda0000d
def zb_DehumidifierSetpointPrecision 0xfda0000e
def zb_AutoSetpointMin 0xfda0000f
def zb_AutoSetpointMax 0xfda00010
def zb_AutoSetpoint 0xfda00011
def zb_AutoSetpointScale 0xfda00012
def zb_AutoSetpointPrecision 0xfda00013

def humidity_control_setpoint_humidify_exists (e'zwHUMIDITY_CONTROL_SETPOINT_TYPE[1])
def humidity_control_setpoint_dehumidify_exists (e'zwHUMIDITY_CONTROL_SETPOINT_TYPE[2])
def humidity_control_setpoint_auto_exists (e'zwHUMIDITY_CONTROL_SETPOINT_TYPE[3])


scope 0 chain_reaction(0) {
//// Setpoints

// Humidifier
r'zb_HumidifierSetpoint =
if (humidity_control_setpoint_humidify_exists)
r'zwHUMIDITY_CONTROL_SETPOINT_TYPE[1].zwHUMIDITY_CONTROL_SETPOINT_VALUE
undefined
r'zb_HumidifierSetpointMin =
if (humidity_control_setpoint_humidify_exists)
r'zwHUMIDITY_CONTROL_SETPOINT_TYPE[1].zwHUMIDITY_CONTROL_SETPOINT_MIN_VALUE
undefined
r'zb_HumidifierSetpointMax =
if (humidity_control_setpoint_humidify_exists)
r'zwHUMIDITY_CONTROL_SETPOINT_TYPE[1].zwHUMIDITY_CONTROL_SETPOINT_MAX_VALUE
undefined
r'zb_HumidifierSetpointScale =
if (humidity_control_setpoint_humidify_exists)
r'zwHUMIDITY_CONTROL_SETPOINT_TYPE[1].zwHUMIDITY_CONTROL_SETPOINT_VALUE_SCALE
undefined
r'zb_HumidifierSetpointPrecision =
if (humidity_control_setpoint_humidify_exists)
r'zwHUMIDITY_CONTROL_SETPOINT_TYPE[1].zwHUMIDITY_CONTROL_SETPOINT_VALUE_PRECISION
undefined

// Humidifier
r'zb_DehumidifierSetpoint =
if (humidity_control_setpoint_dehumidify_exists)
r'zwHUMIDITY_CONTROL_SETPOINT_TYPE[2].zwHUMIDITY_CONTROL_SETPOINT_VALUE
undefined
r'zb_DehumidifierSetpointMin =
if (humidity_control_setpoint_dehumidify_exists)
r'zwHUMIDITY_CONTROL_SETPOINT_TYPE[2].zwHUMIDITY_CONTROL_SETPOINT_MIN_VALUE
undefined
r'zb_DehumidifierSetpointMax =
if (humidity_control_setpoint_dehumidify_exists)
r'zwHUMIDITY_CONTROL_SETPOINT_TYPE[2].zwHUMIDITY_CONTROL_SETPOINT_MAX_VALUE
undefined
r'zb_DehumidifierSetpointScale =
if (humidity_control_setpoint_dehumidify_exists)
r'zwHUMIDITY_CONTROL_SETPOINT_TYPE[2].zwHUMIDITY_CONTROL_SETPOINT_VALUE_SCALE
undefined
r'zb_DehumidifierSetpointPrecision =
if (humidity_control_setpoint_dehumidify_exists)
r'zwHUMIDITY_CONTROL_SETPOINT_TYPE[2].zwHUMIDITY_CONTROL_SETPOINT_VALUE_PRECISION
undefined

// Humidifier
r'zb_AutoSetpoint =
if (humidity_control_setpoint_auto_exists)
r'zwHUMIDITY_CONTROL_SETPOINT_TYPE[2].zwHUMIDITY_CONTROL_SETPOINT_VALUE
undefined
r'zb_AutoSetpointMin =
if (humidity_control_setpoint_auto_exists)
r'zwHUMIDITY_CONTROL_SETPOINT_TYPE[2].zwHUMIDITY_CONTROL_SETPOINT_MIN_VALUE
undefined
r'zb_AutoSetpointMax =
if (humidity_control_setpoint_auto_exists)
r'zwHUMIDITY_CONTROL_SETPOINT_TYPE[2].zwHUMIDITY_CONTROL_SETPOINT_MAX_VALUE
undefined
r'zb_AutoSetpointScale =
if (humidity_control_setpoint_auto_exists)
r'zwHUMIDITY_CONTROL_SETPOINT_TYPE[2].zwHUMIDITY_CONTROL_SETPOINT_VALUE_SCALE
undefined
r'zb_AutoSetpointPrecision =
if (humidity_control_setpoint_auto_exists)
r'zwHUMIDITY_CONTROL_SETPOINT_TYPE[2].zwHUMIDITY_CONTROL_SETPOINT_VALUE_PRECISION
undefined

// Supported setpoints
r'zb_SupportedSetPoints = r'zwHUMIDITY_CONTROL_SUPPORTED_SETPOINT_SUPPORTED_TYPES

//// State
r'zb_CurrentState = r'zwHUMIDITY_CONTROL_OPERATING_STATE

//// Mode
r'zb_ReportingMode = r'zwHUMIDITY_CONTROL_SUPPORTED_MODES
// Since it is a writable attribute we need to update it this way too
r'zwHUMIDITY_CONTROL_SUPPORTED_MODES = r'zb_ReportingMode

r'zb_SupportedReportingMode = r'zwHUMIDITY_CONTROL_MODE
}

Expand Up @@ -14,7 +14,9 @@ add_library(
src/zcl_cluster_servers_helpers.cpp
src/zcl_OTA_cluster_server.cpp
src/zcl_rf_telemetry_cluster_server.c
src/zcl_scenes_cluster_server.cpp)
src/zcl_scenes_cluster_server.cpp
src/humidity_control_cluster_server.c
)

target_include_directories(
zcl_cluster_servers
Expand Down
@@ -0,0 +1,133 @@

/******************************************************************************
* # License
* <b>Copyright 2024 Silicon Laboratories Inc. www.silabs.com</b>
******************************************************************************
* The licensor of this software is Silicon Laboratories Inc. Your use of this
* software is governed by the terms of Silicon Labs Master Software License
* Agreement (MSLA) available at
* www.silabs.com/about-us/legal/master-software-license-agreement. This
* software is distributed to you in Source Code format and is governed by the
* sections of the MSLA applicable to Source Code.
*
*****************************************************************************/
// Includes from this component
#include "humidity_control_cluster_server.h"

// Includes from Unify
#include "sl_log.h"
#include "sl_status.h"
#include "attribute_store_helper.h"
#include "zpc_attribute_store_network_helper.h"
#include "zwave_command_class_humidity_control_types.h"

#include "attribute_store_defined_attribute_types.h"
#include "unify_dotdot_defined_attribute_types.h"
#include "unify_dotdot_attribute_store.h"
#include "unify_dotdot_attribute_store_node_state.h"

// Includes from auto-generated files
#include "dotdot_mqtt.h"

// Setup Log ID
#define LOG_TAG "humidity_control_cluster_server"

sl_status_t zwave_humidity_control_mode_set(
dotdot_unid_t unid,
dotdot_endpoint_id_t endpoint,
uic_mqtt_dotdot_callback_call_type_t call_type,
ModeType mode)
{
attribute_store_node_t endpoint_node
= attribute_store_network_helper_get_endpoint_node(unid, endpoint);

attribute_store_node_t current_mode_node
= attribute_store_get_first_child_by_type(
endpoint_node,
ATTRIBUTE_COMMAND_CLASS_HUMIDITY_CONTROL_MODE_CURRENT_MODE);

// First check the call type. If this is a support check support call,
// we check the attributes
if (call_type == UIC_MQTT_DOTDOT_CALLBACK_TYPE_SUPPORT_CHECK) {
// Check user option automatic_deduction_of_supported_commands
return attribute_store_node_exists(current_mode_node) ? SL_STATUS_OK
: SL_STATUS_FAIL;
}

humidity_control_mode_t mode_value = mode;
return attribute_store_set_desired(current_mode_node,
&mode_value,
sizeof(mode_value));
}

sl_status_t zwave_humidity_control_setpoint_set(
dotdot_unid_t unid,
dotdot_endpoint_id_t endpoint,
uic_mqtt_dotdot_callback_call_type_t call_type,
SetpointType type,
uint8_t precision,
uint8_t scale,
int32_t value)
{
// First check the call type. This command have too many requirements
// so we support it by default
if (call_type == UIC_MQTT_DOTDOT_CALLBACK_TYPE_SUPPORT_CHECK) {
return SL_STATUS_OK;
}

attribute_store_node_t endpoint_node
= attribute_store_network_helper_get_endpoint_node(unid, endpoint);

humidity_control_setpoint_type_t setpoint_type = type;

attribute_store_node_t setpoint_type_node
= attribute_store_get_node_child_by_value(
endpoint_node,
ATTRIBUTE_COMMAND_CLASS_HUMIDITY_CONTROL_SETPOINT_TYPE,
REPORTED_ATTRIBUTE,
&setpoint_type,
sizeof(setpoint_type),
0);

if (setpoint_type == ATTRIBUTE_STORE_INVALID_NODE) {
sl_log_warning(LOG_TAG,
"Can't find humidity setpoint type %d",
setpoint_type);
return SL_STATUS_FAIL;
}

attribute_store_set_child_reported(
setpoint_type_node,
ATTRIBUTE_COMMAND_CLASS_HUMIDITY_CONTROL_SETPOINT_VALUE_PRECISION,
&precision,
sizeof(precision));

attribute_store_set_child_reported(
setpoint_type_node,
ATTRIBUTE_COMMAND_CLASS_HUMIDITY_CONTROL_SETPOINT_VALUE_SCALE,
&scale,
sizeof(scale));

return attribute_store_set_child_desired(
setpoint_type_node,
ATTRIBUTE_COMMAND_CLASS_HUMIDITY_CONTROL_SETPOINT_VALUE,
&value,
sizeof(value));
}

///////////////////////////////////////////////////////////////////////////////
// Init and teardown functions
///////////////////////////////////////////////////////////////////////////////
sl_status_t humidity_control_cluster_server_init()
{
sl_log_debug(LOG_TAG, "Humidity Control cluster (ZWave) server initialization");

// Listen to the BASIC Value attribute is created
uic_mqtt_dotdot_z_wave_humidity_control_mode_set_callback_set(
&zwave_humidity_control_mode_set);

uic_mqtt_dotdot_z_wave_humidity_control_setpoint_set_callback_set(
&zwave_humidity_control_setpoint_set);

return SL_STATUS_OK;
}
@@ -0,0 +1,38 @@
/******************************************************************************
* # License
* <b>Copyright 2024 Silicon Laboratories Inc. www.silabs.com</b>
******************************************************************************
* The licensor of this software is Silicon Laboratories Inc. Your use of this
* software is governed by the terms of Silicon Labs Master Software License
* Agreement (MSLA) available at
* www.silabs.com/about-us/legal/master-software-license-agreement. This
* software is distributed to you in Source Code format and is governed by the
* sections of the MSLA applicable to Source Code.
*
*****************************************************************************/

#ifndef HUMIDITY_CONTROL_CLUSTER_SERVER_H
#define HUMIDITY_CONTROL_CLUSTER_SERVER_H

// Generic includes
#include "sl_status.h"

#ifdef __cplusplus
extern "C" {
#endif

/**
* @brief Initialize the FanControl cluster server
*
* @returns true on success
* @returns false on failure
*
*/
sl_status_t humidity_control_cluster_server_init(void);

#ifdef __cplusplus
}
#endif

#endif //HUMIDITY_CONTROL_CLUSTER_SERVER_H
/** @} end humidity_control_cluster_server */
Expand Up @@ -102,4 +102,16 @@ target_add_unittest(
zcl_cluster_servers_fixture_test.c
DEPENDS
unify
zpc_config_mock)
zpc_config_mock)

# Humidity Control Cluster Mapper test
target_add_unittest(
zcl_cluster_servers
NAME
humidity_control_cluster_server_test
SOURCES
humidity_control_cluster_server_test.c
DEPENDS
zpc_attribute_store_test_helper
uic_dotdot_mqtt_mock
unify_dotdot_attribute_store)

0 comments on commit 85c7c15

Please sign in to comment.