Modify the default attributes of the Zigbee cluster

How to modify the default attributes of the Zigbee cluster?

1. In Application Code

  • Each Zigbee cluster is represented by a class (e.g., CZigBeeClusterOnOff, CZigBeeClusterTemperatureMeasurement).
  • You can set or override default attribute values in your application’s initialization or reset logic.
  • For example, to restore or modify default attributes, you might use functions like RestoreDefaults() or Restore[Cluster]AttributeDefaults() in your application code.

Example:

void CLightApplication::RestoreDefaults(const bool bRemoveAllReferences)
{    
     // Reset Basic cluster attributes to defaults
        RestoreBasicAttributeDefaults();    
     // Reset Identify cluster attributes to defaults
        RestoreIdentifyAttributeDefaults();    
     // Reset Scene, On-Off, Leveling, etc.
        RestoreSceneAttributeDefaults();    
        RestoreOnOffAttributeDefaults();    
        RestoreLevelingAttributeDefaults();
}

You can modify the implementation of these functions to set your desired default values for each attribute.


2. At Attribute Level

  • Each cluster class has attribute members (e.g., m_OnOff for On/Off).
  • You can set their default values in the class constructor or in the reset-to-factory-defaults logic.

Example:

CZigBeeClusterOnOff::CZigBeeClusterOnOff(...)
{    
      m_bOnOff = false; // Set default OnOff state
}

Or use SetAttributeValue() to programmatically change an attribute at runtime.

//Method one
ASSERT(pCurrentScene);    
m_scenes.SetAttributeValue(*pCurrentScene, &m_scenes.m_nCurrentScene, sizeof(m_scenes.m_nCurrentScene));

//Method two
/** @brief Instance of on-off cluster */
CZigBeeClusterOnOffEx m_onOff;
void CLightApplication::SetOnOffAttribute(const bool bOnOff, const bool bPowerup)
{    
     // set on-off attribute    
     m_onOff.SetValue(bOnOff, bPowerup);
}

3. Via Persistent Storage (PSB/NVM)

  • You can define default attribute values in the PSB XML file.
  • When the device is reset or starts up, it will load these defaults from NVM.
  • This is useful for attributes that should persist across reboots or factory resets.

4. Reset to Factory Defaults Command

  • The Zigbee Basic cluster supports a “Reset to Factory Defaults” command.
  • When this command is received, your application should reset all supported cluster attributes to their default values as defined in your logic or PSB.
1 Like