text: /*
   *
   *    Copyright (c) 2021 Project CHIP Authors
   *
   *    Licensed under the Apache License, Version 2.0 (the "License");
   *    you may not use this file except in compliance with the License.
   *    You may obtain a copy of the License at
   *
   *        http://www.apache.org/licenses/LICENSE-2.0
   *
   *    Unless required by applicable law or agreed to in writing, software
   *    distributed under the License is distributed on an "AS IS" BASIS,
   *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   *    See the License for the specific language governing permissions and
   *    limitations under the License.
   */
  
  // THIS FILE IS GENERATED BY ZAP
  #include "CHIPClusters.h"
  
  #include <cstdint>
  
  #include <app/chip-zcl-zpro-codec-api.h>
  #include <lib/support/Span.h>
  
  namespace chip {
  namespace Controller {
  
  // TODO(#4502): onCompletion is not used by IM for now.
  // TODO(#4503): length should be passed to commands when byte string is in argument list.
  // TODO(#4503): Commands should take group id as an argument.
  
  // AccountLogin Cluster Commands
  CHIP_ERROR AccountLoginCluster::GetSetupPIN(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback,
                                              chip::ByteSpan tempAccountIdentifier)
  {
      VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
  
      app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kGetSetupPINCommandId,
                                           (chip::app::CommandPathFlags::kEndpointIdValid) };
      app::Command * ZCLcommand        = mDevice->GetCommandSender();
  
      ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams));
  
      TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter();
      uint8_t argSeqNumber    = 0;
      // tempAccountIdentifier: charString
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), tempAccountIdentifier));
  
      ReturnErrorOnFailure(ZCLcommand->FinishCommand());
  
      // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate.
      mDevice->AddIMResponseHandler(onSuccessCallback, onFailureCallback);
  
      return mDevice->SendCommands();
  }
  
  CHIP_ERROR AccountLoginCluster::Login(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback,
                                        chip::ByteSpan tempAccountIdentifier, chip::ByteSpan setupPIN)
  {
      VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
  
      app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kLoginCommandId,
                                           (chip::app::CommandPathFlags::kEndpointIdValid) };
      app::Command * ZCLcommand        = mDevice->GetCommandSender();
  
      ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams));
  
      TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter();
      uint8_t argSeqNumber    = 0;
      // tempAccountIdentifier: charString
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), tempAccountIdentifier));
      // setupPIN: charString
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), setupPIN));
  
      ReturnErrorOnFailure(ZCLcommand->FinishCommand());
  
      // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate.
      mDevice->AddIMResponseHandler(onSuccessCallback, onFailureCallback);
  
      return mDevice->SendCommands();
  }
  
  // AccountLogin Cluster Attributes
  CHIP_ERROR AccountLoginCluster::DiscoverAttributes(Callback::Cancelable * onSuccessCallback,
                                                     Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeAccountLoginClusterDiscoverAttributes(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  CHIP_ERROR AccountLoginCluster::ReadAttributeClusterRevision(Callback::Cancelable * onSuccessCallback,
                                                               Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeAccountLoginClusterReadClusterRevisionAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  // ApplicationBasic Cluster Commands
  // ApplicationBasic Cluster Attributes
  CHIP_ERROR ApplicationBasicCluster::DiscoverAttributes(Callback::Cancelable * onSuccessCallback,
                                                         Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeApplicationBasicClusterDiscoverAttributes(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  CHIP_ERROR ApplicationBasicCluster::ReadAttributeVendorName(Callback::Cancelable * onSuccessCallback,
                                                              Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeApplicationBasicClusterReadVendorNameAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR ApplicationBasicCluster::ReadAttributeVendorId(Callback::Cancelable * onSuccessCallback,
                                                            Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeApplicationBasicClusterReadVendorIdAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR ApplicationBasicCluster::ReadAttributeApplicationName(Callback::Cancelable * onSuccessCallback,
                                                                   Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeApplicationBasicClusterReadApplicationNameAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR ApplicationBasicCluster::ReadAttributeProductId(Callback::Cancelable * onSuccessCallback,
                                                             Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeApplicationBasicClusterReadProductIdAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR ApplicationBasicCluster::ReadAttributeApplicationId(Callback::Cancelable * onSuccessCallback,
                                                                 Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeApplicationBasicClusterReadApplicationIdAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR ApplicationBasicCluster::ReadAttributeCatalogVendorId(Callback::Cancelable * onSuccessCallback,
                                                                   Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeApplicationBasicClusterReadCatalogVendorIdAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR ApplicationBasicCluster::ReadAttributeApplicationSatus(Callback::Cancelable * onSuccessCallback,
                                                                    Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeApplicationBasicClusterReadApplicationSatusAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR ApplicationBasicCluster::ReadAttributeClusterRevision(Callback::Cancelable * onSuccessCallback,
                                                                   Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeApplicationBasicClusterReadClusterRevisionAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  // ApplicationLauncher Cluster Commands
  CHIP_ERROR ApplicationLauncherCluster::LaunchApp(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback,
                                                   chip::ByteSpan data, uint16_t catalogVendorId, chip::ByteSpan applicationId)
  {
      VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
  
      app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kLaunchAppCommandId,
                                           (chip::app::CommandPathFlags::kEndpointIdValid) };
      app::Command * ZCLcommand        = mDevice->GetCommandSender();
  
      ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams));
  
      TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter();
      uint8_t argSeqNumber    = 0;
      // data: charString
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), data));
      // catalogVendorId: int16u
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), catalogVendorId));
      // applicationId: charString
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), applicationId));
  
      ReturnErrorOnFailure(ZCLcommand->FinishCommand());
  
      // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate.
      mDevice->AddIMResponseHandler(onSuccessCallback, onFailureCallback);
  
      return mDevice->SendCommands();
  }
  
  // ApplicationLauncher Cluster Attributes
  CHIP_ERROR ApplicationLauncherCluster::DiscoverAttributes(Callback::Cancelable * onSuccessCallback,
                                                            Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeApplicationLauncherClusterDiscoverAttributes(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  CHIP_ERROR ApplicationLauncherCluster::ReadAttributeApplicationLauncherList(Callback::Cancelable * onSuccessCallback,
                                                                              Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand =
          encodeApplicationLauncherClusterReadApplicationLauncherListAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR ApplicationLauncherCluster::ReadAttributeClusterRevision(Callback::Cancelable * onSuccessCallback,
                                                                      Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeApplicationLauncherClusterReadClusterRevisionAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  // AudioOutput Cluster Commands
  CHIP_ERROR AudioOutputCluster::RenameOutput(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback,
                                              uint8_t index, chip::ByteSpan name)
  {
      VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
  
      app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kRenameOutputCommandId,
                                           (chip::app::CommandPathFlags::kEndpointIdValid) };
      app::Command * ZCLcommand        = mDevice->GetCommandSender();
  
      ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams));
  
      TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter();
      uint8_t argSeqNumber    = 0;
      // index: int8u
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), index));
      // name: charString
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), name));
  
      ReturnErrorOnFailure(ZCLcommand->FinishCommand());
  
      // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate.
      mDevice->AddIMResponseHandler(onSuccessCallback, onFailureCallback);
  
      return mDevice->SendCommands();
  }
  
  CHIP_ERROR AudioOutputCluster::SelectOutput(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback,
                                              uint8_t index)
  {
      VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
  
      app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kSelectOutputCommandId,
                                           (chip::app::CommandPathFlags::kEndpointIdValid) };
      app::Command * ZCLcommand        = mDevice->GetCommandSender();
  
      ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams));
  
      TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter();
      uint8_t argSeqNumber    = 0;
      // index: int8u
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), index));
  
      ReturnErrorOnFailure(ZCLcommand->FinishCommand());
  
      // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate.
      mDevice->AddIMResponseHandler(onSuccessCallback, onFailureCallback);
  
      return mDevice->SendCommands();
  }
  
  // AudioOutput Cluster Attributes
  CHIP_ERROR AudioOutputCluster::DiscoverAttributes(Callback::Cancelable * onSuccessCallback,
                                                    Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeAudioOutputClusterDiscoverAttributes(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  CHIP_ERROR AudioOutputCluster::ReadAttributeAudioOutputList(Callback::Cancelable * onSuccessCallback,
                                                              Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeAudioOutputClusterReadAudioOutputListAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR AudioOutputCluster::ReadAttributeClusterRevision(Callback::Cancelable * onSuccessCallback,
                                                              Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeAudioOutputClusterReadClusterRevisionAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  // BarrierControl Cluster Commands
  CHIP_ERROR BarrierControlCluster::BarrierControlGoToPercent(Callback::Cancelable * onSuccessCallback,
                                                              Callback::Cancelable * onFailureCallback, uint8_t percentOpen)
  {
      VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
  
      app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kBarrierControlGoToPercentCommandId,
                                           (chip::app::CommandPathFlags::kEndpointIdValid) };
      app::Command * ZCLcommand        = mDevice->GetCommandSender();
  
      ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams));
  
      TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter();
      uint8_t argSeqNumber    = 0;
      // percentOpen: int8u
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), percentOpen));
  
      ReturnErrorOnFailure(ZCLcommand->FinishCommand());
  
      // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate.
      mDevice->AddIMResponseHandler(onSuccessCallback, onFailureCallback);
  
      return mDevice->SendCommands();
  }
  
  CHIP_ERROR BarrierControlCluster::BarrierControlStop(Callback::Cancelable * onSuccessCallback,
                                                       Callback::Cancelable * onFailureCallback)
  {
      VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
  
      app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kBarrierControlStopCommandId,
                                           (chip::app::CommandPathFlags::kEndpointIdValid) };
      app::Command * ZCLcommand        = mDevice->GetCommandSender();
  
      ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams));
  
      // Command takes no arguments.
  
      ReturnErrorOnFailure(ZCLcommand->FinishCommand());
  
      // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate.
      mDevice->AddIMResponseHandler(onSuccessCallback, onFailureCallback);
  
      return mDevice->SendCommands();
  }
  
  // BarrierControl Cluster Attributes
  CHIP_ERROR BarrierControlCluster::DiscoverAttributes(Callback::Cancelable * onSuccessCallback,
                                                       Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeBarrierControlClusterDiscoverAttributes(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  CHIP_ERROR BarrierControlCluster::ReadAttributeBarrierMovingState(Callback::Cancelable * onSuccessCallback,
                                                                    Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeBarrierControlClusterReadBarrierMovingStateAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR BarrierControlCluster::ReadAttributeBarrierSafetyStatus(Callback::Cancelable * onSuccessCallback,
                                                                     Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeBarrierControlClusterReadBarrierSafetyStatusAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR BarrierControlCluster::ReadAttributeBarrierCapabilities(Callback::Cancelable * onSuccessCallback,
                                                                     Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeBarrierControlClusterReadBarrierCapabilitiesAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR BarrierControlCluster::ReadAttributeBarrierPosition(Callback::Cancelable * onSuccessCallback,
                                                                 Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeBarrierControlClusterReadBarrierPositionAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR BarrierControlCluster::ReadAttributeClusterRevision(Callback::Cancelable * onSuccessCallback,
                                                                 Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeBarrierControlClusterReadClusterRevisionAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  // Basic Cluster Commands
  CHIP_ERROR BasicCluster::MfgSpecificPing(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback)
  {
      VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
  
      app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kMfgSpecificPingCommandId,
                                           (chip::app::CommandPathFlags::kEndpointIdValid) };
      app::Command * ZCLcommand        = mDevice->GetCommandSender();
  
      ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams));
  
      // Command takes no arguments.
  
      ReturnErrorOnFailure(ZCLcommand->FinishCommand());
  
      // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate.
      mDevice->AddIMResponseHandler(onSuccessCallback, onFailureCallback);
  
      return mDevice->SendCommands();
  }
  
  // Basic Cluster Attributes
  CHIP_ERROR BasicCluster::DiscoverAttributes(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeBasicClusterDiscoverAttributes(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  CHIP_ERROR BasicCluster::ReadAttributeInteractionModelVersion(Callback::Cancelable * onSuccessCallback,
                                                                Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeBasicClusterReadInteractionModelVersionAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR BasicCluster::ReadAttributeVendorName(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeBasicClusterReadVendorNameAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR BasicCluster::ReadAttributeVendorID(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeBasicClusterReadVendorIDAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR BasicCluster::ReadAttributeProductName(Callback::Cancelable * onSuccessCallback,
                                                    Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeBasicClusterReadProductNameAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR BasicCluster::ReadAttributeProductID(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeBasicClusterReadProductIDAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR BasicCluster::ReadAttributeUserLabel(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeBasicClusterReadUserLabelAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR BasicCluster::WriteAttributeUserLabel(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback,
                                                   chip::ByteSpan value)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeBasicClusterWriteUserLabelAttribute(seqNum, mEndpoint, value);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR BasicCluster::ReadAttributeLocation(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeBasicClusterReadLocationAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR BasicCluster::WriteAttributeLocation(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback,
                                                  chip::ByteSpan value)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeBasicClusterWriteLocationAttribute(seqNum, mEndpoint, value);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR BasicCluster::ReadAttributeHardwareVersion(Callback::Cancelable * onSuccessCallback,
                                                        Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeBasicClusterReadHardwareVersionAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR BasicCluster::ReadAttributeHardwareVersionString(Callback::Cancelable * onSuccessCallback,
                                                              Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeBasicClusterReadHardwareVersionStringAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR BasicCluster::ReadAttributeSoftwareVersion(Callback::Cancelable * onSuccessCallback,
                                                        Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeBasicClusterReadSoftwareVersionAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR BasicCluster::ReadAttributeSoftwareVersionString(Callback::Cancelable * onSuccessCallback,
                                                              Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeBasicClusterReadSoftwareVersionStringAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR BasicCluster::ReadAttributeManufacturingDate(Callback::Cancelable * onSuccessCallback,
                                                          Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeBasicClusterReadManufacturingDateAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR BasicCluster::ReadAttributePartNumber(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeBasicClusterReadPartNumberAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR BasicCluster::ReadAttributeProductURL(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeBasicClusterReadProductURLAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR BasicCluster::ReadAttributeProductLabel(Callback::Cancelable * onSuccessCallback,
                                                     Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeBasicClusterReadProductLabelAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR BasicCluster::ReadAttributeSerialNumber(Callback::Cancelable * onSuccessCallback,
                                                     Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeBasicClusterReadSerialNumberAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR BasicCluster::ReadAttributeLocalConfigDisabled(Callback::Cancelable * onSuccessCallback,
                                                            Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeBasicClusterReadLocalConfigDisabledAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR BasicCluster::WriteAttributeLocalConfigDisabled(Callback::Cancelable * onSuccessCallback,
                                                             Callback::Cancelable * onFailureCallback, uint8_t value)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeBasicClusterWriteLocalConfigDisabledAttribute(seqNum, mEndpoint, value);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR BasicCluster::ReadAttributeClusterRevision(Callback::Cancelable * onSuccessCallback,
                                                        Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeBasicClusterReadClusterRevisionAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  // Binding Cluster Commands
  CHIP_ERROR BindingCluster::Bind(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback,
                                  chip::NodeId nodeId, chip::GroupId groupId, chip::EndpointId endpointId, chip::ClusterId clusterId)
  {
      VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
  
      app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kBindCommandId,
                                           (chip::app::CommandPathFlags::kEndpointIdValid) };
      app::Command * ZCLcommand        = mDevice->GetCommandSender();
  
      ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams));
  
      TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter();
      uint8_t argSeqNumber    = 0;
      // nodeId: nodeId
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), nodeId));
      // groupId: groupId
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), groupId));
      // endpointId: endpointId
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), endpointId));
      // clusterId: clusterId
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), clusterId));
  
      ReturnErrorOnFailure(ZCLcommand->FinishCommand());
  
      // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate.
      mDevice->AddIMResponseHandler(onSuccessCallback, onFailureCallback);
  
      return mDevice->SendCommands();
  }
  
  CHIP_ERROR BindingCluster::Unbind(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback,
                                    chip::NodeId nodeId, chip::GroupId groupId, chip::EndpointId endpointId,
                                    chip::ClusterId clusterId)
  {
      VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
  
      app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kUnbindCommandId,
                                           (chip::app::CommandPathFlags::kEndpointIdValid) };
      app::Command * ZCLcommand        = mDevice->GetCommandSender();
  
      ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams));
  
      TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter();
      uint8_t argSeqNumber    = 0;
      // nodeId: nodeId
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), nodeId));
      // groupId: groupId
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), groupId));
      // endpointId: endpointId
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), endpointId));
      // clusterId: clusterId
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), clusterId));
  
      ReturnErrorOnFailure(ZCLcommand->FinishCommand());
  
      // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate.
      mDevice->AddIMResponseHandler(onSuccessCallback, onFailureCallback);
  
      return mDevice->SendCommands();
  }
  
  // Binding Cluster Attributes
  CHIP_ERROR BindingCluster::DiscoverAttributes(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeBindingClusterDiscoverAttributes(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  CHIP_ERROR BindingCluster::ReadAttributeClusterRevision(Callback::Cancelable * onSuccessCallback,
                                                          Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeBindingClusterReadClusterRevisionAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  // ColorControl Cluster Commands
  CHIP_ERROR ColorControlCluster::MoveColor(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback,
                                            int16_t rateX, int16_t rateY, uint8_t optionsMask, uint8_t optionsOverride)
  {
      VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
  
      app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kMoveColorCommandId,
                                           (chip::app::CommandPathFlags::kEndpointIdValid) };
      app::Command * ZCLcommand        = mDevice->GetCommandSender();
  
      ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams));
  
      TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter();
      uint8_t argSeqNumber    = 0;
      // rateX: int16s
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), rateX));
      // rateY: int16s
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), rateY));
      // optionsMask: bitmap8
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), optionsMask));
      // optionsOverride: bitmap8
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), optionsOverride));
  
      ReturnErrorOnFailure(ZCLcommand->FinishCommand());
  
      // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate.
      mDevice->AddIMResponseHandler(onSuccessCallback, onFailureCallback);
  
      return mDevice->SendCommands();
  }
  
  CHIP_ERROR ColorControlCluster::MoveColorTemperature(Callback::Cancelable * onSuccessCallback,
                                                       Callback::Cancelable * onFailureCallback, uint8_t moveMode, uint16_t rate,
                                                       uint16_t colorTemperatureMinimum, uint16_t colorTemperatureMaximum,
                                                       uint8_t optionsMask, uint8_t optionsOverride)
  {
      VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
  
      app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kMoveColorTemperatureCommandId,
                                           (chip::app::CommandPathFlags::kEndpointIdValid) };
      app::Command * ZCLcommand        = mDevice->GetCommandSender();
  
      ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams));
  
      TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter();
      uint8_t argSeqNumber    = 0;
      // moveMode: hueMoveMode
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), moveMode));
      // rate: int16u
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), rate));
      // colorTemperatureMinimum: int16u
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), colorTemperatureMinimum));
      // colorTemperatureMaximum: int16u
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), colorTemperatureMaximum));
      // optionsMask: bitmap8
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), optionsMask));
      // optionsOverride: bitmap8
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), optionsOverride));
  
      ReturnErrorOnFailure(ZCLcommand->FinishCommand());
  
      // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate.
      mDevice->AddIMResponseHandler(onSuccessCallback, onFailureCallback);
  
      return mDevice->SendCommands();
  }
  
  CHIP_ERROR ColorControlCluster::MoveHue(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback,
                                          uint8_t moveMode, uint8_t rate, uint8_t optionsMask, uint8_t optionsOverride)
  {
      VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
  
      app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kMoveHueCommandId,
                                           (chip::app::CommandPathFlags::kEndpointIdValid) };
      app::Command * ZCLcommand        = mDevice->GetCommandSender();
  
      ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams));
  
      TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter();
      uint8_t argSeqNumber    = 0;
      // moveMode: hueMoveMode
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), moveMode));
      // rate: int8u
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), rate));
      // optionsMask: bitmap8
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), optionsMask));
      // optionsOverride: bitmap8
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), optionsOverride));
  
      ReturnErrorOnFailure(ZCLcommand->FinishCommand());
  
      // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate.
      mDevice->AddIMResponseHandler(onSuccessCallback, onFailureCallback);
  
      return mDevice->SendCommands();
  }
  
  CHIP_ERROR ColorControlCluster::MoveSaturation(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback,
                                                 uint8_t moveMode, uint8_t rate, uint8_t optionsMask, uint8_t optionsOverride)
  {
      VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
  
      app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kMoveSaturationCommandId,
                                           (chip::app::CommandPathFlags::kEndpointIdValid) };
      app::Command * ZCLcommand        = mDevice->GetCommandSender();
  
      ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams));
  
      TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter();
      uint8_t argSeqNumber    = 0;
      // moveMode: saturationMoveMode
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), moveMode));
      // rate: int8u
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), rate));
      // optionsMask: bitmap8
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), optionsMask));
      // optionsOverride: bitmap8
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), optionsOverride));
  
      ReturnErrorOnFailure(ZCLcommand->FinishCommand());
  
      // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate.
      mDevice->AddIMResponseHandler(onSuccessCallback, onFailureCallback);
  
      return mDevice->SendCommands();
  }
  
  CHIP_ERROR ColorControlCluster::MoveToColor(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback,
                                              uint16_t colorX, uint16_t colorY, uint16_t transitionTime, uint8_t optionsMask,
                                              uint8_t optionsOverride)
  {
      VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
  
      app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kMoveToColorCommandId,
                                           (chip::app::CommandPathFlags::kEndpointIdValid) };
      app::Command * ZCLcommand        = mDevice->GetCommandSender();
  
      ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams));
  
      TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter();
      uint8_t argSeqNumber    = 0;
      // colorX: int16u
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), colorX));
      // colorY: int16u
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), colorY));
      // transitionTime: int16u
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), transitionTime));
      // optionsMask: bitmap8
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), optionsMask));
      // optionsOverride: bitmap8
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), optionsOverride));
  
      ReturnErrorOnFailure(ZCLcommand->FinishCommand());
  
      // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate.
      mDevice->AddIMResponseHandler(onSuccessCallback, onFailureCallback);
  
      return mDevice->SendCommands();
  }
  
  CHIP_ERROR ColorControlCluster::MoveToColorTemperature(Callback::Cancelable * onSuccessCallback,
                                                         Callback::Cancelable * onFailureCallback, uint16_t colorTemperature,
                                                         uint16_t transitionTime, uint8_t optionsMask, uint8_t optionsOverride)
  {
      VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
  
      app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kMoveToColorTemperatureCommandId,
                                           (chip::app::CommandPathFlags::kEndpointIdValid) };
      app::Command * ZCLcommand        = mDevice->GetCommandSender();
  
      ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams));
  
      TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter();
      uint8_t argSeqNumber    = 0;
      // colorTemperature: int16u
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), colorTemperature));
      // transitionTime: int16u
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), transitionTime));
      // optionsMask: bitmap8
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), optionsMask));
      // optionsOverride: bitmap8
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), optionsOverride));
  
      ReturnErrorOnFailure(ZCLcommand->FinishCommand());
  
      // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate.
      mDevice->AddIMResponseHandler(onSuccessCallback, onFailureCallback);
  
      return mDevice->SendCommands();
  }
  
  CHIP_ERROR ColorControlCluster::MoveToHue(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback,
                                            uint8_t hue, uint8_t direction, uint16_t transitionTime, uint8_t optionsMask,
                                            uint8_t optionsOverride)
  {
      VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
  
      app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kMoveToHueCommandId,
                                           (chip::app::CommandPathFlags::kEndpointIdValid) };
      app::Command * ZCLcommand        = mDevice->GetCommandSender();
  
      ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams));
  
      TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter();
      uint8_t argSeqNumber    = 0;
      // hue: int8u
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), hue));
      // direction: hueDirection
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), direction));
      // transitionTime: int16u
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), transitionTime));
      // optionsMask: bitmap8
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), optionsMask));
      // optionsOverride: bitmap8
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), optionsOverride));
  
      ReturnErrorOnFailure(ZCLcommand->FinishCommand());
  
      // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate.
      mDevice->AddIMResponseHandler(onSuccessCallback, onFailureCallback);
  
      return mDevice->SendCommands();
  }
  
  CHIP_ERROR ColorControlCluster::MoveToHueAndSaturation(Callback::Cancelable * onSuccessCallback,
                                                         Callback::Cancelable * onFailureCallback, uint8_t hue, uint8_t saturation,
                                                         uint16_t transitionTime, uint8_t optionsMask, uint8_t optionsOverride)
  {
      VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
  
      app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kMoveToHueAndSaturationCommandId,
                                           (chip::app::CommandPathFlags::kEndpointIdValid) };
      app::Command * ZCLcommand        = mDevice->GetCommandSender();
  
      ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams));
  
      TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter();
      uint8_t argSeqNumber    = 0;
      // hue: int8u
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), hue));
      // saturation: int8u
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), saturation));
      // transitionTime: int16u
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), transitionTime));
      // optionsMask: bitmap8
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), optionsMask));
      // optionsOverride: bitmap8
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), optionsOverride));
  
      ReturnErrorOnFailure(ZCLcommand->FinishCommand());
  
      // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate.
      mDevice->AddIMResponseHandler(onSuccessCallback, onFailureCallback);
  
      return mDevice->SendCommands();
  }
  
  CHIP_ERROR ColorControlCluster::MoveToSaturation(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback,
                                                   uint8_t saturation, uint16_t transitionTime, uint8_t optionsMask,
                                                   uint8_t optionsOverride)
  {
      VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
  
      app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kMoveToSaturationCommandId,
                                           (chip::app::CommandPathFlags::kEndpointIdValid) };
      app::Command * ZCLcommand        = mDevice->GetCommandSender();
  
      ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams));
  
      TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter();
      uint8_t argSeqNumber    = 0;
      // saturation: int8u
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), saturation));
      // transitionTime: int16u
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), transitionTime));
      // optionsMask: bitmap8
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), optionsMask));
      // optionsOverride: bitmap8
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), optionsOverride));
  
      ReturnErrorOnFailure(ZCLcommand->FinishCommand());
  
      // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate.
      mDevice->AddIMResponseHandler(onSuccessCallback, onFailureCallback);
  
      return mDevice->SendCommands();
  }
  
  CHIP_ERROR ColorControlCluster::StepColor(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback,
                                            int16_t stepX, int16_t stepY, uint16_t transitionTime, uint8_t optionsMask,
                                            uint8_t optionsOverride)
  {
      VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
  
      app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kStepColorCommandId,
                                           (chip::app::CommandPathFlags::kEndpointIdValid) };
      app::Command * ZCLcommand        = mDevice->GetCommandSender();
  
      ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams));
  
      TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter();
      uint8_t argSeqNumber    = 0;
      // stepX: int16s
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), stepX));
      // stepY: int16s
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), stepY));
      // transitionTime: int16u
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), transitionTime));
      // optionsMask: bitmap8
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), optionsMask));
      // optionsOverride: bitmap8
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), optionsOverride));
  
      ReturnErrorOnFailure(ZCLcommand->FinishCommand());
  
      // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate.
      mDevice->AddIMResponseHandler(onSuccessCallback, onFailureCallback);
  
      return mDevice->SendCommands();
  }
  
  CHIP_ERROR ColorControlCluster::StepColorTemperature(Callback::Cancelable * onSuccessCallback,
                                                       Callback::Cancelable * onFailureCallback, uint8_t stepMode, uint16_t stepSize,
                                                       uint16_t transitionTime, uint16_t colorTemperatureMinimum,
                                                       uint16_t colorTemperatureMaximum, uint8_t optionsMask, uint8_t optionsOverride)
  {
      VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
  
      app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kStepColorTemperatureCommandId,
                                           (chip::app::CommandPathFlags::kEndpointIdValid) };
      app::Command * ZCLcommand        = mDevice->GetCommandSender();
  
      ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams));
  
      TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter();
      uint8_t argSeqNumber    = 0;
      // stepMode: hueStepMode
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), stepMode));
      // stepSize: int16u
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), stepSize));
      // transitionTime: int16u
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), transitionTime));
      // colorTemperatureMinimum: int16u
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), colorTemperatureMinimum));
      // colorTemperatureMaximum: int16u
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), colorTemperatureMaximum));
      // optionsMask: bitmap8
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), optionsMask));
      // optionsOverride: bitmap8
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), optionsOverride));
  
      ReturnErrorOnFailure(ZCLcommand->FinishCommand());
  
      // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate.
      mDevice->AddIMResponseHandler(onSuccessCallback, onFailureCallback);
  
      return mDevice->SendCommands();
  }
  
  CHIP_ERROR ColorControlCluster::StepHue(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback,
                                          uint8_t stepMode, uint8_t stepSize, uint8_t transitionTime, uint8_t optionsMask,
                                          uint8_t optionsOverride)
  {
      VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
  
      app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kStepHueCommandId,
                                           (chip::app::CommandPathFlags::kEndpointIdValid) };
      app::Command * ZCLcommand        = mDevice->GetCommandSender();
  
      ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams));
  
      TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter();
      uint8_t argSeqNumber    = 0;
      // stepMode: hueStepMode
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), stepMode));
      // stepSize: int8u
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), stepSize));
      // transitionTime: int8u
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), transitionTime));
      // optionsMask: bitmap8
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), optionsMask));
      // optionsOverride: bitmap8
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), optionsOverride));
  
      ReturnErrorOnFailure(ZCLcommand->FinishCommand());
  
      // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate.
      mDevice->AddIMResponseHandler(onSuccessCallback, onFailureCallback);
  
      return mDevice->SendCommands();
  }
  
  CHIP_ERROR ColorControlCluster::StepSaturation(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback,
                                                 uint8_t stepMode, uint8_t stepSize, uint8_t transitionTime, uint8_t optionsMask,
                                                 uint8_t optionsOverride)
  {
      VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
  
      app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kStepSaturationCommandId,
                                           (chip::app::CommandPathFlags::kEndpointIdValid) };
      app::Command * ZCLcommand        = mDevice->GetCommandSender();
  
      ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams));
  
      TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter();
      uint8_t argSeqNumber    = 0;
      // stepMode: saturationStepMode
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), stepMode));
      // stepSize: int8u
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), stepSize));
      // transitionTime: int8u
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), transitionTime));
      // optionsMask: bitmap8
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), optionsMask));
      // optionsOverride: bitmap8
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), optionsOverride));
  
      ReturnErrorOnFailure(ZCLcommand->FinishCommand());
  
      // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate.
      mDevice->AddIMResponseHandler(onSuccessCallback, onFailureCallback);
  
      return mDevice->SendCommands();
  }
  
  CHIP_ERROR ColorControlCluster::StopMoveStep(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback,
                                               uint8_t optionsMask, uint8_t optionsOverride)
  {
      VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
  
      app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kStopMoveStepCommandId,
                                           (chip::app::CommandPathFlags::kEndpointIdValid) };
      app::Command * ZCLcommand        = mDevice->GetCommandSender();
  
      ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams));
  
      TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter();
      uint8_t argSeqNumber    = 0;
      // optionsMask: bitmap8
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), optionsMask));
      // optionsOverride: bitmap8
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), optionsOverride));
  
      ReturnErrorOnFailure(ZCLcommand->FinishCommand());
  
      // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate.
      mDevice->AddIMResponseHandler(onSuccessCallback, onFailureCallback);
  
      return mDevice->SendCommands();
  }
  
  // ColorControl Cluster Attributes
  CHIP_ERROR ColorControlCluster::DiscoverAttributes(Callback::Cancelable * onSuccessCallback,
                                                     Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeColorControlClusterDiscoverAttributes(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  CHIP_ERROR ColorControlCluster::ReadAttributeCurrentHue(Callback::Cancelable * onSuccessCallback,
                                                          Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeColorControlClusterReadCurrentHueAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR ColorControlCluster::ConfigureAttributeCurrentHue(Callback::Cancelable * onSuccessCallback,
                                                               Callback::Cancelable * onFailureCallback, uint16_t minInterval,
                                                               uint16_t maxInterval, uint8_t change)
  {
      uint8_t seqNum = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand =
          encodeColorControlClusterConfigureCurrentHueAttribute(seqNum, mEndpoint, minInterval, maxInterval, change);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR ColorControlCluster::ReportAttributeCurrentHue(Callback::Cancelable * onReportCallback)
  {
      return RequestAttributeReporting(0x0000, onReportCallback);
  }
  
  CHIP_ERROR ColorControlCluster::ReadAttributeCurrentSaturation(Callback::Cancelable * onSuccessCallback,
                                                                 Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeColorControlClusterReadCurrentSaturationAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR ColorControlCluster::ConfigureAttributeCurrentSaturation(Callback::Cancelable * onSuccessCallback,
                                                                      Callback::Cancelable * onFailureCallback, uint16_t minInterval,
                                                                      uint16_t maxInterval, uint8_t change)
  {
      uint8_t seqNum = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand =
          encodeColorControlClusterConfigureCurrentSaturationAttribute(seqNum, mEndpoint, minInterval, maxInterval, change);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR ColorControlCluster::ReportAttributeCurrentSaturation(Callback::Cancelable * onReportCallback)
  {
      return RequestAttributeReporting(0x0001, onReportCallback);
  }
  
  CHIP_ERROR ColorControlCluster::ReadAttributeRemainingTime(Callback::Cancelable * onSuccessCallback,
                                                             Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeColorControlClusterReadRemainingTimeAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR ColorControlCluster::ReadAttributeCurrentX(Callback::Cancelable * onSuccessCallback,
                                                        Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeColorControlClusterReadCurrentXAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR ColorControlCluster::ConfigureAttributeCurrentX(Callback::Cancelable * onSuccessCallback,
                                                             Callback::Cancelable * onFailureCallback, uint16_t minInterval,
                                                             uint16_t maxInterval, uint16_t change)
  {
      uint8_t seqNum = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand =
          encodeColorControlClusterConfigureCurrentXAttribute(seqNum, mEndpoint, minInterval, maxInterval, change);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR ColorControlCluster::ReportAttributeCurrentX(Callback::Cancelable * onReportCallback)
  {
      return RequestAttributeReporting(0x0003, onReportCallback);
  }
  
  CHIP_ERROR ColorControlCluster::ReadAttributeCurrentY(Callback::Cancelable * onSuccessCallback,
                                                        Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeColorControlClusterReadCurrentYAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR ColorControlCluster::ConfigureAttributeCurrentY(Callback::Cancelable * onSuccessCallback,
                                                             Callback::Cancelable * onFailureCallback, uint16_t minInterval,
                                                             uint16_t maxInterval, uint16_t change)
  {
      uint8_t seqNum = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand =
          encodeColorControlClusterConfigureCurrentYAttribute(seqNum, mEndpoint, minInterval, maxInterval, change);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR ColorControlCluster::ReportAttributeCurrentY(Callback::Cancelable * onReportCallback)
  {
      return RequestAttributeReporting(0x0004, onReportCallback);
  }
  
  CHIP_ERROR ColorControlCluster::ReadAttributeDriftCompensation(Callback::Cancelable * onSuccessCallback,
                                                                 Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeColorControlClusterReadDriftCompensationAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR ColorControlCluster::ReadAttributeCompensationText(Callback::Cancelable * onSuccessCallback,
                                                                Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeColorControlClusterReadCompensationTextAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR ColorControlCluster::ReadAttributeColorTemperature(Callback::Cancelable * onSuccessCallback,
                                                                Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeColorControlClusterReadColorTemperatureAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR ColorControlCluster::ConfigureAttributeColorTemperature(Callback::Cancelable * onSuccessCallback,
                                                                     Callback::Cancelable * onFailureCallback, uint16_t minInterval,
                                                                     uint16_t maxInterval, uint16_t change)
  {
      uint8_t seqNum = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand =
          encodeColorControlClusterConfigureColorTemperatureAttribute(seqNum, mEndpoint, minInterval, maxInterval, change);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR ColorControlCluster::ReportAttributeColorTemperature(Callback::Cancelable * onReportCallback)
  {
      return RequestAttributeReporting(0x0007, onReportCallback);
  }
  
  CHIP_ERROR ColorControlCluster::ReadAttributeColorMode(Callback::Cancelable * onSuccessCallback,
                                                         Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeColorControlClusterReadColorModeAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR ColorControlCluster::ReadAttributeColorControlOptions(Callback::Cancelable * onSuccessCallback,
                                                                   Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeColorControlClusterReadColorControlOptionsAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR ColorControlCluster::WriteAttributeColorControlOptions(Callback::Cancelable * onSuccessCallback,
                                                                    Callback::Cancelable * onFailureCallback, uint8_t value)
  {
      uint8_t seqNum = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand =
          encodeColorControlClusterWriteColorControlOptionsAttribute(seqNum, mEndpoint, value);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR ColorControlCluster::ReadAttributeNumberOfPrimaries(Callback::Cancelable * onSuccessCallback,
                                                                 Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeColorControlClusterReadNumberOfPrimariesAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR ColorControlCluster::ReadAttributePrimary1X(Callback::Cancelable * onSuccessCallback,
                                                         Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeColorControlClusterReadPrimary1XAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR ColorControlCluster::ReadAttributePrimary1Y(Callback::Cancelable * onSuccessCallback,
                                                         Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeColorControlClusterReadPrimary1YAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR ColorControlCluster::ReadAttributePrimary1Intensity(Callback::Cancelable * onSuccessCallback,
                                                                 Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeColorControlClusterReadPrimary1IntensityAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR ColorControlCluster::ReadAttributePrimary2X(Callback::Cancelable * onSuccessCallback,
                                                         Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeColorControlClusterReadPrimary2XAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR ColorControlCluster::ReadAttributePrimary2Y(Callback::Cancelable * onSuccessCallback,
                                                         Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeColorControlClusterReadPrimary2YAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR ColorControlCluster::ReadAttributePrimary2Intensity(Callback::Cancelable * onSuccessCallback,
                                                                 Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeColorControlClusterReadPrimary2IntensityAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR ColorControlCluster::ReadAttributePrimary3X(Callback::Cancelable * onSuccessCallback,
                                                         Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeColorControlClusterReadPrimary3XAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR ColorControlCluster::ReadAttributePrimary3Y(Callback::Cancelable * onSuccessCallback,
                                                         Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeColorControlClusterReadPrimary3YAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR ColorControlCluster::ReadAttributePrimary3Intensity(Callback::Cancelable * onSuccessCallback,
                                                                 Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeColorControlClusterReadPrimary3IntensityAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR ColorControlCluster::ReadAttributePrimary4X(Callback::Cancelable * onSuccessCallback,
                                                         Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeColorControlClusterReadPrimary4XAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR ColorControlCluster::ReadAttributePrimary4Y(Callback::Cancelable * onSuccessCallback,
                                                         Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeColorControlClusterReadPrimary4YAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR ColorControlCluster::ReadAttributePrimary4Intensity(Callback::Cancelable * onSuccessCallback,
                                                                 Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeColorControlClusterReadPrimary4IntensityAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR ColorControlCluster::ReadAttributePrimary5X(Callback::Cancelable * onSuccessCallback,
                                                         Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeColorControlClusterReadPrimary5XAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR ColorControlCluster::ReadAttributePrimary5Y(Callback::Cancelable * onSuccessCallback,
                                                         Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeColorControlClusterReadPrimary5YAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR ColorControlCluster::ReadAttributePrimary5Intensity(Callback::Cancelable * onSuccessCallback,
                                                                 Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeColorControlClusterReadPrimary5IntensityAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR ColorControlCluster::ReadAttributePrimary6X(Callback::Cancelable * onSuccessCallback,
                                                         Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeColorControlClusterReadPrimary6XAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR ColorControlCluster::ReadAttributePrimary6Y(Callback::Cancelable * onSuccessCallback,
                                                         Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeColorControlClusterReadPrimary6YAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR ColorControlCluster::ReadAttributePrimary6Intensity(Callback::Cancelable * onSuccessCallback,
                                                                 Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeColorControlClusterReadPrimary6IntensityAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR ColorControlCluster::ReadAttributeWhitePointX(Callback::Cancelable * onSuccessCallback,
                                                           Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeColorControlClusterReadWhitePointXAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR ColorControlCluster::WriteAttributeWhitePointX(Callback::Cancelable * onSuccessCallback,
                                                            Callback::Cancelable * onFailureCallback, uint16_t value)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeColorControlClusterWriteWhitePointXAttribute(seqNum, mEndpoint, value);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR ColorControlCluster::ReadAttributeWhitePointY(Callback::Cancelable * onSuccessCallback,
                                                           Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeColorControlClusterReadWhitePointYAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR ColorControlCluster::WriteAttributeWhitePointY(Callback::Cancelable * onSuccessCallback,
                                                            Callback::Cancelable * onFailureCallback, uint16_t value)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeColorControlClusterWriteWhitePointYAttribute(seqNum, mEndpoint, value);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR ColorControlCluster::ReadAttributeColorPointRX(Callback::Cancelable * onSuccessCallback,
                                                            Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeColorControlClusterReadColorPointRXAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR ColorControlCluster::WriteAttributeColorPointRX(Callback::Cancelable * onSuccessCallback,
                                                             Callback::Cancelable * onFailureCallback, uint16_t value)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeColorControlClusterWriteColorPointRXAttribute(seqNum, mEndpoint, value);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR ColorControlCluster::ReadAttributeColorPointRY(Callback::Cancelable * onSuccessCallback,
                                                            Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeColorControlClusterReadColorPointRYAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR ColorControlCluster::WriteAttributeColorPointRY(Callback::Cancelable * onSuccessCallback,
                                                             Callback::Cancelable * onFailureCallback, uint16_t value)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeColorControlClusterWriteColorPointRYAttribute(seqNum, mEndpoint, value);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR ColorControlCluster::ReadAttributeColorPointRIntensity(Callback::Cancelable * onSuccessCallback,
                                                                    Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeColorControlClusterReadColorPointRIntensityAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR ColorControlCluster::WriteAttributeColorPointRIntensity(Callback::Cancelable * onSuccessCallback,
                                                                     Callback::Cancelable * onFailureCallback, uint8_t value)
  {
      uint8_t seqNum = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand =
          encodeColorControlClusterWriteColorPointRIntensityAttribute(seqNum, mEndpoint, value);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR ColorControlCluster::ReadAttributeColorPointGX(Callback::Cancelable * onSuccessCallback,
                                                            Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeColorControlClusterReadColorPointGXAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR ColorControlCluster::WriteAttributeColorPointGX(Callback::Cancelable * onSuccessCallback,
                                                             Callback::Cancelable * onFailureCallback, uint16_t value)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeColorControlClusterWriteColorPointGXAttribute(seqNum, mEndpoint, value);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR ColorControlCluster::ReadAttributeColorPointGY(Callback::Cancelable * onSuccessCallback,
                                                            Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeColorControlClusterReadColorPointGYAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR ColorControlCluster::WriteAttributeColorPointGY(Callback::Cancelable * onSuccessCallback,
                                                             Callback::Cancelable * onFailureCallback, uint16_t value)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeColorControlClusterWriteColorPointGYAttribute(seqNum, mEndpoint, value);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR ColorControlCluster::ReadAttributeColorPointGIntensity(Callback::Cancelable * onSuccessCallback,
                                                                    Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeColorControlClusterReadColorPointGIntensityAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR ColorControlCluster::WriteAttributeColorPointGIntensity(Callback::Cancelable * onSuccessCallback,
                                                                     Callback::Cancelable * onFailureCallback, uint8_t value)
  {
      uint8_t seqNum = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand =
          encodeColorControlClusterWriteColorPointGIntensityAttribute(seqNum, mEndpoint, value);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR ColorControlCluster::ReadAttributeColorPointBX(Callback::Cancelable * onSuccessCallback,
                                                            Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeColorControlClusterReadColorPointBXAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR ColorControlCluster::WriteAttributeColorPointBX(Callback::Cancelable * onSuccessCallback,
                                                             Callback::Cancelable * onFailureCallback, uint16_t value)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeColorControlClusterWriteColorPointBXAttribute(seqNum, mEndpoint, value);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR ColorControlCluster::ReadAttributeColorPointBY(Callback::Cancelable * onSuccessCallback,
                                                            Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeColorControlClusterReadColorPointBYAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR ColorControlCluster::WriteAttributeColorPointBY(Callback::Cancelable * onSuccessCallback,
                                                             Callback::Cancelable * onFailureCallback, uint16_t value)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeColorControlClusterWriteColorPointBYAttribute(seqNum, mEndpoint, value);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR ColorControlCluster::ReadAttributeColorPointBIntensity(Callback::Cancelable * onSuccessCallback,
                                                                    Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeColorControlClusterReadColorPointBIntensityAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR ColorControlCluster::WriteAttributeColorPointBIntensity(Callback::Cancelable * onSuccessCallback,
                                                                     Callback::Cancelable * onFailureCallback, uint8_t value)
  {
      uint8_t seqNum = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand =
          encodeColorControlClusterWriteColorPointBIntensityAttribute(seqNum, mEndpoint, value);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR ColorControlCluster::ReadAttributeEnhancedCurrentHue(Callback::Cancelable * onSuccessCallback,
                                                                  Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeColorControlClusterReadEnhancedCurrentHueAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR ColorControlCluster::ReadAttributeEnhancedColorMode(Callback::Cancelable * onSuccessCallback,
                                                                 Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeColorControlClusterReadEnhancedColorModeAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR ColorControlCluster::ReadAttributeColorLoopActive(Callback::Cancelable * onSuccessCallback,
                                                               Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeColorControlClusterReadColorLoopActiveAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR ColorControlCluster::ReadAttributeColorLoopDirection(Callback::Cancelable * onSuccessCallback,
                                                                  Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeColorControlClusterReadColorLoopDirectionAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR ColorControlCluster::ReadAttributeColorLoopTime(Callback::Cancelable * onSuccessCallback,
                                                             Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeColorControlClusterReadColorLoopTimeAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR ColorControlCluster::ReadAttributeColorCapabilities(Callback::Cancelable * onSuccessCallback,
                                                                 Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeColorControlClusterReadColorCapabilitiesAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR ColorControlCluster::ReadAttributeColorTempPhysicalMin(Callback::Cancelable * onSuccessCallback,
                                                                    Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeColorControlClusterReadColorTempPhysicalMinAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR ColorControlCluster::ReadAttributeColorTempPhysicalMax(Callback::Cancelable * onSuccessCallback,
                                                                    Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeColorControlClusterReadColorTempPhysicalMaxAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR ColorControlCluster::ReadAttributeCoupleColorTempToLevelMinMireds(Callback::Cancelable * onSuccessCallback,
                                                                               Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand =
          encodeColorControlClusterReadCoupleColorTempToLevelMinMiredsAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR ColorControlCluster::ReadAttributeStartUpColorTemperatureMireds(Callback::Cancelable * onSuccessCallback,
                                                                             Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand =
          encodeColorControlClusterReadStartUpColorTemperatureMiredsAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR ColorControlCluster::WriteAttributeStartUpColorTemperatureMireds(Callback::Cancelable * onSuccessCallback,
                                                                              Callback::Cancelable * onFailureCallback,
                                                                              uint16_t value)
  {
      uint8_t seqNum = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand =
          encodeColorControlClusterWriteStartUpColorTemperatureMiredsAttribute(seqNum, mEndpoint, value);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR ColorControlCluster::ReadAttributeClusterRevision(Callback::Cancelable * onSuccessCallback,
                                                               Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeColorControlClusterReadClusterRevisionAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  // ContentLaunch Cluster Commands
  CHIP_ERROR ContentLaunchCluster::LaunchContent(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback,
                                                 uint8_t autoPlay, chip::ByteSpan data)
  {
      VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
  
      app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kLaunchContentCommandId,
                                           (chip::app::CommandPathFlags::kEndpointIdValid) };
      app::Command * ZCLcommand        = mDevice->GetCommandSender();
  
      ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams));
  
      TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter();
      uint8_t argSeqNumber    = 0;
      // autoPlay: boolean
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), autoPlay));
      // data: charString
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), data));
  
      ReturnErrorOnFailure(ZCLcommand->FinishCommand());
  
      // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate.
      mDevice->AddIMResponseHandler(onSuccessCallback, onFailureCallback);
  
      return mDevice->SendCommands();
  }
  
  CHIP_ERROR ContentLaunchCluster::LaunchURL(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback,
                                             chip::ByteSpan contentURL, chip::ByteSpan displayString)
  {
      VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
  
      app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kLaunchURLCommandId,
                                           (chip::app::CommandPathFlags::kEndpointIdValid) };
      app::Command * ZCLcommand        = mDevice->GetCommandSender();
  
      ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams));
  
      TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter();
      uint8_t argSeqNumber    = 0;
      // contentURL: charString
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), contentURL));
      // displayString: charString
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), displayString));
  
      ReturnErrorOnFailure(ZCLcommand->FinishCommand());
  
      // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate.
      mDevice->AddIMResponseHandler(onSuccessCallback, onFailureCallback);
  
      return mDevice->SendCommands();
  }
  
  // ContentLaunch Cluster Attributes
  CHIP_ERROR ContentLaunchCluster::DiscoverAttributes(Callback::Cancelable * onSuccessCallback,
                                                      Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeContentLaunchClusterDiscoverAttributes(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  CHIP_ERROR ContentLaunchCluster::ReadAttributeAcceptsHeaderList(Callback::Cancelable * onSuccessCallback,
                                                                  Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeContentLaunchClusterReadAcceptsHeaderListAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR ContentLaunchCluster::ReadAttributeSupportedStreamingTypes(Callback::Cancelable * onSuccessCallback,
                                                                        Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeContentLaunchClusterReadSupportedStreamingTypesAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR ContentLaunchCluster::ReadAttributeClusterRevision(Callback::Cancelable * onSuccessCallback,
                                                                Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeContentLaunchClusterReadClusterRevisionAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  // Descriptor Cluster Commands
  // Descriptor Cluster Attributes
  CHIP_ERROR DescriptorCluster::DiscoverAttributes(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeDescriptorClusterDiscoverAttributes(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  CHIP_ERROR DescriptorCluster::ReadAttributeDeviceList(Callback::Cancelable * onSuccessCallback,
                                                        Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeDescriptorClusterReadDeviceListAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR DescriptorCluster::ReadAttributeServerList(Callback::Cancelable * onSuccessCallback,
                                                        Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeDescriptorClusterReadServerListAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR DescriptorCluster::ReadAttributeClientList(Callback::Cancelable * onSuccessCallback,
                                                        Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeDescriptorClusterReadClientListAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR DescriptorCluster::ReadAttributePartsList(Callback::Cancelable * onSuccessCallback,
                                                       Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeDescriptorClusterReadPartsListAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR DescriptorCluster::ReadAttributeClusterRevision(Callback::Cancelable * onSuccessCallback,
                                                             Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeDescriptorClusterReadClusterRevisionAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  // DoorLock Cluster Commands
  CHIP_ERROR DoorLockCluster::ClearAllPins(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback)
  {
      VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
  
      app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kClearAllPinsCommandId,
                                           (chip::app::CommandPathFlags::kEndpointIdValid) };
      app::Command * ZCLcommand        = mDevice->GetCommandSender();
  
      ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams));
  
      // Command takes no arguments.
  
      ReturnErrorOnFailure(ZCLcommand->FinishCommand());
  
      // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate.
      mDevice->AddIMResponseHandler(onSuccessCallback, onFailureCallback);
  
      return mDevice->SendCommands();
  }
  
  CHIP_ERROR DoorLockCluster::ClearAllRfids(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback)
  {
      VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
  
      app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kClearAllRfidsCommandId,
                                           (chip::app::CommandPathFlags::kEndpointIdValid) };
      app::Command * ZCLcommand        = mDevice->GetCommandSender();
  
      ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams));
  
      // Command takes no arguments.
  
      ReturnErrorOnFailure(ZCLcommand->FinishCommand());
  
      // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate.
      mDevice->AddIMResponseHandler(onSuccessCallback, onFailureCallback);
  
      return mDevice->SendCommands();
  }
  
  CHIP_ERROR DoorLockCluster::ClearHolidaySchedule(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback,
                                                   uint8_t scheduleId)
  {
      VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
  
      app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kClearHolidayScheduleCommandId,
                                           (chip::app::CommandPathFlags::kEndpointIdValid) };
      app::Command * ZCLcommand        = mDevice->GetCommandSender();
  
      ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams));
  
      TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter();
      uint8_t argSeqNumber    = 0;
      // scheduleId: int8u
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), scheduleId));
  
      ReturnErrorOnFailure(ZCLcommand->FinishCommand());
  
      // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate.
      mDevice->AddIMResponseHandler(onSuccessCallback, onFailureCallback);
  
      return mDevice->SendCommands();
  }
  
  CHIP_ERROR DoorLockCluster::ClearPin(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback,
                                       uint16_t userId)
  {
      VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
  
      app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kClearPinCommandId,
                                           (chip::app::CommandPathFlags::kEndpointIdValid) };
      app::Command * ZCLcommand        = mDevice->GetCommandSender();
  
      ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams));
  
      TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter();
      uint8_t argSeqNumber    = 0;
      // userId: int16u
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), userId));
  
      ReturnErrorOnFailure(ZCLcommand->FinishCommand());
  
      // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate.
      mDevice->AddIMResponseHandler(onSuccessCallback, onFailureCallback);
  
      return mDevice->SendCommands();
  }
  
  CHIP_ERROR DoorLockCluster::ClearRfid(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback,
                                        uint16_t userId)
  {
      VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
  
      app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kClearRfidCommandId,
                                           (chip::app::CommandPathFlags::kEndpointIdValid) };
      app::Command * ZCLcommand        = mDevice->GetCommandSender();
  
      ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams));
  
      TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter();
      uint8_t argSeqNumber    = 0;
      // userId: int16u
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), userId));
  
      ReturnErrorOnFailure(ZCLcommand->FinishCommand());
  
      // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate.
      mDevice->AddIMResponseHandler(onSuccessCallback, onFailureCallback);
  
      return mDevice->SendCommands();
  }
  
  CHIP_ERROR DoorLockCluster::ClearWeekdaySchedule(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback,
                                                   uint8_t scheduleId, uint16_t userId)
  {
      VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
  
      app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kClearWeekdayScheduleCommandId,
                                           (chip::app::CommandPathFlags::kEndpointIdValid) };
      app::Command * ZCLcommand        = mDevice->GetCommandSender();
  
      ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams));
  
      TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter();
      uint8_t argSeqNumber    = 0;
      // scheduleId: int8u
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), scheduleId));
      // userId: int16u
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), userId));
  
      ReturnErrorOnFailure(ZCLcommand->FinishCommand());
  
      // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate.
      mDevice->AddIMResponseHandler(onSuccessCallback, onFailureCallback);
  
      return mDevice->SendCommands();
  }
  
  CHIP_ERROR DoorLockCluster::ClearYeardaySchedule(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback,
                                                   uint8_t scheduleId, uint16_t userId)
  {
      VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
  
      app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kClearYeardayScheduleCommandId,
                                           (chip::app::CommandPathFlags::kEndpointIdValid) };
      app::Command * ZCLcommand        = mDevice->GetCommandSender();
  
      ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams));
  
      TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter();
      uint8_t argSeqNumber    = 0;
      // scheduleId: int8u
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), scheduleId));
      // userId: int16u
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), userId));
  
      ReturnErrorOnFailure(ZCLcommand->FinishCommand());
  
      // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate.
      mDevice->AddIMResponseHandler(onSuccessCallback, onFailureCallback);
  
      return mDevice->SendCommands();
  }
  
  CHIP_ERROR DoorLockCluster::GetHolidaySchedule(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback,
                                                 uint8_t scheduleId)
  {
      VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
  
      app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kGetHolidayScheduleCommandId,
                                           (chip::app::CommandPathFlags::kEndpointIdValid) };
      app::Command * ZCLcommand        = mDevice->GetCommandSender();
  
      ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams));
  
      TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter();
      uint8_t argSeqNumber    = 0;
      // scheduleId: int8u
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), scheduleId));
  
      ReturnErrorOnFailure(ZCLcommand->FinishCommand());
  
      // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate.
      mDevice->AddIMResponseHandler(onSuccessCallback, onFailureCallback);
  
      return mDevice->SendCommands();
  }
  
  CHIP_ERROR DoorLockCluster::GetLogRecord(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback,
                                           uint16_t logIndex)
  {
      VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
  
      app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kGetLogRecordCommandId,
                                           (chip::app::CommandPathFlags::kEndpointIdValid) };
      app::Command * ZCLcommand        = mDevice->GetCommandSender();
  
      ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams));
  
      TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter();
      uint8_t argSeqNumber    = 0;
      // logIndex: int16u
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), logIndex));
  
      ReturnErrorOnFailure(ZCLcommand->FinishCommand());
  
      // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate.
      mDevice->AddIMResponseHandler(onSuccessCallback, onFailureCallback);
  
      return mDevice->SendCommands();
  }
  
  CHIP_ERROR DoorLockCluster::GetPin(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback,
                                     uint16_t userId)
  {
      VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
  
      app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kGetPinCommandId,
                                           (chip::app::CommandPathFlags::kEndpointIdValid) };
      app::Command * ZCLcommand        = mDevice->GetCommandSender();
  
      ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams));
  
      TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter();
      uint8_t argSeqNumber    = 0;
      // userId: int16u
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), userId));
  
      ReturnErrorOnFailure(ZCLcommand->FinishCommand());
  
      // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate.
      mDevice->AddIMResponseHandler(onSuccessCallback, onFailureCallback);
  
      return mDevice->SendCommands();
  }
  
  CHIP_ERROR DoorLockCluster::GetRfid(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback,
                                      uint16_t userId)
  {
      VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
  
      app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kGetRfidCommandId,
                                           (chip::app::CommandPathFlags::kEndpointIdValid) };
      app::Command * ZCLcommand        = mDevice->GetCommandSender();
  
      ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams));
  
      TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter();
      uint8_t argSeqNumber    = 0;
      // userId: int16u
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), userId));
  
      ReturnErrorOnFailure(ZCLcommand->FinishCommand());
  
      // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate.
      mDevice->AddIMResponseHandler(onSuccessCallback, onFailureCallback);
  
      return mDevice->SendCommands();
  }
  
  CHIP_ERROR DoorLockCluster::GetUserType(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback,
                                          uint16_t userId)
  {
      VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
  
      app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kGetUserTypeCommandId,
                                           (chip::app::CommandPathFlags::kEndpointIdValid) };
      app::Command * ZCLcommand        = mDevice->GetCommandSender();
  
      ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams));
  
      TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter();
      uint8_t argSeqNumber    = 0;
      // userId: int16u
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), userId));
  
      ReturnErrorOnFailure(ZCLcommand->FinishCommand());
  
      // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate.
      mDevice->AddIMResponseHandler(onSuccessCallback, onFailureCallback);
  
      return mDevice->SendCommands();
  }
  
  CHIP_ERROR DoorLockCluster::GetWeekdaySchedule(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback,
                                                 uint8_t scheduleId, uint16_t userId)
  {
      VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
  
      app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kGetWeekdayScheduleCommandId,
                                           (chip::app::CommandPathFlags::kEndpointIdValid) };
      app::Command * ZCLcommand        = mDevice->GetCommandSender();
  
      ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams));
  
      TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter();
      uint8_t argSeqNumber    = 0;
      // scheduleId: int8u
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), scheduleId));
      // userId: int16u
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), userId));
  
      ReturnErrorOnFailure(ZCLcommand->FinishCommand());
  
      // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate.
      mDevice->AddIMResponseHandler(onSuccessCallback, onFailureCallback);
  
      return mDevice->SendCommands();
  }
  
  CHIP_ERROR DoorLockCluster::GetYeardaySchedule(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback,
                                                 uint8_t scheduleId, uint16_t userId)
  {
      VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
  
      app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kGetYeardayScheduleCommandId,
                                           (chip::app::CommandPathFlags::kEndpointIdValid) };
      app::Command * ZCLcommand        = mDevice->GetCommandSender();
  
      ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams));
  
      TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter();
      uint8_t argSeqNumber    = 0;
      // scheduleId: int8u
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), scheduleId));
      // userId: int16u
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), userId));
  
      ReturnErrorOnFailure(ZCLcommand->FinishCommand());
  
      // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate.
      mDevice->AddIMResponseHandler(onSuccessCallback, onFailureCallback);
  
      return mDevice->SendCommands();
  }
  
  CHIP_ERROR DoorLockCluster::LockDoor(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback,
                                       chip::ByteSpan pin)
  {
      VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
  
      app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kLockDoorCommandId,
                                           (chip::app::CommandPathFlags::kEndpointIdValid) };
      app::Command * ZCLcommand        = mDevice->GetCommandSender();
  
      ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams));
  
      TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter();
      uint8_t argSeqNumber    = 0;
      // pin: charString
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), pin));
  
      ReturnErrorOnFailure(ZCLcommand->FinishCommand());
  
      // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate.
      mDevice->AddIMResponseHandler(onSuccessCallback, onFailureCallback);
  
      return mDevice->SendCommands();
  }
  
  CHIP_ERROR DoorLockCluster::SetHolidaySchedule(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback,
                                                 uint8_t scheduleId, uint32_t localStartTime, uint32_t localEndTime,
                                                 uint8_t operatingModeDuringHoliday)
  {
      VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
  
      app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kSetHolidayScheduleCommandId,
                                           (chip::app::CommandPathFlags::kEndpointIdValid) };
      app::Command * ZCLcommand        = mDevice->GetCommandSender();
  
      ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams));
  
      TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter();
      uint8_t argSeqNumber    = 0;
      // scheduleId: int8u
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), scheduleId));
      // localStartTime: int32u
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), localStartTime));
      // localEndTime: int32u
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), localEndTime));
      // operatingModeDuringHoliday: enum8
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), operatingModeDuringHoliday));
  
      ReturnErrorOnFailure(ZCLcommand->FinishCommand());
  
      // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate.
      mDevice->AddIMResponseHandler(onSuccessCallback, onFailureCallback);
  
      return mDevice->SendCommands();
  }
  
  CHIP_ERROR DoorLockCluster::SetPin(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback,
                                     uint16_t userId, uint8_t userStatus, uint8_t userType, chip::ByteSpan pin)
  {
      VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
  
      app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kSetPinCommandId,
                                           (chip::app::CommandPathFlags::kEndpointIdValid) };
      app::Command * ZCLcommand        = mDevice->GetCommandSender();
  
      ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams));
  
      TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter();
      uint8_t argSeqNumber    = 0;
      // userId: int16u
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), userId));
      // userStatus: doorLockUserStatus
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), userStatus));
      // userType: doorLockUserType
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), userType));
      // pin: charString
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), pin));
  
      ReturnErrorOnFailure(ZCLcommand->FinishCommand());
  
      // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate.
      mDevice->AddIMResponseHandler(onSuccessCallback, onFailureCallback);
  
      return mDevice->SendCommands();
  }
  
  CHIP_ERROR DoorLockCluster::SetRfid(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback,
                                      uint16_t userId, uint8_t userStatus, uint8_t userType, chip::ByteSpan id)
  {
      VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
  
      app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kSetRfidCommandId,
                                           (chip::app::CommandPathFlags::kEndpointIdValid) };
      app::Command * ZCLcommand        = mDevice->GetCommandSender();
  
      ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams));
  
      TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter();
      uint8_t argSeqNumber    = 0;
      // userId: int16u
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), userId));
      // userStatus: doorLockUserStatus
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), userStatus));
      // userType: doorLockUserType
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), userType));
      // id: charString
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), id));
  
      ReturnErrorOnFailure(ZCLcommand->FinishCommand());
  
      // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate.
      mDevice->AddIMResponseHandler(onSuccessCallback, onFailureCallback);
  
      return mDevice->SendCommands();
  }
  
  CHIP_ERROR DoorLockCluster::SetUserType(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback,
                                          uint16_t userId, uint8_t userType)
  {
      VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
  
      app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kSetUserTypeCommandId,
                                           (chip::app::CommandPathFlags::kEndpointIdValid) };
      app::Command * ZCLcommand        = mDevice->GetCommandSender();
  
      ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams));
  
      TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter();
      uint8_t argSeqNumber    = 0;
      // userId: int16u
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), userId));
      // userType: doorLockUserType
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), userType));
  
      ReturnErrorOnFailure(ZCLcommand->FinishCommand());
  
      // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate.
      mDevice->AddIMResponseHandler(onSuccessCallback, onFailureCallback);
  
      return mDevice->SendCommands();
  }
  
  CHIP_ERROR DoorLockCluster::SetWeekdaySchedule(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback,
                                                 uint8_t scheduleId, uint16_t userId, uint8_t daysMask, uint8_t startHour,
                                                 uint8_t startMinute, uint8_t endHour, uint8_t endMinute)
  {
      VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
  
      app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kSetWeekdayScheduleCommandId,
                                           (chip::app::CommandPathFlags::kEndpointIdValid) };
      app::Command * ZCLcommand        = mDevice->GetCommandSender();
  
      ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams));
  
      TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter();
      uint8_t argSeqNumber    = 0;
      // scheduleId: int8u
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), scheduleId));
      // userId: int16u
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), userId));
      // daysMask: doorLockDayOfWeek
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), daysMask));
      // startHour: int8u
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), startHour));
      // startMinute: int8u
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), startMinute));
      // endHour: int8u
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), endHour));
      // endMinute: int8u
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), endMinute));
  
      ReturnErrorOnFailure(ZCLcommand->FinishCommand());
  
      // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate.
      mDevice->AddIMResponseHandler(onSuccessCallback, onFailureCallback);
  
      return mDevice->SendCommands();
  }
  
  CHIP_ERROR DoorLockCluster::SetYeardaySchedule(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback,
                                                 uint8_t scheduleId, uint16_t userId, uint32_t localStartTime, uint32_t localEndTime)
  {
      VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
  
      app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kSetYeardayScheduleCommandId,
                                           (chip::app::CommandPathFlags::kEndpointIdValid) };
      app::Command * ZCLcommand        = mDevice->GetCommandSender();
  
      ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams));
  
      TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter();
      uint8_t argSeqNumber    = 0;
      // scheduleId: int8u
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), scheduleId));
      // userId: int16u
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), userId));
      // localStartTime: int32u
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), localStartTime));
      // localEndTime: int32u
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), localEndTime));
  
      ReturnErrorOnFailure(ZCLcommand->FinishCommand());
  
      // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate.
      mDevice->AddIMResponseHandler(onSuccessCallback, onFailureCallback);
  
      return mDevice->SendCommands();
  }
  
  CHIP_ERROR DoorLockCluster::UnlockDoor(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback,
                                         chip::ByteSpan pin)
  {
      VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
  
      app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kUnlockDoorCommandId,
                                           (chip::app::CommandPathFlags::kEndpointIdValid) };
      app::Command * ZCLcommand        = mDevice->GetCommandSender();
  
      ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams));
  
      TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter();
      uint8_t argSeqNumber    = 0;
      // pin: charString
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), pin));
  
      ReturnErrorOnFailure(ZCLcommand->FinishCommand());
  
      // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate.
      mDevice->AddIMResponseHandler(onSuccessCallback, onFailureCallback);
  
      return mDevice->SendCommands();
  }
  
  CHIP_ERROR DoorLockCluster::UnlockWithTimeout(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback,
                                                uint16_t timeoutInSeconds, chip::ByteSpan pin)
  {
      VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
  
      app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kUnlockWithTimeoutCommandId,
                                           (chip::app::CommandPathFlags::kEndpointIdValid) };
      app::Command * ZCLcommand        = mDevice->GetCommandSender();
  
      ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams));
  
      TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter();
      uint8_t argSeqNumber    = 0;
      // timeoutInSeconds: int16u
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), timeoutInSeconds));
      // pin: charString
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), pin));
  
      ReturnErrorOnFailure(ZCLcommand->FinishCommand());
  
      // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate.
      mDevice->AddIMResponseHandler(onSuccessCallback, onFailureCallback);
  
      return mDevice->SendCommands();
  }
  
  // DoorLock Cluster Attributes
  CHIP_ERROR DoorLockCluster::DiscoverAttributes(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeDoorLockClusterDiscoverAttributes(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  CHIP_ERROR DoorLockCluster::ReadAttributeLockState(Callback::Cancelable * onSuccessCallback,
                                                     Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeDoorLockClusterReadLockStateAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR DoorLockCluster::ConfigureAttributeLockState(Callback::Cancelable * onSuccessCallback,
                                                          Callback::Cancelable * onFailureCallback, uint16_t minInterval,
                                                          uint16_t maxInterval)
  {
      uint8_t seqNum = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand =
          encodeDoorLockClusterConfigureLockStateAttribute(seqNum, mEndpoint, minInterval, maxInterval);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR DoorLockCluster::ReportAttributeLockState(Callback::Cancelable * onReportCallback)
  {
      return RequestAttributeReporting(0x0000, onReportCallback);
  }
  
  CHIP_ERROR DoorLockCluster::ReadAttributeLockType(Callback::Cancelable * onSuccessCallback,
                                                    Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeDoorLockClusterReadLockTypeAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR DoorLockCluster::ReadAttributeActuatorEnabled(Callback::Cancelable * onSuccessCallback,
                                                           Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeDoorLockClusterReadActuatorEnabledAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR DoorLockCluster::ReadAttributeClusterRevision(Callback::Cancelable * onSuccessCallback,
                                                           Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeDoorLockClusterReadClusterRevisionAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  // GeneralCommissioning Cluster Commands
  CHIP_ERROR GeneralCommissioningCluster::ArmFailSafe(Callback::Cancelable * onSuccessCallback,
                                                      Callback::Cancelable * onFailureCallback, uint16_t expiryLengthSeconds,
                                                      uint64_t breadcrumb, uint32_t timeoutMs)
  {
      VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
  
      app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kArmFailSafeCommandId,
                                           (chip::app::CommandPathFlags::kEndpointIdValid) };
      app::Command * ZCLcommand        = mDevice->GetCommandSender();
  
      ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams));
  
      TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter();
      uint8_t argSeqNumber    = 0;
      // expiryLengthSeconds: int16u
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), expiryLengthSeconds));
      // breadcrumb: int64u
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), breadcrumb));
      // timeoutMs: int32u
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), timeoutMs));
  
      ReturnErrorOnFailure(ZCLcommand->FinishCommand());
  
      // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate.
      mDevice->AddIMResponseHandler(onSuccessCallback, onFailureCallback);
  
      return mDevice->SendCommands();
  }
  
  CHIP_ERROR GeneralCommissioningCluster::CommissioningComplete(Callback::Cancelable * onSuccessCallback,
                                                                Callback::Cancelable * onFailureCallback)
  {
      VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
  
      app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kCommissioningCompleteCommandId,
                                           (chip::app::CommandPathFlags::kEndpointIdValid) };
      app::Command * ZCLcommand        = mDevice->GetCommandSender();
  
      ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams));
  
      // Command takes no arguments.
  
      ReturnErrorOnFailure(ZCLcommand->FinishCommand());
  
      // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate.
      mDevice->AddIMResponseHandler(onSuccessCallback, onFailureCallback);
  
      return mDevice->SendCommands();
  }
  
  CHIP_ERROR GeneralCommissioningCluster::SetRegulatoryConfig(Callback::Cancelable * onSuccessCallback,
                                                              Callback::Cancelable * onFailureCallback, uint8_t location,
                                                              chip::ByteSpan countryCode, uint64_t breadcrumb, uint32_t timeoutMs)
  {
      VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
  
      app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kSetRegulatoryConfigCommandId,
                                           (chip::app::CommandPathFlags::kEndpointIdValid) };
      app::Command * ZCLcommand        = mDevice->GetCommandSender();
  
      ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams));
  
      TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter();
      uint8_t argSeqNumber    = 0;
      // location: regulatoryLocationType
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), location));
      // countryCode: charString
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), countryCode));
      // breadcrumb: int64u
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), breadcrumb));
      // timeoutMs: int32u
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), timeoutMs));
  
      ReturnErrorOnFailure(ZCLcommand->FinishCommand());
  
      // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate.
      mDevice->AddIMResponseHandler(onSuccessCallback, onFailureCallback);
  
      return mDevice->SendCommands();
  }
  
  // GeneralCommissioning Cluster Attributes
  CHIP_ERROR GeneralCommissioningCluster::DiscoverAttributes(Callback::Cancelable * onSuccessCallback,
                                                             Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeGeneralCommissioningClusterDiscoverAttributes(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  CHIP_ERROR GeneralCommissioningCluster::ReadAttributeFabricId(Callback::Cancelable * onSuccessCallback,
                                                                Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeGeneralCommissioningClusterReadFabricIdAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR GeneralCommissioningCluster::ReadAttributeBreadcrumb(Callback::Cancelable * onSuccessCallback,
                                                                  Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeGeneralCommissioningClusterReadBreadcrumbAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR GeneralCommissioningCluster::WriteAttributeBreadcrumb(Callback::Cancelable * onSuccessCallback,
                                                                   Callback::Cancelable * onFailureCallback, uint64_t value)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeGeneralCommissioningClusterWriteBreadcrumbAttribute(seqNum, mEndpoint, value);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR GeneralCommissioningCluster::ReadAttributeClusterRevision(Callback::Cancelable * onSuccessCallback,
                                                                       Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeGeneralCommissioningClusterReadClusterRevisionAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  // GroupKeyManagement Cluster Commands
  // GroupKeyManagement Cluster Attributes
  CHIP_ERROR GroupKeyManagementCluster::DiscoverAttributes(Callback::Cancelable * onSuccessCallback,
                                                           Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeGroupKeyManagementClusterDiscoverAttributes(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  CHIP_ERROR GroupKeyManagementCluster::ReadAttributeGroups(Callback::Cancelable * onSuccessCallback,
                                                            Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeGroupKeyManagementClusterReadGroupsAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR GroupKeyManagementCluster::ReadAttributeGroupKeys(Callback::Cancelable * onSuccessCallback,
                                                               Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeGroupKeyManagementClusterReadGroupKeysAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR GroupKeyManagementCluster::ReadAttributeClusterRevision(Callback::Cancelable * onSuccessCallback,
                                                                     Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeGroupKeyManagementClusterReadClusterRevisionAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  // Groups Cluster Commands
  CHIP_ERROR GroupsCluster::AddGroup(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback,
                                     uint16_t groupId, chip::ByteSpan groupName)
  {
      VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
  
      app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kAddGroupCommandId,
                                           (chip::app::CommandPathFlags::kEndpointIdValid) };
      app::Command * ZCLcommand        = mDevice->GetCommandSender();
  
      ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams));
  
      TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter();
      uint8_t argSeqNumber    = 0;
      // groupId: int16u
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), groupId));
      // groupName: charString
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), groupName));
  
      ReturnErrorOnFailure(ZCLcommand->FinishCommand());
  
      // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate.
      mDevice->AddIMResponseHandler(onSuccessCallback, onFailureCallback);
  
      return mDevice->SendCommands();
  }
  
  CHIP_ERROR GroupsCluster::AddGroupIfIdentifying(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback,
                                                  uint16_t groupId, chip::ByteSpan groupName)
  {
      VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
  
      app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kAddGroupIfIdentifyingCommandId,
                                           (chip::app::CommandPathFlags::kEndpointIdValid) };
      app::Command * ZCLcommand        = mDevice->GetCommandSender();
  
      ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams));
  
      TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter();
      uint8_t argSeqNumber    = 0;
      // groupId: int16u
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), groupId));
      // groupName: charString
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), groupName));
  
      ReturnErrorOnFailure(ZCLcommand->FinishCommand());
  
      // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate.
      mDevice->AddIMResponseHandler(onSuccessCallback, onFailureCallback);
  
      return mDevice->SendCommands();
  }
  
  CHIP_ERROR GroupsCluster::GetGroupMembership(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback,
                                               uint8_t groupCount, uint16_t groupList)
  {
      VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
  
      app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kGetGroupMembershipCommandId,
                                           (chip::app::CommandPathFlags::kEndpointIdValid) };
      app::Command * ZCLcommand        = mDevice->GetCommandSender();
  
      ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams));
  
      TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter();
      uint8_t argSeqNumber    = 0;
      // groupCount: int8u
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), groupCount));
      // groupList: int16u
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), groupList));
  
      ReturnErrorOnFailure(ZCLcommand->FinishCommand());
  
      // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate.
      mDevice->AddIMResponseHandler(onSuccessCallback, onFailureCallback);
  
      return mDevice->SendCommands();
  }
  
  CHIP_ERROR GroupsCluster::RemoveAllGroups(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback)
  {
      VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
  
      app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kRemoveAllGroupsCommandId,
                                           (chip::app::CommandPathFlags::kEndpointIdValid) };
      app::Command * ZCLcommand        = mDevice->GetCommandSender();
  
      ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams));
  
      // Command takes no arguments.
  
      ReturnErrorOnFailure(ZCLcommand->FinishCommand());
  
      // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate.
      mDevice->AddIMResponseHandler(onSuccessCallback, onFailureCallback);
  
      return mDevice->SendCommands();
  }
  
  CHIP_ERROR GroupsCluster::RemoveGroup(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback,
                                        uint16_t groupId)
  {
      VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
  
      app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kRemoveGroupCommandId,
                                           (chip::app::CommandPathFlags::kEndpointIdValid) };
      app::Command * ZCLcommand        = mDevice->GetCommandSender();
  
      ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams));
  
      TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter();
      uint8_t argSeqNumber    = 0;
      // groupId: int16u
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), groupId));
  
      ReturnErrorOnFailure(ZCLcommand->FinishCommand());
  
      // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate.
      mDevice->AddIMResponseHandler(onSuccessCallback, onFailureCallback);
  
      return mDevice->SendCommands();
  }
  
  CHIP_ERROR GroupsCluster::ViewGroup(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback,
                                      uint16_t groupId)
  {
      VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
  
      app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kViewGroupCommandId,
                                           (chip::app::CommandPathFlags::kEndpointIdValid) };
      app::Command * ZCLcommand        = mDevice->GetCommandSender();
  
      ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams));
  
      TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter();
      uint8_t argSeqNumber    = 0;
      // groupId: int16u
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), groupId));
  
      ReturnErrorOnFailure(ZCLcommand->FinishCommand());
  
      // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate.
      mDevice->AddIMResponseHandler(onSuccessCallback, onFailureCallback);
  
      return mDevice->SendCommands();
  }
  
  // Groups Cluster Attributes
  CHIP_ERROR GroupsCluster::DiscoverAttributes(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeGroupsClusterDiscoverAttributes(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  CHIP_ERROR GroupsCluster::ReadAttributeNameSupport(Callback::Cancelable * onSuccessCallback,
                                                     Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeGroupsClusterReadNameSupportAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR GroupsCluster::ReadAttributeClusterRevision(Callback::Cancelable * onSuccessCallback,
                                                         Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeGroupsClusterReadClusterRevisionAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  // Identify Cluster Commands
  CHIP_ERROR IdentifyCluster::Identify(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback,
                                       uint16_t identifyTime)
  {
      VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
  
      app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kIdentifyCommandId,
                                           (chip::app::CommandPathFlags::kEndpointIdValid) };
      app::Command * ZCLcommand        = mDevice->GetCommandSender();
  
      ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams));
  
      TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter();
      uint8_t argSeqNumber    = 0;
      // identifyTime: int16u
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), identifyTime));
  
      ReturnErrorOnFailure(ZCLcommand->FinishCommand());
  
      // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate.
      mDevice->AddIMResponseHandler(onSuccessCallback, onFailureCallback);
  
      return mDevice->SendCommands();
  }
  
  CHIP_ERROR IdentifyCluster::IdentifyQuery(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback)
  {
      VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
  
      app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kIdentifyQueryCommandId,
                                           (chip::app::CommandPathFlags::kEndpointIdValid) };
      app::Command * ZCLcommand        = mDevice->GetCommandSender();
  
      ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams));
  
      // Command takes no arguments.
  
      ReturnErrorOnFailure(ZCLcommand->FinishCommand());
  
      // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate.
      mDevice->AddIMResponseHandler(onSuccessCallback, onFailureCallback);
  
      return mDevice->SendCommands();
  }
  
  // Identify Cluster Attributes
  CHIP_ERROR IdentifyCluster::DiscoverAttributes(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeIdentifyClusterDiscoverAttributes(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  CHIP_ERROR IdentifyCluster::ReadAttributeIdentifyTime(Callback::Cancelable * onSuccessCallback,
                                                        Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeIdentifyClusterReadIdentifyTimeAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR IdentifyCluster::WriteAttributeIdentifyTime(Callback::Cancelable * onSuccessCallback,
                                                         Callback::Cancelable * onFailureCallback, uint16_t value)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeIdentifyClusterWriteIdentifyTimeAttribute(seqNum, mEndpoint, value);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR IdentifyCluster::ReadAttributeClusterRevision(Callback::Cancelable * onSuccessCallback,
                                                           Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeIdentifyClusterReadClusterRevisionAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  // KeypadInput Cluster Commands
  CHIP_ERROR KeypadInputCluster::SendKey(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback,
                                         uint8_t keyCode)
  {
      VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
  
      app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kSendKeyCommandId,
                                           (chip::app::CommandPathFlags::kEndpointIdValid) };
      app::Command * ZCLcommand        = mDevice->GetCommandSender();
  
      ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams));
  
      TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter();
      uint8_t argSeqNumber    = 0;
      // keyCode: keypadInputCecKeyCode
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), keyCode));
  
      ReturnErrorOnFailure(ZCLcommand->FinishCommand());
  
      // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate.
      mDevice->AddIMResponseHandler(onSuccessCallback, onFailureCallback);
  
      return mDevice->SendCommands();
  }
  
  // KeypadInput Cluster Attributes
  CHIP_ERROR KeypadInputCluster::DiscoverAttributes(Callback::Cancelable * onSuccessCallback,
                                                    Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeKeypadInputClusterDiscoverAttributes(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  CHIP_ERROR KeypadInputCluster::ReadAttributeClusterRevision(Callback::Cancelable * onSuccessCallback,
                                                              Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeKeypadInputClusterReadClusterRevisionAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  // LevelControl Cluster Commands
  CHIP_ERROR LevelControlCluster::Move(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback,
                                       uint8_t moveMode, uint8_t rate, uint8_t optionMask, uint8_t optionOverride)
  {
      VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
  
      app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kMoveCommandId,
                                           (chip::app::CommandPathFlags::kEndpointIdValid) };
      app::Command * ZCLcommand        = mDevice->GetCommandSender();
  
      ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams));
  
      TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter();
      uint8_t argSeqNumber    = 0;
      // moveMode: moveMode
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), moveMode));
      // rate: int8u
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), rate));
      // optionMask: bitmap8
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), optionMask));
      // optionOverride: bitmap8
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), optionOverride));
  
      ReturnErrorOnFailure(ZCLcommand->FinishCommand());
  
      // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate.
      mDevice->AddIMResponseHandler(onSuccessCallback, onFailureCallback);
  
      return mDevice->SendCommands();
  }
  
  CHIP_ERROR LevelControlCluster::MoveToLevel(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback,
                                              uint8_t level, uint16_t transitionTime, uint8_t optionMask, uint8_t optionOverride)
  {
      VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
  
      app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kMoveToLevelCommandId,
                                           (chip::app::CommandPathFlags::kEndpointIdValid) };
      app::Command * ZCLcommand        = mDevice->GetCommandSender();
  
      ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams));
  
      TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter();
      uint8_t argSeqNumber    = 0;
      // level: int8u
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), level));
      // transitionTime: int16u
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), transitionTime));
      // optionMask: bitmap8
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), optionMask));
      // optionOverride: bitmap8
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), optionOverride));
  
      ReturnErrorOnFailure(ZCLcommand->FinishCommand());
  
      // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate.
      mDevice->AddIMResponseHandler(onSuccessCallback, onFailureCallback);
  
      return mDevice->SendCommands();
  }
  
  CHIP_ERROR LevelControlCluster::MoveToLevelWithOnOff(Callback::Cancelable * onSuccessCallback,
                                                       Callback::Cancelable * onFailureCallback, uint8_t level,
                                                       uint16_t transitionTime)
  {
      VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
  
      app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kMoveToLevelWithOnOffCommandId,
                                           (chip::app::CommandPathFlags::kEndpointIdValid) };
      app::Command * ZCLcommand        = mDevice->GetCommandSender();
  
      ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams));
  
      TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter();
      uint8_t argSeqNumber    = 0;
      // level: int8u
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), level));
      // transitionTime: int16u
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), transitionTime));
  
      ReturnErrorOnFailure(ZCLcommand->FinishCommand());
  
      // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate.
      mDevice->AddIMResponseHandler(onSuccessCallback, onFailureCallback);
  
      return mDevice->SendCommands();
  }
  
  CHIP_ERROR LevelControlCluster::MoveWithOnOff(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback,
                                                uint8_t moveMode, uint8_t rate)
  {
      VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
  
      app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kMoveWithOnOffCommandId,
                                           (chip::app::CommandPathFlags::kEndpointIdValid) };
      app::Command * ZCLcommand        = mDevice->GetCommandSender();
  
      ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams));
  
      TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter();
      uint8_t argSeqNumber    = 0;
      // moveMode: moveMode
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), moveMode));
      // rate: int8u
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), rate));
  
      ReturnErrorOnFailure(ZCLcommand->FinishCommand());
  
      // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate.
      mDevice->AddIMResponseHandler(onSuccessCallback, onFailureCallback);
  
      return mDevice->SendCommands();
  }
  
  CHIP_ERROR LevelControlCluster::Step(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback,
                                       uint8_t stepMode, uint8_t stepSize, uint16_t transitionTime, uint8_t optionMask,
                                       uint8_t optionOverride)
  {
      VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
  
      app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kStepCommandId,
                                           (chip::app::CommandPathFlags::kEndpointIdValid) };
      app::Command * ZCLcommand        = mDevice->GetCommandSender();
  
      ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams));
  
      TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter();
      uint8_t argSeqNumber    = 0;
      // stepMode: stepMode
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), stepMode));
      // stepSize: int8u
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), stepSize));
      // transitionTime: int16u
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), transitionTime));
      // optionMask: bitmap8
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), optionMask));
      // optionOverride: bitmap8
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), optionOverride));
  
      ReturnErrorOnFailure(ZCLcommand->FinishCommand());
  
      // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate.
      mDevice->AddIMResponseHandler(onSuccessCallback, onFailureCallback);
  
      return mDevice->SendCommands();
  }
  
  CHIP_ERROR LevelControlCluster::StepWithOnOff(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback,
                                                uint8_t stepMode, uint8_t stepSize, uint16_t transitionTime)
  {
      VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
  
      app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kStepWithOnOffCommandId,
                                           (chip::app::CommandPathFlags::kEndpointIdValid) };
      app::Command * ZCLcommand        = mDevice->GetCommandSender();
  
      ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams));
  
      TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter();
      uint8_t argSeqNumber    = 0;
      // stepMode: stepMode
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), stepMode));
      // stepSize: int8u
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), stepSize));
      // transitionTime: int16u
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), transitionTime));
  
      ReturnErrorOnFailure(ZCLcommand->FinishCommand());
  
      // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate.
      mDevice->AddIMResponseHandler(onSuccessCallback, onFailureCallback);
  
      return mDevice->SendCommands();
  }
  
  CHIP_ERROR LevelControlCluster::Stop(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback,
                                       uint8_t optionMask, uint8_t optionOverride)
  {
      VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
  
      app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kStopCommandId,
                                           (chip::app::CommandPathFlags::kEndpointIdValid) };
      app::Command * ZCLcommand        = mDevice->GetCommandSender();
  
      ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams));
  
      TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter();
      uint8_t argSeqNumber    = 0;
      // optionMask: bitmap8
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), optionMask));
      // optionOverride: bitmap8
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), optionOverride));
  
      ReturnErrorOnFailure(ZCLcommand->FinishCommand());
  
      // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate.
      mDevice->AddIMResponseHandler(onSuccessCallback, onFailureCallback);
  
      return mDevice->SendCommands();
  }
  
  CHIP_ERROR LevelControlCluster::StopWithOnOff(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback)
  {
      VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
  
      app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kStopWithOnOffCommandId,
                                           (chip::app::CommandPathFlags::kEndpointIdValid) };
      app::Command * ZCLcommand        = mDevice->GetCommandSender();
  
      ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams));
  
      // Command takes no arguments.
  
      ReturnErrorOnFailure(ZCLcommand->FinishCommand());
  
      // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate.
      mDevice->AddIMResponseHandler(onSuccessCallback, onFailureCallback);
  
      return mDevice->SendCommands();
  }
  
  // LevelControl Cluster Attributes
  CHIP_ERROR LevelControlCluster::DiscoverAttributes(Callback::Cancelable * onSuccessCallback,
                                                     Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeLevelControlClusterDiscoverAttributes(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  CHIP_ERROR LevelControlCluster::ReadAttributeCurrentLevel(Callback::Cancelable * onSuccessCallback,
                                                            Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeLevelControlClusterReadCurrentLevelAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR LevelControlCluster::ConfigureAttributeCurrentLevel(Callback::Cancelable * onSuccessCallback,
                                                                 Callback::Cancelable * onFailureCallback, uint16_t minInterval,
                                                                 uint16_t maxInterval, uint8_t change)
  {
      uint8_t seqNum = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand =
          encodeLevelControlClusterConfigureCurrentLevelAttribute(seqNum, mEndpoint, minInterval, maxInterval, change);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR LevelControlCluster::ReportAttributeCurrentLevel(Callback::Cancelable * onReportCallback)
  {
      return RequestAttributeReporting(0x0000, onReportCallback);
  }
  
  CHIP_ERROR LevelControlCluster::ReadAttributeClusterRevision(Callback::Cancelable * onSuccessCallback,
                                                               Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeLevelControlClusterReadClusterRevisionAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  // LowPower Cluster Commands
  CHIP_ERROR LowPowerCluster::Sleep(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback)
  {
      VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
  
      app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kSleepCommandId,
                                           (chip::app::CommandPathFlags::kEndpointIdValid) };
      app::Command * ZCLcommand        = mDevice->GetCommandSender();
  
      ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams));
  
      // Command takes no arguments.
  
      ReturnErrorOnFailure(ZCLcommand->FinishCommand());
  
      // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate.
      mDevice->AddIMResponseHandler(onSuccessCallback, onFailureCallback);
  
      return mDevice->SendCommands();
  }
  
  // LowPower Cluster Attributes
  CHIP_ERROR LowPowerCluster::DiscoverAttributes(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeLowPowerClusterDiscoverAttributes(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  CHIP_ERROR LowPowerCluster::ReadAttributeClusterRevision(Callback::Cancelable * onSuccessCallback,
                                                           Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeLowPowerClusterReadClusterRevisionAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  // MediaInput Cluster Commands
  CHIP_ERROR MediaInputCluster::HideInputStatus(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback)
  {
      VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
  
      app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kHideInputStatusCommandId,
                                           (chip::app::CommandPathFlags::kEndpointIdValid) };
      app::Command * ZCLcommand        = mDevice->GetCommandSender();
  
      ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams));
  
      // Command takes no arguments.
  
      ReturnErrorOnFailure(ZCLcommand->FinishCommand());
  
      // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate.
      mDevice->AddIMResponseHandler(onSuccessCallback, onFailureCallback);
  
      return mDevice->SendCommands();
  }
  
  CHIP_ERROR MediaInputCluster::RenameInput(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback,
                                            uint8_t index, chip::ByteSpan name)
  {
      VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
  
      app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kRenameInputCommandId,
                                           (chip::app::CommandPathFlags::kEndpointIdValid) };
      app::Command * ZCLcommand        = mDevice->GetCommandSender();
  
      ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams));
  
      TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter();
      uint8_t argSeqNumber    = 0;
      // index: int8u
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), index));
      // name: charString
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), name));
  
      ReturnErrorOnFailure(ZCLcommand->FinishCommand());
  
      // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate.
      mDevice->AddIMResponseHandler(onSuccessCallback, onFailureCallback);
  
      return mDevice->SendCommands();
  }
  
  CHIP_ERROR MediaInputCluster::SelectInput(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback,
                                            uint8_t index)
  {
      VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
  
      app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kSelectInputCommandId,
                                           (chip::app::CommandPathFlags::kEndpointIdValid) };
      app::Command * ZCLcommand        = mDevice->GetCommandSender();
  
      ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams));
  
      TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter();
      uint8_t argSeqNumber    = 0;
      // index: int8u
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), index));
  
      ReturnErrorOnFailure(ZCLcommand->FinishCommand());
  
      // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate.
      mDevice->AddIMResponseHandler(onSuccessCallback, onFailureCallback);
  
      return mDevice->SendCommands();
  }
  
  CHIP_ERROR MediaInputCluster::ShowInputStatus(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback)
  {
      VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
  
      app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kShowInputStatusCommandId,
                                           (chip::app::CommandPathFlags::kEndpointIdValid) };
      app::Command * ZCLcommand        = mDevice->GetCommandSender();
  
      ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams));
  
      // Command takes no arguments.
  
      ReturnErrorOnFailure(ZCLcommand->FinishCommand());
  
      // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate.
      mDevice->AddIMResponseHandler(onSuccessCallback, onFailureCallback);
  
      return mDevice->SendCommands();
  }
  
  // MediaInput Cluster Attributes
  CHIP_ERROR MediaInputCluster::DiscoverAttributes(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeMediaInputClusterDiscoverAttributes(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  CHIP_ERROR MediaInputCluster::ReadAttributeMediaInputList(Callback::Cancelable * onSuccessCallback,
                                                            Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeMediaInputClusterReadMediaInputListAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR MediaInputCluster::ReadAttributeClusterRevision(Callback::Cancelable * onSuccessCallback,
                                                             Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeMediaInputClusterReadClusterRevisionAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  // MediaPlayback Cluster Commands
  CHIP_ERROR MediaPlaybackCluster::MediaFastForward(Callback::Cancelable * onSuccessCallback,
                                                    Callback::Cancelable * onFailureCallback)
  {
      VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
  
      app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kMediaFastForwardCommandId,
                                           (chip::app::CommandPathFlags::kEndpointIdValid) };
      app::Command * ZCLcommand        = mDevice->GetCommandSender();
  
      ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams));
  
      // Command takes no arguments.
  
      ReturnErrorOnFailure(ZCLcommand->FinishCommand());
  
      // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate.
      mDevice->AddIMResponseHandler(onSuccessCallback, onFailureCallback);
  
      return mDevice->SendCommands();
  }
  
  CHIP_ERROR MediaPlaybackCluster::MediaNext(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback)
  {
      VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
  
      app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kMediaNextCommandId,
                                           (chip::app::CommandPathFlags::kEndpointIdValid) };
      app::Command * ZCLcommand        = mDevice->GetCommandSender();
  
      ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams));
  
      // Command takes no arguments.
  
      ReturnErrorOnFailure(ZCLcommand->FinishCommand());
  
      // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate.
      mDevice->AddIMResponseHandler(onSuccessCallback, onFailureCallback);
  
      return mDevice->SendCommands();
  }
  
  CHIP_ERROR MediaPlaybackCluster::MediaPause(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback)
  {
      VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
  
      app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kMediaPauseCommandId,
                                           (chip::app::CommandPathFlags::kEndpointIdValid) };
      app::Command * ZCLcommand        = mDevice->GetCommandSender();
  
      ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams));
  
      // Command takes no arguments.
  
      ReturnErrorOnFailure(ZCLcommand->FinishCommand());
  
      // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate.
      mDevice->AddIMResponseHandler(onSuccessCallback, onFailureCallback);
  
      return mDevice->SendCommands();
  }
  
  CHIP_ERROR MediaPlaybackCluster::MediaPlay(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback)
  {
      VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
  
      app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kMediaPlayCommandId,
                                           (chip::app::CommandPathFlags::kEndpointIdValid) };
      app::Command * ZCLcommand        = mDevice->GetCommandSender();
  
      ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams));
  
      // Command takes no arguments.
  
      ReturnErrorOnFailure(ZCLcommand->FinishCommand());
  
      // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate.
      mDevice->AddIMResponseHandler(onSuccessCallback, onFailureCallback);
  
      return mDevice->SendCommands();
  }
  
  CHIP_ERROR MediaPlaybackCluster::MediaPrevious(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback)
  {
      VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
  
      app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kMediaPreviousCommandId,
                                           (chip::app::CommandPathFlags::kEndpointIdValid) };
      app::Command * ZCLcommand        = mDevice->GetCommandSender();
  
      ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams));
  
      // Command takes no arguments.
  
      ReturnErrorOnFailure(ZCLcommand->FinishCommand());
  
      // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate.
      mDevice->AddIMResponseHandler(onSuccessCallback, onFailureCallback);
  
      return mDevice->SendCommands();
  }
  
  CHIP_ERROR MediaPlaybackCluster::MediaRewind(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback)
  {
      VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
  
      app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kMediaRewindCommandId,
                                           (chip::app::CommandPathFlags::kEndpointIdValid) };
      app::Command * ZCLcommand        = mDevice->GetCommandSender();
  
      ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams));
  
      // Command takes no arguments.
  
      ReturnErrorOnFailure(ZCLcommand->FinishCommand());
  
      // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate.
      mDevice->AddIMResponseHandler(onSuccessCallback, onFailureCallback);
  
      return mDevice->SendCommands();
  }
  
  CHIP_ERROR MediaPlaybackCluster::MediaSkipBackward(Callback::Cancelable * onSuccessCallback,
                                                     Callback::Cancelable * onFailureCallback, uint64_t deltaPositionMilliseconds)
  {
      VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
  
      app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kMediaSkipBackwardCommandId,
                                           (chip::app::CommandPathFlags::kEndpointIdValid) };
      app::Command * ZCLcommand        = mDevice->GetCommandSender();
  
      ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams));
  
      TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter();
      uint8_t argSeqNumber    = 0;
      // deltaPositionMilliseconds: int64u
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), deltaPositionMilliseconds));
  
      ReturnErrorOnFailure(ZCLcommand->FinishCommand());
  
      // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate.
      mDevice->AddIMResponseHandler(onSuccessCallback, onFailureCallback);
  
      return mDevice->SendCommands();
  }
  
  CHIP_ERROR MediaPlaybackCluster::MediaSkipForward(Callback::Cancelable * onSuccessCallback,
                                                    Callback::Cancelable * onFailureCallback, uint64_t deltaPositionMilliseconds)
  {
      VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
  
      app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kMediaSkipForwardCommandId,
                                           (chip::app::CommandPathFlags::kEndpointIdValid) };
      app::Command * ZCLcommand        = mDevice->GetCommandSender();
  
      ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams));
  
      TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter();
      uint8_t argSeqNumber    = 0;
      // deltaPositionMilliseconds: int64u
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), deltaPositionMilliseconds));
  
      ReturnErrorOnFailure(ZCLcommand->FinishCommand());
  
      // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate.
      mDevice->AddIMResponseHandler(onSuccessCallback, onFailureCallback);
  
      return mDevice->SendCommands();
  }
  
  CHIP_ERROR MediaPlaybackCluster::MediaSkipSeek(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback,
                                                 uint64_t position)
  {
      VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
  
      app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kMediaSkipSeekCommandId,
                                           (chip::app::CommandPathFlags::kEndpointIdValid) };
      app::Command * ZCLcommand        = mDevice->GetCommandSender();
  
      ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams));
  
      TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter();
      uint8_t argSeqNumber    = 0;
      // position: int64u
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), position));
  
      ReturnErrorOnFailure(ZCLcommand->FinishCommand());
  
      // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate.
      mDevice->AddIMResponseHandler(onSuccessCallback, onFailureCallback);
  
      return mDevice->SendCommands();
  }
  
  CHIP_ERROR MediaPlaybackCluster::MediaStartOver(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback)
  {
      VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
  
      app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kMediaStartOverCommandId,
                                           (chip::app::CommandPathFlags::kEndpointIdValid) };
      app::Command * ZCLcommand        = mDevice->GetCommandSender();
  
      ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams));
  
      // Command takes no arguments.
  
      ReturnErrorOnFailure(ZCLcommand->FinishCommand());
  
      // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate.
      mDevice->AddIMResponseHandler(onSuccessCallback, onFailureCallback);
  
      return mDevice->SendCommands();
  }
  
  CHIP_ERROR MediaPlaybackCluster::MediaStop(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback)
  {
      VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
  
      app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kMediaStopCommandId,
                                           (chip::app::CommandPathFlags::kEndpointIdValid) };
      app::Command * ZCLcommand        = mDevice->GetCommandSender();
  
      ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams));
  
      // Command takes no arguments.
  
      ReturnErrorOnFailure(ZCLcommand->FinishCommand());
  
      // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate.
      mDevice->AddIMResponseHandler(onSuccessCallback, onFailureCallback);
  
      return mDevice->SendCommands();
  }
  
  // MediaPlayback Cluster Attributes
  CHIP_ERROR MediaPlaybackCluster::DiscoverAttributes(Callback::Cancelable * onSuccessCallback,
                                                      Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeMediaPlaybackClusterDiscoverAttributes(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  CHIP_ERROR MediaPlaybackCluster::ReadAttributeClusterRevision(Callback::Cancelable * onSuccessCallback,
                                                                Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeMediaPlaybackClusterReadClusterRevisionAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  // NetworkCommissioning Cluster Commands
  CHIP_ERROR NetworkCommissioningCluster::AddThreadNetwork(Callback::Cancelable * onSuccessCallback,
                                                           Callback::Cancelable * onFailureCallback,
                                                           chip::ByteSpan operationalDataset, uint64_t breadcrumb, uint32_t timeoutMs)
  {
      VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
  
      app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kAddThreadNetworkCommandId,
                                           (chip::app::CommandPathFlags::kEndpointIdValid) };
      app::Command * ZCLcommand        = mDevice->GetCommandSender();
  
      ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams));
  
      TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter();
      uint8_t argSeqNumber    = 0;
      // operationalDataset: octetString
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), operationalDataset));
      // breadcrumb: int64u
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), breadcrumb));
      // timeoutMs: int32u
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), timeoutMs));
  
      ReturnErrorOnFailure(ZCLcommand->FinishCommand());
  
      // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate.
      mDevice->AddIMResponseHandler(onSuccessCallback, onFailureCallback);
  
      return mDevice->SendCommands();
  }
  
  CHIP_ERROR NetworkCommissioningCluster::AddWiFiNetwork(Callback::Cancelable * onSuccessCallback,
                                                         Callback::Cancelable * onFailureCallback, chip::ByteSpan ssid,
                                                         chip::ByteSpan credentials, uint64_t breadcrumb, uint32_t timeoutMs)
  {
      VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
  
      app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kAddWiFiNetworkCommandId,
                                           (chip::app::CommandPathFlags::kEndpointIdValid) };
      app::Command * ZCLcommand        = mDevice->GetCommandSender();
  
      ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams));
  
      TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter();
      uint8_t argSeqNumber    = 0;
      // ssid: octetString
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), ssid));
      // credentials: octetString
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), credentials));
      // breadcrumb: int64u
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), breadcrumb));
      // timeoutMs: int32u
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), timeoutMs));
  
      ReturnErrorOnFailure(ZCLcommand->FinishCommand());
  
      // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate.
      mDevice->AddIMResponseHandler(onSuccessCallback, onFailureCallback);
  
      return mDevice->SendCommands();
  }
  
  CHIP_ERROR NetworkCommissioningCluster::DisableNetwork(Callback::Cancelable * onSuccessCallback,
                                                         Callback::Cancelable * onFailureCallback, chip::ByteSpan networkID,
                                                         uint64_t breadcrumb, uint32_t timeoutMs)
  {
      VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
  
      app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kDisableNetworkCommandId,
                                           (chip::app::CommandPathFlags::kEndpointIdValid) };
      app::Command * ZCLcommand        = mDevice->GetCommandSender();
  
      ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams));
  
      TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter();
      uint8_t argSeqNumber    = 0;
      // networkID: octetString
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), networkID));
      // breadcrumb: int64u
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), breadcrumb));
      // timeoutMs: int32u
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), timeoutMs));
  
      ReturnErrorOnFailure(ZCLcommand->FinishCommand());
  
      // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate.
      mDevice->AddIMResponseHandler(onSuccessCallback, onFailureCallback);
  
      return mDevice->SendCommands();
  }
  
  CHIP_ERROR NetworkCommissioningCluster::EnableNetwork(Callback::Cancelable * onSuccessCallback,
                                                        Callback::Cancelable * onFailureCallback, chip::ByteSpan networkID,
                                                        uint64_t breadcrumb, uint32_t timeoutMs)
  {
      VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
  
      app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kEnableNetworkCommandId,
                                           (chip::app::CommandPathFlags::kEndpointIdValid) };
      app::Command * ZCLcommand        = mDevice->GetCommandSender();
  
      ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams));
  
      TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter();
      uint8_t argSeqNumber    = 0;
      // networkID: octetString
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), networkID));
      // breadcrumb: int64u
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), breadcrumb));
      // timeoutMs: int32u
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), timeoutMs));
  
      ReturnErrorOnFailure(ZCLcommand->FinishCommand());
  
      // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate.
      mDevice->AddIMResponseHandler(onSuccessCallback, onFailureCallback);
  
      return mDevice->SendCommands();
  }
  
  CHIP_ERROR NetworkCommissioningCluster::GetLastNetworkCommissioningResult(Callback::Cancelable * onSuccessCallback,
                                                                            Callback::Cancelable * onFailureCallback,
                                                                            uint32_t timeoutMs)
  {
      VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
  
      app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kGetLastNetworkCommissioningResultCommandId,
                                           (chip::app::CommandPathFlags::kEndpointIdValid) };
      app::Command * ZCLcommand        = mDevice->GetCommandSender();
  
      ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams));
  
      TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter();
      uint8_t argSeqNumber    = 0;
      // timeoutMs: int32u
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), timeoutMs));
  
      ReturnErrorOnFailure(ZCLcommand->FinishCommand());
  
      // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate.
      mDevice->AddIMResponseHandler(onSuccessCallback, onFailureCallback);
  
      return mDevice->SendCommands();
  }
  
  CHIP_ERROR NetworkCommissioningCluster::RemoveNetwork(Callback::Cancelable * onSuccessCallback,
                                                        Callback::Cancelable * onFailureCallback, chip::ByteSpan networkID,
                                                        uint64_t breadcrumb, uint32_t timeoutMs)
  {
      VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
  
      app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kRemoveNetworkCommandId,
                                           (chip::app::CommandPathFlags::kEndpointIdValid) };
      app::Command * ZCLcommand        = mDevice->GetCommandSender();
  
      ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams));
  
      TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter();
      uint8_t argSeqNumber    = 0;
      // networkID: octetString
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), networkID));
      // breadcrumb: int64u
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), breadcrumb));
      // timeoutMs: int32u
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), timeoutMs));
  
      ReturnErrorOnFailure(ZCLcommand->FinishCommand());
  
      // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate.
      mDevice->AddIMResponseHandler(onSuccessCallback, onFailureCallback);
  
      return mDevice->SendCommands();
  }
  
  CHIP_ERROR NetworkCommissioningCluster::ScanNetworks(Callback::Cancelable * onSuccessCallback,
                                                       Callback::Cancelable * onFailureCallback, chip::ByteSpan ssid,
                                                       uint64_t breadcrumb, uint32_t timeoutMs)
  {
      VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
  
      app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kScanNetworksCommandId,
                                           (chip::app::CommandPathFlags::kEndpointIdValid) };
      app::Command * ZCLcommand        = mDevice->GetCommandSender();
  
      ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams));
  
      TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter();
      uint8_t argSeqNumber    = 0;
      // ssid: octetString
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), ssid));
      // breadcrumb: int64u
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), breadcrumb));
      // timeoutMs: int32u
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), timeoutMs));
  
      ReturnErrorOnFailure(ZCLcommand->FinishCommand());
  
      // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate.
      mDevice->AddIMResponseHandler(onSuccessCallback, onFailureCallback);
  
      return mDevice->SendCommands();
  }
  
  CHIP_ERROR NetworkCommissioningCluster::UpdateThreadNetwork(Callback::Cancelable * onSuccessCallback,
                                                              Callback::Cancelable * onFailureCallback,
                                                              chip::ByteSpan operationalDataset, uint64_t breadcrumb,
                                                              uint32_t timeoutMs)
  {
      VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
  
      app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kUpdateThreadNetworkCommandId,
                                           (chip::app::CommandPathFlags::kEndpointIdValid) };
      app::Command * ZCLcommand        = mDevice->GetCommandSender();
  
      ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams));
  
      TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter();
      uint8_t argSeqNumber    = 0;
      // operationalDataset: octetString
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), operationalDataset));
      // breadcrumb: int64u
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), breadcrumb));
      // timeoutMs: int32u
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), timeoutMs));
  
      ReturnErrorOnFailure(ZCLcommand->FinishCommand());
  
      // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate.
      mDevice->AddIMResponseHandler(onSuccessCallback, onFailureCallback);
  
      return mDevice->SendCommands();
  }
  
  CHIP_ERROR NetworkCommissioningCluster::UpdateWiFiNetwork(Callback::Cancelable * onSuccessCallback,
                                                            Callback::Cancelable * onFailureCallback, chip::ByteSpan ssid,
                                                            chip::ByteSpan credentials, uint64_t breadcrumb, uint32_t timeoutMs)
  {
      VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
  
      app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kUpdateWiFiNetworkCommandId,
                                           (chip::app::CommandPathFlags::kEndpointIdValid) };
      app::Command * ZCLcommand        = mDevice->GetCommandSender();
  
      ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams));
  
      TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter();
      uint8_t argSeqNumber    = 0;
      // ssid: octetString
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), ssid));
      // credentials: octetString
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), credentials));
      // breadcrumb: int64u
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), breadcrumb));
      // timeoutMs: int32u
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), timeoutMs));
  
      ReturnErrorOnFailure(ZCLcommand->FinishCommand());
  
      // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate.
      mDevice->AddIMResponseHandler(onSuccessCallback, onFailureCallback);
  
      return mDevice->SendCommands();
  }
  
  // NetworkCommissioning Cluster Attributes
  CHIP_ERROR NetworkCommissioningCluster::DiscoverAttributes(Callback::Cancelable * onSuccessCallback,
                                                             Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeNetworkCommissioningClusterDiscoverAttributes(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  CHIP_ERROR NetworkCommissioningCluster::ReadAttributeClusterRevision(Callback::Cancelable * onSuccessCallback,
                                                                       Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeNetworkCommissioningClusterReadClusterRevisionAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  // OnOff Cluster Commands
  CHIP_ERROR OnOffCluster::Off(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback)
  {
      VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
  
      app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kOffCommandId,
                                           (chip::app::CommandPathFlags::kEndpointIdValid) };
      app::Command * ZCLcommand        = mDevice->GetCommandSender();
  
      ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams));
  
      // Command takes no arguments.
  
      ReturnErrorOnFailure(ZCLcommand->FinishCommand());
  
      // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate.
      mDevice->AddIMResponseHandler(onSuccessCallback, onFailureCallback);
  
      return mDevice->SendCommands();
  }
  
  CHIP_ERROR OnOffCluster::On(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback)
  {
      VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
  
      app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kOnCommandId,
                                           (chip::app::CommandPathFlags::kEndpointIdValid) };
      app::Command * ZCLcommand        = mDevice->GetCommandSender();
  
      ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams));
  
      // Command takes no arguments.
  
      ReturnErrorOnFailure(ZCLcommand->FinishCommand());
  
      // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate.
      mDevice->AddIMResponseHandler(onSuccessCallback, onFailureCallback);
  
      return mDevice->SendCommands();
  }
  
  CHIP_ERROR OnOffCluster::Toggle(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback)
  {
      VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
  
      app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kToggleCommandId,
                                           (chip::app::CommandPathFlags::kEndpointIdValid) };
      app::Command * ZCLcommand        = mDevice->GetCommandSender();
  
      ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams));
  
      // Command takes no arguments.
  
      ReturnErrorOnFailure(ZCLcommand->FinishCommand());
  
      // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate.
      mDevice->AddIMResponseHandler(onSuccessCallback, onFailureCallback);
  
      return mDevice->SendCommands();
  }
  
  // OnOff Cluster Attributes
  CHIP_ERROR OnOffCluster::DiscoverAttributes(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeOnOffClusterDiscoverAttributes(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  CHIP_ERROR OnOffCluster::ReadAttributeOnOff(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeOnOffClusterReadOnOffAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR OnOffCluster::ConfigureAttributeOnOff(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback,
                                                   uint16_t minInterval, uint16_t maxInterval)
  {
      uint8_t seqNum = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand =
          encodeOnOffClusterConfigureOnOffAttribute(seqNum, mEndpoint, minInterval, maxInterval);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR OnOffCluster::ReportAttributeOnOff(Callback::Cancelable * onReportCallback)
  {
      return RequestAttributeReporting(0x0000, onReportCallback);
  }
  
  CHIP_ERROR OnOffCluster::ReadAttributeClusterRevision(Callback::Cancelable * onSuccessCallback,
                                                        Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeOnOffClusterReadClusterRevisionAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  // OperationalCredentials Cluster Commands
  CHIP_ERROR OperationalCredentialsCluster::RemoveAllFabrics(Callback::Cancelable * onSuccessCallback,
                                                             Callback::Cancelable * onFailureCallback)
  {
      VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
  
      app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kRemoveAllFabricsCommandId,
                                           (chip::app::CommandPathFlags::kEndpointIdValid) };
      app::Command * ZCLcommand        = mDevice->GetCommandSender();
  
      ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams));
  
      // Command takes no arguments.
  
      ReturnErrorOnFailure(ZCLcommand->FinishCommand());
  
      // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate.
      mDevice->AddIMResponseHandler(onSuccessCallback, onFailureCallback);
  
      return mDevice->SendCommands();
  }
  
  CHIP_ERROR OperationalCredentialsCluster::RemoveFabric(Callback::Cancelable * onSuccessCallback,
                                                         Callback::Cancelable * onFailureCallback, chip::FabricId fabricId,
                                                         chip::NodeId nodeId, uint16_t vendorId)
  {
      VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
  
      app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kRemoveFabricCommandId,
                                           (chip::app::CommandPathFlags::kEndpointIdValid) };
      app::Command * ZCLcommand        = mDevice->GetCommandSender();
  
      ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams));
  
      TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter();
      uint8_t argSeqNumber    = 0;
      // fabricId: fabricId
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), fabricId));
      // nodeId: nodeId
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), nodeId));
      // vendorId: int16u
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), vendorId));
  
      ReturnErrorOnFailure(ZCLcommand->FinishCommand());
  
      // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate.
      mDevice->AddIMResponseHandler(onSuccessCallback, onFailureCallback);
  
      return mDevice->SendCommands();
  }
  
  CHIP_ERROR OperationalCredentialsCluster::SetFabric(Callback::Cancelable * onSuccessCallback,
                                                      Callback::Cancelable * onFailureCallback, uint16_t vendorId)
  {
      VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
  
      app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kSetFabricCommandId,
                                           (chip::app::CommandPathFlags::kEndpointIdValid) };
      app::Command * ZCLcommand        = mDevice->GetCommandSender();
  
      ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams));
  
      TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter();
      uint8_t argSeqNumber    = 0;
      // vendorId: int16u
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), vendorId));
  
      ReturnErrorOnFailure(ZCLcommand->FinishCommand());
  
      // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate.
      mDevice->AddIMResponseHandler(onSuccessCallback, onFailureCallback);
  
      return mDevice->SendCommands();
  }
  
  CHIP_ERROR OperationalCredentialsCluster::UpdateFabricLabel(Callback::Cancelable * onSuccessCallback,
                                                              Callback::Cancelable * onFailureCallback, chip::ByteSpan label)
  {
      VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
  
      app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kUpdateFabricLabelCommandId,
                                           (chip::app::CommandPathFlags::kEndpointIdValid) };
      app::Command * ZCLcommand        = mDevice->GetCommandSender();
  
      ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams));
  
      TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter();
      uint8_t argSeqNumber    = 0;
      // label: charString
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), label));
  
      ReturnErrorOnFailure(ZCLcommand->FinishCommand());
  
      // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate.
      mDevice->AddIMResponseHandler(onSuccessCallback, onFailureCallback);
  
      return mDevice->SendCommands();
  }
  
  // OperationalCredentials Cluster Attributes
  CHIP_ERROR OperationalCredentialsCluster::DiscoverAttributes(Callback::Cancelable * onSuccessCallback,
                                                               Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeOperationalCredentialsClusterDiscoverAttributes(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  CHIP_ERROR OperationalCredentialsCluster::ReadAttributeFabricsList(Callback::Cancelable * onSuccessCallback,
                                                                     Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeOperationalCredentialsClusterReadFabricsListAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR OperationalCredentialsCluster::ReadAttributeClusterRevision(Callback::Cancelable * onSuccessCallback,
                                                                         Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeOperationalCredentialsClusterReadClusterRevisionAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  // PumpConfigurationAndControl Cluster Commands
  // PumpConfigurationAndControl Cluster Attributes
  CHIP_ERROR PumpConfigurationAndControlCluster::DiscoverAttributes(Callback::Cancelable * onSuccessCallback,
                                                                    Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodePumpConfigurationAndControlClusterDiscoverAttributes(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  CHIP_ERROR PumpConfigurationAndControlCluster::ReadAttributeMaxPressure(Callback::Cancelable * onSuccessCallback,
                                                                          Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodePumpConfigurationAndControlClusterReadMaxPressureAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR PumpConfigurationAndControlCluster::ReadAttributeMaxSpeed(Callback::Cancelable * onSuccessCallback,
                                                                       Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodePumpConfigurationAndControlClusterReadMaxSpeedAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR PumpConfigurationAndControlCluster::ReadAttributeMaxFlow(Callback::Cancelable * onSuccessCallback,
                                                                      Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodePumpConfigurationAndControlClusterReadMaxFlowAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR PumpConfigurationAndControlCluster::ReadAttributeEffectiveOperationMode(Callback::Cancelable * onSuccessCallback,
                                                                                     Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand =
          encodePumpConfigurationAndControlClusterReadEffectiveOperationModeAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR PumpConfigurationAndControlCluster::ReadAttributeEffectiveControlMode(Callback::Cancelable * onSuccessCallback,
                                                                                   Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand =
          encodePumpConfigurationAndControlClusterReadEffectiveControlModeAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR PumpConfigurationAndControlCluster::ReadAttributeCapacity(Callback::Cancelable * onSuccessCallback,
                                                                       Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodePumpConfigurationAndControlClusterReadCapacityAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR PumpConfigurationAndControlCluster::ConfigureAttributeCapacity(Callback::Cancelable * onSuccessCallback,
                                                                            Callback::Cancelable * onFailureCallback,
                                                                            uint16_t minInterval, uint16_t maxInterval,
                                                                            int16_t change)
  {
      uint8_t seqNum = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand =
          encodePumpConfigurationAndControlClusterConfigureCapacityAttribute(seqNum, mEndpoint, minInterval, maxInterval, change);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR PumpConfigurationAndControlCluster::ReportAttributeCapacity(Callback::Cancelable * onReportCallback)
  {
      return RequestAttributeReporting(0x0013, onReportCallback);
  }
  
  CHIP_ERROR PumpConfigurationAndControlCluster::ReadAttributeOperationMode(Callback::Cancelable * onSuccessCallback,
                                                                            Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand =
          encodePumpConfigurationAndControlClusterReadOperationModeAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR PumpConfigurationAndControlCluster::WriteAttributeOperationMode(Callback::Cancelable * onSuccessCallback,
                                                                             Callback::Cancelable * onFailureCallback, uint8_t value)
  {
      uint8_t seqNum = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand =
          encodePumpConfigurationAndControlClusterWriteOperationModeAttribute(seqNum, mEndpoint, value);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR PumpConfigurationAndControlCluster::ReadAttributeClusterRevision(Callback::Cancelable * onSuccessCallback,
                                                                              Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand =
          encodePumpConfigurationAndControlClusterReadClusterRevisionAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  // Scenes Cluster Commands
  CHIP_ERROR ScenesCluster::AddScene(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback,
                                     uint16_t groupId, uint8_t sceneId, uint16_t transitionTime, chip::ByteSpan sceneName,
                                     chip::ClusterId clusterId, uint8_t length, uint8_t value)
  {
      VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
  
      app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kAddSceneCommandId,
                                           (chip::app::CommandPathFlags::kEndpointIdValid) };
      app::Command * ZCLcommand        = mDevice->GetCommandSender();
  
      ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams));
  
      TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter();
      uint8_t argSeqNumber    = 0;
      // groupId: int16u
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), groupId));
      // sceneId: int8u
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), sceneId));
      // transitionTime: int16u
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), transitionTime));
      // sceneName: charString
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), sceneName));
      // clusterId: clusterId
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), clusterId));
      // length: int8u
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), length));
      // value: int8u
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), value));
  
      ReturnErrorOnFailure(ZCLcommand->FinishCommand());
  
      // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate.
      mDevice->AddIMResponseHandler(onSuccessCallback, onFailureCallback);
  
      return mDevice->SendCommands();
  }
  
  CHIP_ERROR ScenesCluster::GetSceneMembership(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback,
                                               uint16_t groupId)
  {
      VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
  
      app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kGetSceneMembershipCommandId,
                                           (chip::app::CommandPathFlags::kEndpointIdValid) };
      app::Command * ZCLcommand        = mDevice->GetCommandSender();
  
      ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams));
  
      TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter();
      uint8_t argSeqNumber    = 0;
      // groupId: int16u
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), groupId));
  
      ReturnErrorOnFailure(ZCLcommand->FinishCommand());
  
      // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate.
      mDevice->AddIMResponseHandler(onSuccessCallback, onFailureCallback);
  
      return mDevice->SendCommands();
  }
  
  CHIP_ERROR ScenesCluster::RecallScene(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback,
                                        uint16_t groupId, uint8_t sceneId, uint16_t transitionTime)
  {
      VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
  
      app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kRecallSceneCommandId,
                                           (chip::app::CommandPathFlags::kEndpointIdValid) };
      app::Command * ZCLcommand        = mDevice->GetCommandSender();
  
      ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams));
  
      TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter();
      uint8_t argSeqNumber    = 0;
      // groupId: int16u
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), groupId));
      // sceneId: int8u
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), sceneId));
      // transitionTime: int16u
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), transitionTime));
  
      ReturnErrorOnFailure(ZCLcommand->FinishCommand());
  
      // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate.
      mDevice->AddIMResponseHandler(onSuccessCallback, onFailureCallback);
  
      return mDevice->SendCommands();
  }
  
  CHIP_ERROR ScenesCluster::RemoveAllScenes(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback,
                                            uint16_t groupId)
  {
      VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
  
      app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kRemoveAllScenesCommandId,
                                           (chip::app::CommandPathFlags::kEndpointIdValid) };
      app::Command * ZCLcommand        = mDevice->GetCommandSender();
  
      ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams));
  
      TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter();
      uint8_t argSeqNumber    = 0;
      // groupId: int16u
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), groupId));
  
      ReturnErrorOnFailure(ZCLcommand->FinishCommand());
  
      // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate.
      mDevice->AddIMResponseHandler(onSuccessCallback, onFailureCallback);
  
      return mDevice->SendCommands();
  }
  
  CHIP_ERROR ScenesCluster::RemoveScene(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback,
                                        uint16_t groupId, uint8_t sceneId)
  {
      VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
  
      app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kRemoveSceneCommandId,
                                           (chip::app::CommandPathFlags::kEndpointIdValid) };
      app::Command * ZCLcommand        = mDevice->GetCommandSender();
  
      ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams));
  
      TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter();
      uint8_t argSeqNumber    = 0;
      // groupId: int16u
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), groupId));
      // sceneId: int8u
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), sceneId));
  
      ReturnErrorOnFailure(ZCLcommand->FinishCommand());
  
      // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate.
      mDevice->AddIMResponseHandler(onSuccessCallback, onFailureCallback);
  
      return mDevice->SendCommands();
  }
  
  CHIP_ERROR ScenesCluster::StoreScene(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback,
                                       uint16_t groupId, uint8_t sceneId)
  {
      VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
  
      app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kStoreSceneCommandId,
                                           (chip::app::CommandPathFlags::kEndpointIdValid) };
      app::Command * ZCLcommand        = mDevice->GetCommandSender();
  
      ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams));
  
      TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter();
      uint8_t argSeqNumber    = 0;
      // groupId: int16u
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), groupId));
      // sceneId: int8u
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), sceneId));
  
      ReturnErrorOnFailure(ZCLcommand->FinishCommand());
  
      // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate.
      mDevice->AddIMResponseHandler(onSuccessCallback, onFailureCallback);
  
      return mDevice->SendCommands();
  }
  
  CHIP_ERROR ScenesCluster::ViewScene(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback,
                                      uint16_t groupId, uint8_t sceneId)
  {
      VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
  
      app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kViewSceneCommandId,
                                           (chip::app::CommandPathFlags::kEndpointIdValid) };
      app::Command * ZCLcommand        = mDevice->GetCommandSender();
  
      ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams));
  
      TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter();
      uint8_t argSeqNumber    = 0;
      // groupId: int16u
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), groupId));
      // sceneId: int8u
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), sceneId));
  
      ReturnErrorOnFailure(ZCLcommand->FinishCommand());
  
      // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate.
      mDevice->AddIMResponseHandler(onSuccessCallback, onFailureCallback);
  
      return mDevice->SendCommands();
  }
  
  // Scenes Cluster Attributes
  CHIP_ERROR ScenesCluster::DiscoverAttributes(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeScenesClusterDiscoverAttributes(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  CHIP_ERROR ScenesCluster::ReadAttributeSceneCount(Callback::Cancelable * onSuccessCallback,
                                                    Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeScenesClusterReadSceneCountAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR ScenesCluster::ReadAttributeCurrentScene(Callback::Cancelable * onSuccessCallback,
                                                      Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeScenesClusterReadCurrentSceneAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR ScenesCluster::ReadAttributeCurrentGroup(Callback::Cancelable * onSuccessCallback,
                                                      Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeScenesClusterReadCurrentGroupAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR ScenesCluster::ReadAttributeSceneValid(Callback::Cancelable * onSuccessCallback,
                                                    Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeScenesClusterReadSceneValidAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR ScenesCluster::ReadAttributeNameSupport(Callback::Cancelable * onSuccessCallback,
                                                     Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeScenesClusterReadNameSupportAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR ScenesCluster::ReadAttributeClusterRevision(Callback::Cancelable * onSuccessCallback,
                                                         Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeScenesClusterReadClusterRevisionAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  // Switch Cluster Commands
  // Switch Cluster Attributes
  CHIP_ERROR SwitchCluster::DiscoverAttributes(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeSwitchClusterDiscoverAttributes(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  CHIP_ERROR SwitchCluster::ReadAttributeNumberOfPositions(Callback::Cancelable * onSuccessCallback,
                                                           Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeSwitchClusterReadNumberOfPositionsAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR SwitchCluster::ReadAttributeCurrentPosition(Callback::Cancelable * onSuccessCallback,
                                                         Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeSwitchClusterReadCurrentPositionAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR SwitchCluster::ConfigureAttributeCurrentPosition(Callback::Cancelable * onSuccessCallback,
                                                              Callback::Cancelable * onFailureCallback, uint16_t minInterval,
                                                              uint16_t maxInterval, uint8_t change)
  {
      uint8_t seqNum = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand =
          encodeSwitchClusterConfigureCurrentPositionAttribute(seqNum, mEndpoint, minInterval, maxInterval, change);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR SwitchCluster::ReportAttributeCurrentPosition(Callback::Cancelable * onReportCallback)
  {
      return RequestAttributeReporting(0x0001, onReportCallback);
  }
  
  CHIP_ERROR SwitchCluster::ReadAttributeClusterRevision(Callback::Cancelable * onSuccessCallback,
                                                         Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeSwitchClusterReadClusterRevisionAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  // TvChannel Cluster Commands
  CHIP_ERROR TvChannelCluster::ChangeChannel(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback,
                                             chip::ByteSpan match)
  {
      VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
  
      app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kChangeChannelCommandId,
                                           (chip::app::CommandPathFlags::kEndpointIdValid) };
      app::Command * ZCLcommand        = mDevice->GetCommandSender();
  
      ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams));
  
      TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter();
      uint8_t argSeqNumber    = 0;
      // match: charString
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), match));
  
      ReturnErrorOnFailure(ZCLcommand->FinishCommand());
  
      // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate.
      mDevice->AddIMResponseHandler(onSuccessCallback, onFailureCallback);
  
      return mDevice->SendCommands();
  }
  
  CHIP_ERROR TvChannelCluster::ChangeChannelByNumber(Callback::Cancelable * onSuccessCallback,
                                                     Callback::Cancelable * onFailureCallback, uint16_t majorNumber,
                                                     uint16_t minorNumber)
  {
      VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
  
      app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kChangeChannelByNumberCommandId,
                                           (chip::app::CommandPathFlags::kEndpointIdValid) };
      app::Command * ZCLcommand        = mDevice->GetCommandSender();
  
      ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams));
  
      TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter();
      uint8_t argSeqNumber    = 0;
      // majorNumber: int16u
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), majorNumber));
      // minorNumber: int16u
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), minorNumber));
  
      ReturnErrorOnFailure(ZCLcommand->FinishCommand());
  
      // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate.
      mDevice->AddIMResponseHandler(onSuccessCallback, onFailureCallback);
  
      return mDevice->SendCommands();
  }
  
  CHIP_ERROR TvChannelCluster::SkipChannel(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback,
                                           uint16_t count)
  {
      VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
  
      app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kSkipChannelCommandId,
                                           (chip::app::CommandPathFlags::kEndpointIdValid) };
      app::Command * ZCLcommand        = mDevice->GetCommandSender();
  
      ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams));
  
      TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter();
      uint8_t argSeqNumber    = 0;
      // count: int16u
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), count));
  
      ReturnErrorOnFailure(ZCLcommand->FinishCommand());
  
      // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate.
      mDevice->AddIMResponseHandler(onSuccessCallback, onFailureCallback);
  
      return mDevice->SendCommands();
  }
  
  // TvChannel Cluster Attributes
  CHIP_ERROR TvChannelCluster::DiscoverAttributes(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeTvChannelClusterDiscoverAttributes(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  CHIP_ERROR TvChannelCluster::ReadAttributeTvChannelList(Callback::Cancelable * onSuccessCallback,
                                                          Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeTvChannelClusterReadTvChannelListAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR TvChannelCluster::ReadAttributeTvChannelLineup(Callback::Cancelable * onSuccessCallback,
                                                            Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeTvChannelClusterReadTvChannelLineupAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR TvChannelCluster::ReadAttributeCurrentTvChannel(Callback::Cancelable * onSuccessCallback,
                                                             Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeTvChannelClusterReadCurrentTvChannelAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR TvChannelCluster::ReadAttributeClusterRevision(Callback::Cancelable * onSuccessCallback,
                                                            Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeTvChannelClusterReadClusterRevisionAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  // TargetNavigator Cluster Commands
  CHIP_ERROR TargetNavigatorCluster::NavigateTarget(Callback::Cancelable * onSuccessCallback,
                                                    Callback::Cancelable * onFailureCallback, uint8_t target, chip::ByteSpan data)
  {
      VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
  
      app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kNavigateTargetCommandId,
                                           (chip::app::CommandPathFlags::kEndpointIdValid) };
      app::Command * ZCLcommand        = mDevice->GetCommandSender();
  
      ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams));
  
      TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter();
      uint8_t argSeqNumber    = 0;
      // target: int8u
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), target));
      // data: charString
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), data));
  
      ReturnErrorOnFailure(ZCLcommand->FinishCommand());
  
      // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate.
      mDevice->AddIMResponseHandler(onSuccessCallback, onFailureCallback);
  
      return mDevice->SendCommands();
  }
  
  // TargetNavigator Cluster Attributes
  CHIP_ERROR TargetNavigatorCluster::DiscoverAttributes(Callback::Cancelable * onSuccessCallback,
                                                        Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeTargetNavigatorClusterDiscoverAttributes(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  CHIP_ERROR TargetNavigatorCluster::ReadAttributeTargetNavigatorList(Callback::Cancelable * onSuccessCallback,
                                                                      Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeTargetNavigatorClusterReadTargetNavigatorListAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR TargetNavigatorCluster::ReadAttributeClusterRevision(Callback::Cancelable * onSuccessCallback,
                                                                  Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeTargetNavigatorClusterReadClusterRevisionAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  // TemperatureMeasurement Cluster Commands
  // TemperatureMeasurement Cluster Attributes
  CHIP_ERROR TemperatureMeasurementCluster::DiscoverAttributes(Callback::Cancelable * onSuccessCallback,
                                                               Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeTemperatureMeasurementClusterDiscoverAttributes(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  CHIP_ERROR TemperatureMeasurementCluster::ReadAttributeMeasuredValue(Callback::Cancelable * onSuccessCallback,
                                                                       Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeTemperatureMeasurementClusterReadMeasuredValueAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR TemperatureMeasurementCluster::ConfigureAttributeMeasuredValue(Callback::Cancelable * onSuccessCallback,
                                                                            Callback::Cancelable * onFailureCallback,
                                                                            uint16_t minInterval, uint16_t maxInterval,
                                                                            int16_t change)
  {
      uint8_t seqNum = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand =
          encodeTemperatureMeasurementClusterConfigureMeasuredValueAttribute(seqNum, mEndpoint, minInterval, maxInterval, change);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR TemperatureMeasurementCluster::ReportAttributeMeasuredValue(Callback::Cancelable * onReportCallback)
  {
      return RequestAttributeReporting(0x0000, onReportCallback);
  }
  
  CHIP_ERROR TemperatureMeasurementCluster::ReadAttributeMinMeasuredValue(Callback::Cancelable * onSuccessCallback,
                                                                          Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeTemperatureMeasurementClusterReadMinMeasuredValueAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR TemperatureMeasurementCluster::ReadAttributeMaxMeasuredValue(Callback::Cancelable * onSuccessCallback,
                                                                          Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeTemperatureMeasurementClusterReadMaxMeasuredValueAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR TemperatureMeasurementCluster::ReadAttributeClusterRevision(Callback::Cancelable * onSuccessCallback,
                                                                         Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeTemperatureMeasurementClusterReadClusterRevisionAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  // TestCluster Cluster Commands
  CHIP_ERROR TestClusterCluster::Test(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback)
  {
      VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
  
      app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kTestCommandId,
                                           (chip::app::CommandPathFlags::kEndpointIdValid) };
      app::Command * ZCLcommand        = mDevice->GetCommandSender();
  
      ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams));
  
      // Command takes no arguments.
  
      ReturnErrorOnFailure(ZCLcommand->FinishCommand());
  
      // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate.
      mDevice->AddIMResponseHandler(onSuccessCallback, onFailureCallback);
  
      return mDevice->SendCommands();
  }
  
  CHIP_ERROR TestClusterCluster::TestNotHandled(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback)
  {
      VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
  
      app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kTestNotHandledCommandId,
                                           (chip::app::CommandPathFlags::kEndpointIdValid) };
      app::Command * ZCLcommand        = mDevice->GetCommandSender();
  
      ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams));
  
      // Command takes no arguments.
  
      ReturnErrorOnFailure(ZCLcommand->FinishCommand());
  
      // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate.
      mDevice->AddIMResponseHandler(onSuccessCallback, onFailureCallback);
  
      return mDevice->SendCommands();
  }
  
  CHIP_ERROR TestClusterCluster::TestSpecific(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback)
  {
      VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
  
      app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kTestSpecificCommandId,
                                           (chip::app::CommandPathFlags::kEndpointIdValid) };
      app::Command * ZCLcommand        = mDevice->GetCommandSender();
  
      ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams));
  
      // Command takes no arguments.
  
      ReturnErrorOnFailure(ZCLcommand->FinishCommand());
  
      // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate.
      mDevice->AddIMResponseHandler(onSuccessCallback, onFailureCallback);
  
      return mDevice->SendCommands();
  }
  
  // TestCluster Cluster Attributes
  CHIP_ERROR TestClusterCluster::DiscoverAttributes(Callback::Cancelable * onSuccessCallback,
                                                    Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeTestClusterClusterDiscoverAttributes(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  CHIP_ERROR TestClusterCluster::ReadAttributeBoolean(Callback::Cancelable * onSuccessCallback,
                                                      Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeTestClusterClusterReadBooleanAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR TestClusterCluster::WriteAttributeBoolean(Callback::Cancelable * onSuccessCallback,
                                                       Callback::Cancelable * onFailureCallback, uint8_t value)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeTestClusterClusterWriteBooleanAttribute(seqNum, mEndpoint, value);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR TestClusterCluster::ReadAttributeBitmap8(Callback::Cancelable * onSuccessCallback,
                                                      Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeTestClusterClusterReadBitmap8Attribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR TestClusterCluster::WriteAttributeBitmap8(Callback::Cancelable * onSuccessCallback,
                                                       Callback::Cancelable * onFailureCallback, uint8_t value)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeTestClusterClusterWriteBitmap8Attribute(seqNum, mEndpoint, value);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR TestClusterCluster::ReadAttributeBitmap16(Callback::Cancelable * onSuccessCallback,
                                                       Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeTestClusterClusterReadBitmap16Attribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR TestClusterCluster::WriteAttributeBitmap16(Callback::Cancelable * onSuccessCallback,
                                                        Callback::Cancelable * onFailureCallback, uint16_t value)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeTestClusterClusterWriteBitmap16Attribute(seqNum, mEndpoint, value);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR TestClusterCluster::ReadAttributeBitmap32(Callback::Cancelable * onSuccessCallback,
                                                       Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeTestClusterClusterReadBitmap32Attribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR TestClusterCluster::WriteAttributeBitmap32(Callback::Cancelable * onSuccessCallback,
                                                        Callback::Cancelable * onFailureCallback, uint32_t value)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeTestClusterClusterWriteBitmap32Attribute(seqNum, mEndpoint, value);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR TestClusterCluster::ReadAttributeBitmap64(Callback::Cancelable * onSuccessCallback,
                                                       Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeTestClusterClusterReadBitmap64Attribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR TestClusterCluster::WriteAttributeBitmap64(Callback::Cancelable * onSuccessCallback,
                                                        Callback::Cancelable * onFailureCallback, uint64_t value)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeTestClusterClusterWriteBitmap64Attribute(seqNum, mEndpoint, value);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR TestClusterCluster::ReadAttributeInt8u(Callback::Cancelable * onSuccessCallback,
                                                    Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeTestClusterClusterReadInt8uAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR TestClusterCluster::WriteAttributeInt8u(Callback::Cancelable * onSuccessCallback,
                                                     Callback::Cancelable * onFailureCallback, uint8_t value)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeTestClusterClusterWriteInt8uAttribute(seqNum, mEndpoint, value);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR TestClusterCluster::ReadAttributeInt16u(Callback::Cancelable * onSuccessCallback,
                                                     Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeTestClusterClusterReadInt16uAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR TestClusterCluster::WriteAttributeInt16u(Callback::Cancelable * onSuccessCallback,
                                                      Callback::Cancelable * onFailureCallback, uint16_t value)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeTestClusterClusterWriteInt16uAttribute(seqNum, mEndpoint, value);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR TestClusterCluster::ReadAttributeInt32u(Callback::Cancelable * onSuccessCallback,
                                                     Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeTestClusterClusterReadInt32uAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR TestClusterCluster::WriteAttributeInt32u(Callback::Cancelable * onSuccessCallback,
                                                      Callback::Cancelable * onFailureCallback, uint32_t value)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeTestClusterClusterWriteInt32uAttribute(seqNum, mEndpoint, value);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR TestClusterCluster::ReadAttributeInt64u(Callback::Cancelable * onSuccessCallback,
                                                     Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeTestClusterClusterReadInt64uAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR TestClusterCluster::WriteAttributeInt64u(Callback::Cancelable * onSuccessCallback,
                                                      Callback::Cancelable * onFailureCallback, uint64_t value)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeTestClusterClusterWriteInt64uAttribute(seqNum, mEndpoint, value);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR TestClusterCluster::ReadAttributeInt8s(Callback::Cancelable * onSuccessCallback,
                                                    Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeTestClusterClusterReadInt8sAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR TestClusterCluster::WriteAttributeInt8s(Callback::Cancelable * onSuccessCallback,
                                                     Callback::Cancelable * onFailureCallback, int8_t value)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeTestClusterClusterWriteInt8sAttribute(seqNum, mEndpoint, value);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR TestClusterCluster::ReadAttributeInt16s(Callback::Cancelable * onSuccessCallback,
                                                     Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeTestClusterClusterReadInt16sAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR TestClusterCluster::WriteAttributeInt16s(Callback::Cancelable * onSuccessCallback,
                                                      Callback::Cancelable * onFailureCallback, int16_t value)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeTestClusterClusterWriteInt16sAttribute(seqNum, mEndpoint, value);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR TestClusterCluster::ReadAttributeInt32s(Callback::Cancelable * onSuccessCallback,
                                                     Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeTestClusterClusterReadInt32sAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR TestClusterCluster::WriteAttributeInt32s(Callback::Cancelable * onSuccessCallback,
                                                      Callback::Cancelable * onFailureCallback, int32_t value)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeTestClusterClusterWriteInt32sAttribute(seqNum, mEndpoint, value);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR TestClusterCluster::ReadAttributeInt64s(Callback::Cancelable * onSuccessCallback,
                                                     Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeTestClusterClusterReadInt64sAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR TestClusterCluster::WriteAttributeInt64s(Callback::Cancelable * onSuccessCallback,
                                                      Callback::Cancelable * onFailureCallback, int64_t value)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeTestClusterClusterWriteInt64sAttribute(seqNum, mEndpoint, value);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR TestClusterCluster::ReadAttributeEnum8(Callback::Cancelable * onSuccessCallback,
                                                    Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeTestClusterClusterReadEnum8Attribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR TestClusterCluster::WriteAttributeEnum8(Callback::Cancelable * onSuccessCallback,
                                                     Callback::Cancelable * onFailureCallback, uint8_t value)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeTestClusterClusterWriteEnum8Attribute(seqNum, mEndpoint, value);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR TestClusterCluster::ReadAttributeEnum16(Callback::Cancelable * onSuccessCallback,
                                                     Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeTestClusterClusterReadEnum16Attribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR TestClusterCluster::WriteAttributeEnum16(Callback::Cancelable * onSuccessCallback,
                                                      Callback::Cancelable * onFailureCallback, uint16_t value)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeTestClusterClusterWriteEnum16Attribute(seqNum, mEndpoint, value);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR TestClusterCluster::ReadAttributeOctetString(Callback::Cancelable * onSuccessCallback,
                                                          Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeTestClusterClusterReadOctetStringAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR TestClusterCluster::WriteAttributeOctetString(Callback::Cancelable * onSuccessCallback,
                                                           Callback::Cancelable * onFailureCallback, chip::ByteSpan value)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeTestClusterClusterWriteOctetStringAttribute(seqNum, mEndpoint, value);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR TestClusterCluster::ReadAttributeListInt8u(Callback::Cancelable * onSuccessCallback,
                                                        Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeTestClusterClusterReadListInt8uAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR TestClusterCluster::ReadAttributeListOctetString(Callback::Cancelable * onSuccessCallback,
                                                              Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeTestClusterClusterReadListOctetStringAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR TestClusterCluster::ReadAttributeListStructOctetString(Callback::Cancelable * onSuccessCallback,
                                                                    Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeTestClusterClusterReadListStructOctetStringAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR TestClusterCluster::ReadAttributeClusterRevision(Callback::Cancelable * onSuccessCallback,
                                                              Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeTestClusterClusterReadClusterRevisionAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  // Thermostat Cluster Commands
  CHIP_ERROR ThermostatCluster::ClearWeeklySchedule(Callback::Cancelable * onSuccessCallback,
                                                    Callback::Cancelable * onFailureCallback)
  {
      VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
  
      app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kClearWeeklyScheduleCommandId,
                                           (chip::app::CommandPathFlags::kEndpointIdValid) };
      app::Command * ZCLcommand        = mDevice->GetCommandSender();
  
      ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams));
  
      // Command takes no arguments.
  
      ReturnErrorOnFailure(ZCLcommand->FinishCommand());
  
      // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate.
      mDevice->AddIMResponseHandler(onSuccessCallback, onFailureCallback);
  
      return mDevice->SendCommands();
  }
  
  CHIP_ERROR ThermostatCluster::GetRelayStatusLog(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback)
  {
      VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
  
      app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kGetRelayStatusLogCommandId,
                                           (chip::app::CommandPathFlags::kEndpointIdValid) };
      app::Command * ZCLcommand        = mDevice->GetCommandSender();
  
      ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams));
  
      // Command takes no arguments.
  
      ReturnErrorOnFailure(ZCLcommand->FinishCommand());
  
      // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate.
      mDevice->AddIMResponseHandler(onSuccessCallback, onFailureCallback);
  
      return mDevice->SendCommands();
  }
  
  CHIP_ERROR ThermostatCluster::GetWeeklySchedule(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback,
                                                  uint8_t daysToReturn, uint8_t modeToReturn)
  {
      VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
  
      app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kGetWeeklyScheduleCommandId,
                                           (chip::app::CommandPathFlags::kEndpointIdValid) };
      app::Command * ZCLcommand        = mDevice->GetCommandSender();
  
      ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams));
  
      TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter();
      uint8_t argSeqNumber    = 0;
      // daysToReturn: dayOfWeek
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), daysToReturn));
      // modeToReturn: modeForSequence
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), modeToReturn));
  
      ReturnErrorOnFailure(ZCLcommand->FinishCommand());
  
      // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate.
      mDevice->AddIMResponseHandler(onSuccessCallback, onFailureCallback);
  
      return mDevice->SendCommands();
  }
  
  CHIP_ERROR ThermostatCluster::SetWeeklySchedule(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback,
                                                  uint8_t numberOfTransitionsForSequence, uint8_t dayOfWeekForSequence,
                                                  uint8_t modeForSequence, uint8_t payload)
  {
      VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
  
      app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kSetWeeklyScheduleCommandId,
                                           (chip::app::CommandPathFlags::kEndpointIdValid) };
      app::Command * ZCLcommand        = mDevice->GetCommandSender();
  
      ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams));
  
      TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter();
      uint8_t argSeqNumber    = 0;
      // numberOfTransitionsForSequence: enum8
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), numberOfTransitionsForSequence));
      // dayOfWeekForSequence: dayOfWeek
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), dayOfWeekForSequence));
      // modeForSequence: modeForSequence
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), modeForSequence));
      // payload: int8u
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), payload));
  
      ReturnErrorOnFailure(ZCLcommand->FinishCommand());
  
      // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate.
      mDevice->AddIMResponseHandler(onSuccessCallback, onFailureCallback);
  
      return mDevice->SendCommands();
  }
  
  CHIP_ERROR ThermostatCluster::SetpointRaiseLower(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback,
                                                   uint8_t mode, int8_t amount)
  {
      VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
  
      app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kSetpointRaiseLowerCommandId,
                                           (chip::app::CommandPathFlags::kEndpointIdValid) };
      app::Command * ZCLcommand        = mDevice->GetCommandSender();
  
      ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams));
  
      TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter();
      uint8_t argSeqNumber    = 0;
      // mode: setpointAdjustMode
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), mode));
      // amount: int8s
      ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), amount));
  
      ReturnErrorOnFailure(ZCLcommand->FinishCommand());
  
      // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate.
      mDevice->AddIMResponseHandler(onSuccessCallback, onFailureCallback);
  
      return mDevice->SendCommands();
  }
  
  // Thermostat Cluster Attributes
  CHIP_ERROR ThermostatCluster::DiscoverAttributes(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeThermostatClusterDiscoverAttributes(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  CHIP_ERROR ThermostatCluster::ReadAttributeLocalTemperature(Callback::Cancelable * onSuccessCallback,
                                                              Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeThermostatClusterReadLocalTemperatureAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR ThermostatCluster::ConfigureAttributeLocalTemperature(Callback::Cancelable * onSuccessCallback,
                                                                   Callback::Cancelable * onFailureCallback, uint16_t minInterval,
                                                                   uint16_t maxInterval, int16_t change)
  {
      uint8_t seqNum = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand =
          encodeThermostatClusterConfigureLocalTemperatureAttribute(seqNum, mEndpoint, minInterval, maxInterval, change);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR ThermostatCluster::ReportAttributeLocalTemperature(Callback::Cancelable * onReportCallback)
  {
      return RequestAttributeReporting(0x0000, onReportCallback);
  }
  
  CHIP_ERROR ThermostatCluster::ReadAttributeOccupiedCoolingSetpoint(Callback::Cancelable * onSuccessCallback,
                                                                     Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeThermostatClusterReadOccupiedCoolingSetpointAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR ThermostatCluster::WriteAttributeOccupiedCoolingSetpoint(Callback::Cancelable * onSuccessCallback,
                                                                      Callback::Cancelable * onFailureCallback, int16_t value)
  {
      uint8_t seqNum = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand =
          encodeThermostatClusterWriteOccupiedCoolingSetpointAttribute(seqNum, mEndpoint, value);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR ThermostatCluster::ReadAttributeOccupiedHeatingSetpoint(Callback::Cancelable * onSuccessCallback,
                                                                     Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeThermostatClusterReadOccupiedHeatingSetpointAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR ThermostatCluster::WriteAttributeOccupiedHeatingSetpoint(Callback::Cancelable * onSuccessCallback,
                                                                      Callback::Cancelable * onFailureCallback, int16_t value)
  {
      uint8_t seqNum = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand =
          encodeThermostatClusterWriteOccupiedHeatingSetpointAttribute(seqNum, mEndpoint, value);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR ThermostatCluster::ReadAttributeControlSequenceOfOperation(Callback::Cancelable * onSuccessCallback,
                                                                        Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeThermostatClusterReadControlSequenceOfOperationAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR ThermostatCluster::WriteAttributeControlSequenceOfOperation(Callback::Cancelable * onSuccessCallback,
                                                                         Callback::Cancelable * onFailureCallback, uint8_t value)
  {
      uint8_t seqNum = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand =
          encodeThermostatClusterWriteControlSequenceOfOperationAttribute(seqNum, mEndpoint, value);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR ThermostatCluster::ReadAttributeSystemMode(Callback::Cancelable * onSuccessCallback,
                                                        Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeThermostatClusterReadSystemModeAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR ThermostatCluster::WriteAttributeSystemMode(Callback::Cancelable * onSuccessCallback,
                                                         Callback::Cancelable * onFailureCallback, uint8_t value)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeThermostatClusterWriteSystemModeAttribute(seqNum, mEndpoint, value);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR ThermostatCluster::ReadAttributeClusterRevision(Callback::Cancelable * onSuccessCallback,
                                                             Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeThermostatClusterReadClusterRevisionAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  // WakeOnLan Cluster Commands
  // WakeOnLan Cluster Attributes
  CHIP_ERROR WakeOnLanCluster::DiscoverAttributes(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeWakeOnLanClusterDiscoverAttributes(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  CHIP_ERROR WakeOnLanCluster::ReadAttributeWakeOnLanMacAddress(Callback::Cancelable * onSuccessCallback,
                                                                Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeWakeOnLanClusterReadWakeOnLanMacAddressAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  CHIP_ERROR WakeOnLanCluster::ReadAttributeClusterRevision(Callback::Cancelable * onSuccessCallback,
                                                            Callback::Cancelable * onFailureCallback)
  {
      uint8_t seqNum                            = mDevice->GetNextSequenceNumber();
      System::PacketBufferHandle encodedCommand = encodeWakeOnLanClusterReadClusterRevisionAttribute(seqNum, mEndpoint);
      return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback);
  }
  
  } // namespace Controller
  } // namespace chip
  