3737
3838#define LOG_TAG "zwave_command_class_switch_color"
3939
40- [[ maybe_unused ]]
41- static void set_desired_duration ( attribute_store_node_t state_node ,
42- uint32_t duration )
40+ static void set_duration ( attribute_store_node_t state_node ,
41+ attribute_store_node_value_state_t state ,
42+ uint32_t duration )
4343{
4444 attribute_store_node_t duration_node
4545 = attribute_store_get_first_child_by_type (
4646 state_node ,
4747 ATTRIBUTE_COMMAND_CLASS_SWITCH_COLOR_DURATION );
4848
4949 attribute_store_set_node_attribute_value (duration_node ,
50- DESIRED_ATTRIBUTE ,
51- (uint8_t * )& duration ,
52- sizeof (duration ));
53- }
54-
55- static void set_reported_duration (attribute_store_node_t state_node ,
56- uint32_t duration )
57- {
58- attribute_store_node_t duration_node
59- = attribute_store_get_first_child_by_type (
60- state_node ,
61- ATTRIBUTE_COMMAND_CLASS_SWITCH_COLOR_DURATION );
62-
63- attribute_store_set_node_attribute_value (duration_node ,
64- REPORTED_ATTRIBUTE ,
50+ state ,
6551 (uint8_t * )& duration ,
6652 sizeof (duration ));
6753}
@@ -80,15 +66,7 @@ static void
8066 while (component_node != ATTRIBUTE_STORE_INVALID_NODE ) {
8167 index += 1 ;
8268
83- attribute_store_node_t duration_node
84- = attribute_store_get_first_child_by_type (
85- component_node ,
86- ATTRIBUTE_COMMAND_CLASS_SWITCH_COLOR_DURATION );
87-
88- attribute_store_set_node_attribute_value (duration_node ,
89- value_state ,
90- (uint8_t * )& duration ,
91- sizeof (duration ));
69+ set_duration (component_node , value_state , duration );
9270
9371 component_node = attribute_store_get_node_child_by_type (
9472 state_node ,
@@ -166,7 +144,7 @@ static void
166144 state_node ,
167145 ATTRIBUTE_COMMAND_CLASS_SWITCH_COLOR_VALUE ,
168146 & attribute_store_undefine_desired );
169- set_reported_duration (state_node , 0 );
147+ set_duration (state_node , REPORTED_ATTRIBUTE , 0 );
170148 attribute_store_undefine_desired (duration_node );
171149 break ;
172150
0 commit comments