Matter Concentration Measurement Cluster Issue

Hello,

I am trying to add different ConcentrationMeasurement cluster types to my application (CarbonDioxide, VOC, Pm1, etc.) but have an issue with zap-gui not saving the feature flags for the attributes in these clusters. If I enable any feature flag, the required attributes are enabled. When I save the zap file and re-open in zap-gui, the attributes are still enabled, but the feature flags have been disabled. With the feature flags disabled, I believe this is causing an issue with the discovery and function of these attributes within my matter controller (Home Assistant).

The code I have is based on the air-quality-sensor-app, where I have an Init() function to register and configure the clusters (TVOC only at the moment). This is slightly different from what was recommended in this ticket, where an emberAfClusterInitCallback function is apparently needed. I did find something similar for concentration-measurement-instances but those callbacks are effectively the same as the Init() function in the air-quality-sensor-app linked above. 

I think the way I am registering and initializing the new clusters is correct but don't really know. This is my first exposure to code-driven clusters and I'm finding the documentation on how to use them difficult at best.

Is the issue I am facing due to zap-gui not saving the feature flags? If not, am I missing something along the lines of a callback as in the ticket regarding Electrical Power Measurement?

Thanks for the support
Patrick


SDK Version: NCS v3.2.0
Zap Version: 2025.10.23

Errors:

<err> chip: [DMG]Fail to retrieve data, roll back and encode status on clusterId: 0x0000_0003, attributeId: 0x0000_0000err = 501
<err> chip: [DMG]Fail to retrieve data, roll back and encode status on clusterId: 0x0000_0003, attributeId: 0x0000_0001err = 501
<err> chip: [DMG]Fail to retrieve data, roll back and encode status on clusterId: 0x0000_0003, attributeId: 0x0000_FFFCerr = 501
<err> chip: [DMG]Fail to retrieve data, roll back and encode status on clusterId: 0x0000_0003, attributeId: 0x0000_FFFDerr = 501
<err> chip: [DMG]Fail to retrieve data, roll back and encode status on clusterId: 0x0000_005B, attributeId: 0x0000_0000err = 501
<err> chip: [DMG]Fail to retrieve data, roll back and encode status on clusterId: 0x0000_005B, attributeId: 0x0000_FFFCerr = 501
<err> chip: [DMG]Fail to retrieve data, roll back and encode status on clusterId: 0x0000_040D, attributeId: 0x0000_0000err = 501
<err> chip: [DMG]Fail to retrieve data, roll back and encode status on clusterId: 0x0000_040D, attributeId: 0x0000_0001err = 501
<err> chip: [DMG]Fail to retrieve data, roll back and encode status on clusterId: 0x0000_040D, attributeId: 0x0000_0002err = 501
<err> chip: [DMG]Fail to retrieve data, roll back and encode status on clusterId: 0x0000_040D, attributeId: 0x0000_0003err = 501
<err> chip: [DMG]Fail to retrieve data, roll back and encode status on clusterId: 0x0000_040D, attributeId: 0x0000_0004err = 501
<err> chip: [DMG]Fail to retrieve data, roll back and encode status on clusterId: 0x0000_040D, attributeId: 0x0000_0005err = 501
<err> chip: [DMG]Fail to retrieve data, roll back and encode status on clusterId: 0x0000_040D, attributeId: 0x0000_0006err = 501
<err> chip: [DMG]Fail to retrieve data, roll back and encode status on clusterId: 0x0000_040D, attributeId: 0x0000_0008err = 501
<err> chip: [DMG]Fail to retrieve data, roll back and encode status on clusterId: 0x0000_040D, attributeId: 0x0000_0009err = 501
<err> chip: [DMG]Fail to retrieve data, roll back and encode status on clusterId: 0x0000_040D, attributeId: 0x0000_000Aerr = 501
<inf> chip: [EM]<<< [E:31173i S:49655 M:188192703 (Ack:15725626)] (S) Msg TX from 000000000000001D to 2:000000000001B669 [82B3] [UDP:[fd75:ff7a:79ba:1:901:e191:1def:5268]:41879] --- Type 0001:05 (IM:ReportData) (B:1195)
<inf> chip: [EM]??1 [E:31173i S:49655 M:188192703] (S) Msg Retransmission to 2:000000000001B669 scheduled for 2397ms from now [State:Active II:500 AI:300 AT:4000]
<dbg> chip: LogV: [IN]UDP Message Received packet nb : 9 SrcAddr : fd75:ff7a:79ba:1:901:e191:1def:5268[41879] DestAddr : fd75:ff7a:79ba:1:947f:ded5:c16:aded[5540] Payload Length 42
<inf> chip: [EM]>>> [E:31173i S:49655 M:15725627 (Ack:188192703)] (S) Msg RX from 2:000000000001B669 [82B3] to 000000000000001D --- Type 0001:01 (IM:StatusResponse) (B:42)
<inf> chip: [IM]Received status response, status is 0x00
<err> chip: [DMG]Fail to retrieve data, roll back and encode status on clusterId: 0x0000_040D, attributeId: 0x0000_000Aerr = 501
<err> chip: [DMG]Fail to retrieve data, roll back and encode status on clusterId: 0x0000_040D, attributeId: 0x0000_FFFCerr = 501
<err> chip: [DMG]Fail to retrieve data, roll back and encode status on clusterId: 0x0000_042E, attributeId: 0x0000_0000err = 501
<err> chip: [DMG]Fail to retrieve data, roll back and encode status on clusterId: 0x0000_042E, attributeId: 0x0000_0001err = 501
<err> chip: [DMG]Fail to retrieve data, roll back and encode status on clusterId: 0x0000_042E, attributeId: 0x0000_0002err = 501
<err> chip: [DMG]Fail to retrieve data, roll back and encode status on clusterId: 0x0000_042E, attributeId: 0x0000_0008err = 501
<err> chip: [DMG]Fail to retrieve data, roll back and encode status on clusterId: 0x0000_042E, attributeId: 0x0000_0009err = 501
<err> chip: [DMG]Fail to retrieve data, roll back and encode status on clusterId: 0x0000_042E, attributeId: 0x0000_FFFCerr = 501

AirQualitySensorManager.h

#include "AppProperties.h"
#include "clusters/AirQuality/Enums.h"
#include "lib/core/DataModelTypes.h"
#include "lib/support/BitMask.h"
#include <cstdint>
#include <app/clusters/air-quality-server/air-quality-server.h>
#include <app/clusters/concentration-measurement-server/concentration-measurement-cluster-objects.h>
#include <app/clusters/concentration-measurement-server/concentration-measurement-server.h>
#include <clusters/CarbonDioxideConcentrationMeasurement/ClusterId.h>

using namespace ::chip;
using namespace ::chip::app;
using namespace ::chip::app::Clusters;

class AirQualitySensorManager
{
  public:
    AirQualitySensorManager(const AirQualitySensorManager &) = delete;
    AirQualitySensorManager(const AirQualitySensorManager &&) = delete;
    AirQualitySensorManager &operator=(const AirQualitySensorManager &) = delete;

    static void InitInstance(EndpointId endpointId = 1)
    {
        static AirQualitySensorManager instance(endpointId);
        mInstance = &instance;
        static bool mInitialized = false;
        if (!mInitialized) {
          mInstance->Init();
          mInitialized = true;
        }
    }

    auto&& GetVocInstance() { return mTvocConcentrationMeasurementInstance;}

    static AirQualitySensorManager * GetInstance() { return mInstance; }
    void Init();

  private:
    inline static AirQualitySensorManager *mInstance = nullptr;
    EndpointId mEndpointId;
    ConcentrationMeasurement::Instance<true, true, true, true, true, true> mTvocConcentrationMeasurementInstance;
    AirQualitySensorManager(EndpointId endpointId)
        : mEndpointId(endpointId), 
          mTvocConcentrationMeasurementInstance(App::Properties::externalSensor1EndpointId,
              TotalVolatileOrganicCompoundsConcentrationMeasurement::Id,
              ConcentrationMeasurement::MeasurementMediumEnum::kAir,
              ConcentrationMeasurement::MeasurementUnitEnum::kPpm)
    {};
};

AirQualitySensorManager.cpp

#include "AqsManager.h"
#include "LogProxy.h"
#include <cstdio>

using namespace chip;
using namespace chip::app;
using namespace chip::app::DataModel;
using namespace chip::app::Clusters;
using namespace chip::app::Clusters::ConcentrationMeasurement;
using namespace chip::app::Clusters::AirQuality;

void AirQualitySensorManager::Init()
{
    // TVOC
    mTvocConcentrationMeasurementInstance.Init();
    mTvocConcentrationMeasurementInstance.SetMinMeasuredValue(MakeNullable(0.0f));
    mTvocConcentrationMeasurementInstance.SetMaxMeasuredValue(MakeNullable(65000.0f));
    mTvocConcentrationMeasurementInstance.SetMeasuredValue(MakeNullable(0.0f));
    mTvocConcentrationMeasurementInstance.SetPeakMeasuredValue(MakeNullable(1.0f));
    mTvocConcentrationMeasurementInstance.SetPeakMeasuredValueWindow(320);
    mTvocConcentrationMeasurementInstance.SetAverageMeasuredValue(MakeNullable(1.0f));
    mTvocConcentrationMeasurementInstance.SetAverageMeasuredValueWindow(320);
    mTvocConcentrationMeasurementInstance.SetUncertainty(0.0f);
    mTvocConcentrationMeasurementInstance.SetLevelValue(LevelValueEnum::kLow);

}

Usage would look something like this:

auto& vocInstance = AirQualitySensorManager::GetInstance()->GetVocInstance()
vocInstance.SetMeasuredValue(500.0f);

Parents Reply Children
No Data
Related