How to resetting Matter TotalOperationalHours to 0 on Factory Reset

Dear Nordic Support Team,

Hope this email finds you well. I am currently developing a Matter-enabled device using the Nordic nRF Connect SDK, and I’ve encountered a question regarding the General Diagnostics Cluster (per Matter specification) that I hope you can assist with.

Specifically, I need to reset the value of the TotalOperationalHours attribute (Attribute ID: 0x0003, as defined in the Matter General Diagnostics Cluster) to 0 when the device performs a factory reset. This ensures the operational hour count starts fresh after a factory reset, which is critical for accurate device usage tracking in our product.
I have the following key questions:
In the Nordic nRF Connect SDK, which specific API or function should I call to directly set the TotalOperationalHours attribute value to 0?
Parents Reply Children
  • Hi,

    I tested with both v3.0.1 and v3.1.0.

    I did some pretty simple tests where I added functionality that reads and increments the TotalOperationalHours when button 4 is pressed. I added it in ButtonEventHandler() in the light switch sample:

    uint32_t newTotalOperationalHours = 0;
    
    void AppTask::ButtonEventHandler(Nrf::ButtonState state, Nrf::ButtonMask hasChanged)
    {
    	if ((APPLICATION_BUTTON_MASK & state & hasChanged)) {
    		LOG_INF("Button has been pressed, keep in this state for at least 500 ms to change light sensitivity of bound lighting devices.");
    		Instance().StartTimer(Timer::DimmerTrigger, kDimmerTriggeredTimeout);
    	} else if ((APPLICATION_BUTTON_MASK & hasChanged)) {
    		Nrf::PostTask([] { DimmerTriggerEventHandler(); });
    #ifdef CONFIG_CHIP_ICD_UAT_SUPPORT
    	} else if ((UAT_BUTTON_MASK & state & hasChanged)) {
    		LOG_INF("ICD UserActiveMode has been triggered.");
    		Server::GetInstance().GetICDManager().OnNetworkActivity();
    #endif
    	}
    	if ((DK_BTN4_MSK & state & hasChanged)) {
    		uint32_t totalOperationalHours;
    		LOG_INF("Button 4 pressed.");
    		ConfigurationMgr().GetTotalOperationalHours(totalOperationalHours);
    		LOG_INF("TotalOperationalHours: %u", totalOperationalHours);
    		newTotalOperationalHours = totalOperationalHours + 1;
    		LOG_INF("TotalOperationalHours after increment: %u", newTotalOperationalHours);
    		ConfigurationMgr().StoreTotalOperationalHours(newTotalOperationalHours);
    	}
    }

    I tested by pressing button 4 to read and increment TotalOperationalHours. I also verified the value with chip-tool. Then I performed a factory reset by holding button 1. After the device restarted, I checked TotalOperationalHours again, and it was reset to 0.

    Best regards,
    Marte

Related