diff --git a/src/darwin/Framework/CHIP/templates/availability.yaml b/src/darwin/Framework/CHIP/templates/availability.yaml
index 6a797e9..60e34d0 100644
--- a/src/darwin/Framework/CHIP/templates/availability.yaml
+++ b/src/darwin/Framework/CHIP/templates/availability.yaml
@@ -8390,6 +8390,7 @@
           - RVCCleanMode
           - DishwasherMode
           - WasherControls
+          - RVCOperationalState
       # Once we actually unmark TimeSynchronization as provisional, all these bits should go away too, and we should instead
       # mark things as introduced/deprecated as needed.  The "ids" entries should go away, in particular.
       ids:
diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRAttributeSpecifiedCheck.mm b/src/darwin/Framework/CHIP/zap-generated/MTRAttributeSpecifiedCheck.mm
index 1b4bb1c..0920c65 100644
--- a/src/darwin/Framework/CHIP/zap-generated/MTRAttributeSpecifiedCheck.mm
+++ b/src/darwin/Framework/CHIP/zap-generated/MTRAttributeSpecifiedCheck.mm
@@ -2018,51 +2018,6 @@
     }
     }
 }
-static BOOL AttributeIsSpecifiedInRVCOperationalStateCluster(AttributeId aAttributeId)
-{
-    using namespace Clusters::RvcOperationalState;
-    switch (aAttributeId) {
-    case Attributes::PhaseList::Id: {
-        return YES;
-    }
-    case Attributes::CurrentPhase::Id: {
-        return YES;
-    }
-    case Attributes::CountdownTime::Id: {
-        return YES;
-    }
-    case Attributes::OperationalStateList::Id: {
-        return YES;
-    }
-    case Attributes::OperationalState::Id: {
-        return YES;
-    }
-    case Attributes::OperationalError::Id: {
-        return YES;
-    }
-    case Attributes::GeneratedCommandList::Id: {
-        return YES;
-    }
-    case Attributes::AcceptedCommandList::Id: {
-        return YES;
-    }
-    case Attributes::EventList::Id: {
-        return YES;
-    }
-    case Attributes::AttributeList::Id: {
-        return YES;
-    }
-    case Attributes::FeatureMap::Id: {
-        return YES;
-    }
-    case Attributes::ClusterRevision::Id: {
-        return YES;
-    }
-    default: {
-        return NO;
-    }
-    }
-}
 static BOOL AttributeIsSpecifiedInHEPAFilterMonitoringCluster(AttributeId aAttributeId)
 {
     using namespace Clusters::HepaFilterMonitoring;
@@ -5145,9 +5100,6 @@
     case Clusters::OperationalState::Id: {
         return AttributeIsSpecifiedInOperationalStateCluster(aAttributeId);
     }
-    case Clusters::RvcOperationalState::Id: {
-        return AttributeIsSpecifiedInRVCOperationalStateCluster(aAttributeId);
-    }
     case Clusters::HepaFilterMonitoring::Id: {
         return AttributeIsSpecifiedInHEPAFilterMonitoringCluster(aAttributeId);
     }
diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRAttributeTLVValueDecoder.mm b/src/darwin/Framework/CHIP/zap-generated/MTRAttributeTLVValueDecoder.mm
index fe3c110..02563e2 100644
--- a/src/darwin/Framework/CHIP/zap-generated/MTRAttributeTLVValueDecoder.mm
+++ b/src/darwin/Framework/CHIP/zap-generated/MTRAttributeTLVValueDecoder.mm
@@ -10352,301 +10352,6 @@
     *aError = CHIP_ERROR_IM_MALFORMED_ATTRIBUTE_PATH_IB;
     return nil;
 }
-static id _Nullable DecodeAttributeValueForRVCOperationalStateCluster(
-    AttributeId aAttributeId, TLV::TLVReader & aReader, CHIP_ERROR * aError)
-{
-    using namespace Clusters::RvcOperationalState;
-    switch (aAttributeId) {
-    case Attributes::PhaseList::Id: {
-        using TypeInfo = Attributes::PhaseList::TypeInfo;
-        TypeInfo::DecodableType cppValue;
-        *aError = DataModel::Decode(aReader, cppValue);
-        if (*aError != CHIP_NO_ERROR) {
-            return nil;
-        }
-        NSArray * _Nullable value;
-        if (cppValue.IsNull()) {
-            value = nil;
-        } else {
-            { // Scope for our temporary variables
-                auto * array_1 = [NSMutableArray new];
-                auto iter_1 = cppValue.Value().begin();
-                while (iter_1.Next()) {
-                    auto & entry_1 = iter_1.GetValue();
-                    NSString * newElement_1;
-                    newElement_1 = AsString(entry_1);
-                    if (newElement_1 == nil) {
-                        CHIP_ERROR err = CHIP_ERROR_INVALID_ARGUMENT;
-                        *aError = err;
-                        return nil;
-                    }
-                    [array_1 addObject:newElement_1];
-                }
-                CHIP_ERROR err = iter_1.GetStatus();
-                if (err != CHIP_NO_ERROR) {
-                    *aError = err;
-                    return nil;
-                }
-                value = array_1;
-            }
-        }
-        return value;
-    }
-    case Attributes::CurrentPhase::Id: {
-        using TypeInfo = Attributes::CurrentPhase::TypeInfo;
-        TypeInfo::DecodableType cppValue;
-        *aError = DataModel::Decode(aReader, cppValue);
-        if (*aError != CHIP_NO_ERROR) {
-            return nil;
-        }
-        NSNumber * _Nullable value;
-        if (cppValue.IsNull()) {
-            value = nil;
-        } else {
-            value = [NSNumber numberWithUnsignedChar:cppValue.Value()];
-        }
-        return value;
-    }
-    case Attributes::CountdownTime::Id: {
-        using TypeInfo = Attributes::CountdownTime::TypeInfo;
-        TypeInfo::DecodableType cppValue;
-        *aError = DataModel::Decode(aReader, cppValue);
-        if (*aError != CHIP_NO_ERROR) {
-            return nil;
-        }
-        NSNumber * _Nullable value;
-        if (cppValue.IsNull()) {
-            value = nil;
-        } else {
-            value = [NSNumber numberWithUnsignedInt:cppValue.Value()];
-        }
-        return value;
-    }
-    case Attributes::OperationalStateList::Id: {
-        using TypeInfo = Attributes::OperationalStateList::TypeInfo;
-        TypeInfo::DecodableType cppValue;
-        *aError = DataModel::Decode(aReader, cppValue);
-        if (*aError != CHIP_NO_ERROR) {
-            return nil;
-        }
-        NSArray * _Nonnull value;
-        { // Scope for our temporary variables
-            auto * array_0 = [NSMutableArray new];
-            auto iter_0 = cppValue.begin();
-            while (iter_0.Next()) {
-                auto & entry_0 = iter_0.GetValue();
-                MTRRVCOperationalStateClusterOperationalStateStruct * newElement_0;
-                newElement_0 = [MTRRVCOperationalStateClusterOperationalStateStruct new];
-                newElement_0.operationalStateID = [NSNumber numberWithUnsignedChar:entry_0.operationalStateID];
-                if (entry_0.operationalStateLabel.HasValue()) {
-                    newElement_0.operationalStateLabel = AsString(entry_0.operationalStateLabel.Value());
-                    if (newElement_0.operationalStateLabel == nil) {
-                        CHIP_ERROR err = CHIP_ERROR_INVALID_ARGUMENT;
-                        *aError = err;
-                        return nil;
-                    }
-                } else {
-                    newElement_0.operationalStateLabel = nil;
-                }
-                [array_0 addObject:newElement_0];
-            }
-            CHIP_ERROR err = iter_0.GetStatus();
-            if (err != CHIP_NO_ERROR) {
-                *aError = err;
-                return nil;
-            }
-            value = array_0;
-        }
-        return value;
-    }
-    case Attributes::OperationalState::Id: {
-        using TypeInfo = Attributes::OperationalState::TypeInfo;
-        TypeInfo::DecodableType cppValue;
-        *aError = DataModel::Decode(aReader, cppValue);
-        if (*aError != CHIP_NO_ERROR) {
-            return nil;
-        }
-        MTRRVCOperationalStateClusterOperationalStateStruct * _Nonnull value;
-        value = [MTRRVCOperationalStateClusterOperationalStateStruct new];
-        value.operationalStateID = [NSNumber numberWithUnsignedChar:cppValue.operationalStateID];
-        if (cppValue.operationalStateLabel.HasValue()) {
-            value.operationalStateLabel = AsString(cppValue.operationalStateLabel.Value());
-            if (value.operationalStateLabel == nil) {
-                CHIP_ERROR err = CHIP_ERROR_INVALID_ARGUMENT;
-                *aError = err;
-                return nil;
-            }
-        } else {
-            value.operationalStateLabel = nil;
-        }
-        return value;
-    }
-    case Attributes::OperationalError::Id: {
-        using TypeInfo = Attributes::OperationalError::TypeInfo;
-        TypeInfo::DecodableType cppValue;
-        *aError = DataModel::Decode(aReader, cppValue);
-        if (*aError != CHIP_NO_ERROR) {
-            return nil;
-        }
-        MTRRVCOperationalStateClusterErrorStateStruct * _Nonnull value;
-        value = [MTRRVCOperationalStateClusterErrorStateStruct new];
-        value.errorStateID = [NSNumber numberWithUnsignedChar:cppValue.errorStateID];
-        if (cppValue.errorStateLabel.HasValue()) {
-            value.errorStateLabel = AsString(cppValue.errorStateLabel.Value());
-            if (value.errorStateLabel == nil) {
-                CHIP_ERROR err = CHIP_ERROR_INVALID_ARGUMENT;
-                *aError = err;
-                return nil;
-            }
-        } else {
-            value.errorStateLabel = nil;
-        }
-        if (cppValue.errorStateDetails.HasValue()) {
-            value.errorStateDetails = AsString(cppValue.errorStateDetails.Value());
-            if (value.errorStateDetails == nil) {
-                CHIP_ERROR err = CHIP_ERROR_INVALID_ARGUMENT;
-                *aError = err;
-                return nil;
-            }
-        } else {
-            value.errorStateDetails = nil;
-        }
-        return value;
-    }
-    case Attributes::GeneratedCommandList::Id: {
-        using TypeInfo = Attributes::GeneratedCommandList::TypeInfo;
-        TypeInfo::DecodableType cppValue;
-        *aError = DataModel::Decode(aReader, cppValue);
-        if (*aError != CHIP_NO_ERROR) {
-            return nil;
-        }
-        NSArray * _Nonnull value;
-        { // Scope for our temporary variables
-            auto * array_0 = [NSMutableArray new];
-            auto iter_0 = cppValue.begin();
-            while (iter_0.Next()) {
-                auto & entry_0 = iter_0.GetValue();
-                NSNumber * newElement_0;
-                newElement_0 = [NSNumber numberWithUnsignedInt:entry_0];
-                [array_0 addObject:newElement_0];
-            }
-            CHIP_ERROR err = iter_0.GetStatus();
-            if (err != CHIP_NO_ERROR) {
-                *aError = err;
-                return nil;
-            }
-            value = array_0;
-        }
-        return value;
-    }
-    case Attributes::AcceptedCommandList::Id: {
-        using TypeInfo = Attributes::AcceptedCommandList::TypeInfo;
-        TypeInfo::DecodableType cppValue;
-        *aError = DataModel::Decode(aReader, cppValue);
-        if (*aError != CHIP_NO_ERROR) {
-            return nil;
-        }
-        NSArray * _Nonnull value;
-        { // Scope for our temporary variables
-            auto * array_0 = [NSMutableArray new];
-            auto iter_0 = cppValue.begin();
-            while (iter_0.Next()) {
-                auto & entry_0 = iter_0.GetValue();
-                NSNumber * newElement_0;
-                newElement_0 = [NSNumber numberWithUnsignedInt:entry_0];
-                [array_0 addObject:newElement_0];
-            }
-            CHIP_ERROR err = iter_0.GetStatus();
-            if (err != CHIP_NO_ERROR) {
-                *aError = err;
-                return nil;
-            }
-            value = array_0;
-        }
-        return value;
-    }
-    case Attributes::EventList::Id: {
-        using TypeInfo = Attributes::EventList::TypeInfo;
-        TypeInfo::DecodableType cppValue;
-        *aError = DataModel::Decode(aReader, cppValue);
-        if (*aError != CHIP_NO_ERROR) {
-            return nil;
-        }
-        NSArray * _Nonnull value;
-        { // Scope for our temporary variables
-            auto * array_0 = [NSMutableArray new];
-            auto iter_0 = cppValue.begin();
-            while (iter_0.Next()) {
-                auto & entry_0 = iter_0.GetValue();
-                NSNumber * newElement_0;
-                newElement_0 = [NSNumber numberWithUnsignedInt:entry_0];
-                [array_0 addObject:newElement_0];
-            }
-            CHIP_ERROR err = iter_0.GetStatus();
-            if (err != CHIP_NO_ERROR) {
-                *aError = err;
-                return nil;
-            }
-            value = array_0;
-        }
-        return value;
-    }
-    case Attributes::AttributeList::Id: {
-        using TypeInfo = Attributes::AttributeList::TypeInfo;
-        TypeInfo::DecodableType cppValue;
-        *aError = DataModel::Decode(aReader, cppValue);
-        if (*aError != CHIP_NO_ERROR) {
-            return nil;
-        }
-        NSArray * _Nonnull value;
-        { // Scope for our temporary variables
-            auto * array_0 = [NSMutableArray new];
-            auto iter_0 = cppValue.begin();
-            while (iter_0.Next()) {
-                auto & entry_0 = iter_0.GetValue();
-                NSNumber * newElement_0;
-                newElement_0 = [NSNumber numberWithUnsignedInt:entry_0];
-                [array_0 addObject:newElement_0];
-            }
-            CHIP_ERROR err = iter_0.GetStatus();
-            if (err != CHIP_NO_ERROR) {
-                *aError = err;
-                return nil;
-            }
-            value = array_0;
-        }
-        return value;
-    }
-    case Attributes::FeatureMap::Id: {
-        using TypeInfo = Attributes::FeatureMap::TypeInfo;
-        TypeInfo::DecodableType cppValue;
-        *aError = DataModel::Decode(aReader, cppValue);
-        if (*aError != CHIP_NO_ERROR) {
-            return nil;
-        }
-        NSNumber * _Nonnull value;
-        value = [NSNumber numberWithUnsignedInt:cppValue];
-        return value;
-    }
-    case Attributes::ClusterRevision::Id: {
-        using TypeInfo = Attributes::ClusterRevision::TypeInfo;
-        TypeInfo::DecodableType cppValue;
-        *aError = DataModel::Decode(aReader, cppValue);
-        if (*aError != CHIP_NO_ERROR) {
-            return nil;
-        }
-        NSNumber * _Nonnull value;
-        value = [NSNumber numberWithUnsignedShort:cppValue];
-        return value;
-    }
-    default: {
-        break;
-    }
-    }
-
-    *aError = CHIP_ERROR_IM_MALFORMED_ATTRIBUTE_PATH_IB;
-    return nil;
-}
 static id _Nullable DecodeAttributeValueForHEPAFilterMonitoringCluster(
     AttributeId aAttributeId, TLV::TLVReader & aReader, CHIP_ERROR * aError)
 {
@@ -24587,9 +24292,6 @@
     case Clusters::OperationalState::Id: {
         return DecodeAttributeValueForOperationalStateCluster(aPath.mAttributeId, aReader, aError);
     }
-    case Clusters::RvcOperationalState::Id: {
-        return DecodeAttributeValueForRVCOperationalStateCluster(aPath.mAttributeId, aReader, aError);
-    }
     case Clusters::HepaFilterMonitoring::Id: {
         return DecodeAttributeValueForHEPAFilterMonitoringCluster(aPath.mAttributeId, aReader, aError);
     }
diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.h b/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.h
index 6e21a62..bf303f8 100644
--- a/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.h
+++ b/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.h
@@ -8734,213 +8734,6 @@
 @end
 
 /**
- * Cluster RVC Operational State
- *
- * This cluster supports remotely monitoring and, where supported, changing the operational state of a Robotic Vacuum.
- */
-MTR_NEWLY_AVAILABLE
-@interface MTRBaseClusterRVCOperationalState : MTRCluster
-
-- (instancetype _Nullable)initWithDevice:(MTRBaseDevice *)device
-                              endpointID:(NSNumber *)endpointID
-                                   queue:(dispatch_queue_t)queue NS_DESIGNATED_INITIALIZER MTR_NEWLY_AVAILABLE;
-
-/**
- * Command Pause
- *
- * Upon receipt, the device SHALL pause its operation if it is possible based on the current function of the server.
- */
-- (void)pauseWithParams:(MTRRVCOperationalStateClusterPauseParams * _Nullable)params
-             completion:(void (^)(MTRRVCOperationalStateClusterOperationalCommandResponseParams * _Nullable data,
-                            NSError * _Nullable error))completion MTR_NEWLY_AVAILABLE;
-- (void)pauseWithCompletion:(void (^)(MTRRVCOperationalStateClusterOperationalCommandResponseParams * _Nullable data,
-                                NSError * _Nullable error))completion MTR_NEWLY_AVAILABLE;
-/**
- * Command Stop
- *
- * Upon receipt, the device SHALL stop its operation if it is at a position where it is safe to do so and/or permitted.
- */
-- (void)stopWithParams:(MTRRVCOperationalStateClusterStopParams * _Nullable)params
-            completion:(void (^)(MTRRVCOperationalStateClusterOperationalCommandResponseParams * _Nullable data,
-                           NSError * _Nullable error))completion MTR_NEWLY_AVAILABLE;
-- (void)stopWithCompletion:(void (^)(MTRRVCOperationalStateClusterOperationalCommandResponseParams * _Nullable data,
-                               NSError * _Nullable error))completion MTR_NEWLY_AVAILABLE;
-/**
- * Command Start
- *
- * Upon receipt, the device SHALL start its operation if it is safe to do so and the device is in an operational state from which it
- * can be started.
- */
-- (void)startWithParams:(MTRRVCOperationalStateClusterStartParams * _Nullable)params
-             completion:(void (^)(MTRRVCOperationalStateClusterOperationalCommandResponseParams * _Nullable data,
-                            NSError * _Nullable error))completion MTR_NEWLY_AVAILABLE;
-- (void)startWithCompletion:(void (^)(MTRRVCOperationalStateClusterOperationalCommandResponseParams * _Nullable data,
-                                NSError * _Nullable error))completion MTR_NEWLY_AVAILABLE;
-/**
- * Command Resume
- *
- * Upon receipt, the device SHALL resume its operation from the point it was at when it received the Pause command, or from the
- * point when it was paused by means outside of this cluster (for example by manual button press).
- */
-- (void)resumeWithParams:(MTRRVCOperationalStateClusterResumeParams * _Nullable)params
-              completion:(void (^)(MTRRVCOperationalStateClusterOperationalCommandResponseParams * _Nullable data,
-                             NSError * _Nullable error))completion MTR_NEWLY_AVAILABLE;
-- (void)resumeWithCompletion:(void (^)(MTRRVCOperationalStateClusterOperationalCommandResponseParams * _Nullable data,
-                                 NSError * _Nullable error))completion MTR_NEWLY_AVAILABLE;
-
-- (void)readAttributePhaseListWithCompletion:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion
-    MTR_NEWLY_AVAILABLE;
-- (void)subscribeAttributePhaseListWithParams:(MTRSubscribeParams *)params
-                      subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished
-                                reportHandler:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))reportHandler
-    MTR_NEWLY_AVAILABLE;
-+ (void)readAttributePhaseListWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer
-                                           endpoint:(NSNumber *)endpoint
-                                              queue:(dispatch_queue_t)queue
-                                         completion:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion
-    MTR_NEWLY_AVAILABLE;
-
-- (void)readAttributeCurrentPhaseWithCompletion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion
-    MTR_NEWLY_AVAILABLE;
-- (void)subscribeAttributeCurrentPhaseWithParams:(MTRSubscribeParams *)params
-                         subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished
-                                   reportHandler:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))reportHandler
-    MTR_NEWLY_AVAILABLE;
-+ (void)readAttributeCurrentPhaseWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer
-                                              endpoint:(NSNumber *)endpoint
-                                                 queue:(dispatch_queue_t)queue
-                                            completion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion
-    MTR_NEWLY_AVAILABLE;
-
-- (void)readAttributeCountdownTimeWithCompletion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion
-    MTR_NEWLY_AVAILABLE;
-- (void)subscribeAttributeCountdownTimeWithParams:(MTRSubscribeParams *)params
-                          subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished
-                                    reportHandler:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))reportHandler
-    MTR_NEWLY_AVAILABLE;
-+ (void)readAttributeCountdownTimeWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer
-                                               endpoint:(NSNumber *)endpoint
-                                                  queue:(dispatch_queue_t)queue
-                                             completion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion
-    MTR_NEWLY_AVAILABLE;
-
-- (void)readAttributeOperationalStateListWithCompletion:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion
-    MTR_NEWLY_AVAILABLE;
-- (void)subscribeAttributeOperationalStateListWithParams:(MTRSubscribeParams *)params
-                                 subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished
-                                           reportHandler:(void (^)(NSArray * _Nullable value,
-                                                             NSError * _Nullable error))reportHandler MTR_NEWLY_AVAILABLE;
-+ (void)readAttributeOperationalStateListWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer
-                                                      endpoint:(NSNumber *)endpoint
-                                                         queue:(dispatch_queue_t)queue
-                                                    completion:(void (^)(NSArray * _Nullable value,
-                                                                   NSError * _Nullable error))completion MTR_NEWLY_AVAILABLE;
-
-- (void)readAttributeOperationalStateWithCompletion:(void (^)(MTRRVCOperationalStateClusterOperationalStateStruct * _Nullable value,
-                                                        NSError * _Nullable error))completion MTR_NEWLY_AVAILABLE;
-- (void)subscribeAttributeOperationalStateWithParams:(MTRSubscribeParams *)params
-                             subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished
-                                       reportHandler:
-                                           (void (^)(MTRRVCOperationalStateClusterOperationalStateStruct * _Nullable value,
-                                               NSError * _Nullable error))reportHandler MTR_NEWLY_AVAILABLE;
-+ (void)readAttributeOperationalStateWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer
-                                                  endpoint:(NSNumber *)endpoint
-                                                     queue:(dispatch_queue_t)queue
-                                                completion:
-                                                    (void (^)(MTRRVCOperationalStateClusterOperationalStateStruct * _Nullable value,
-                                                        NSError * _Nullable error))completion MTR_NEWLY_AVAILABLE;
-
-- (void)readAttributeOperationalErrorWithCompletion:(void (^)(MTRRVCOperationalStateClusterErrorStateStruct * _Nullable value,
-                                                        NSError * _Nullable error))completion MTR_NEWLY_AVAILABLE;
-- (void)subscribeAttributeOperationalErrorWithParams:(MTRSubscribeParams *)params
-                             subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished
-                                       reportHandler:(void (^)(MTRRVCOperationalStateClusterErrorStateStruct * _Nullable value,
-                                                         NSError * _Nullable error))reportHandler MTR_NEWLY_AVAILABLE;
-+ (void)readAttributeOperationalErrorWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer
-                                                  endpoint:(NSNumber *)endpoint
-                                                     queue:(dispatch_queue_t)queue
-                                                completion:
-                                                    (void (^)(MTRRVCOperationalStateClusterErrorStateStruct * _Nullable value,
-                                                        NSError * _Nullable error))completion MTR_NEWLY_AVAILABLE;
-
-- (void)readAttributeGeneratedCommandListWithCompletion:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion
-    MTR_NEWLY_AVAILABLE;
-- (void)subscribeAttributeGeneratedCommandListWithParams:(MTRSubscribeParams *)params
-                                 subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished
-                                           reportHandler:(void (^)(NSArray * _Nullable value,
-                                                             NSError * _Nullable error))reportHandler MTR_NEWLY_AVAILABLE;
-+ (void)readAttributeGeneratedCommandListWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer
-                                                      endpoint:(NSNumber *)endpoint
-                                                         queue:(dispatch_queue_t)queue
-                                                    completion:(void (^)(NSArray * _Nullable value,
-                                                                   NSError * _Nullable error))completion MTR_NEWLY_AVAILABLE;
-
-- (void)readAttributeAcceptedCommandListWithCompletion:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion
-    MTR_NEWLY_AVAILABLE;
-- (void)subscribeAttributeAcceptedCommandListWithParams:(MTRSubscribeParams *)params
-                                subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished
-                                          reportHandler:(void (^)(NSArray * _Nullable value,
-                                                            NSError * _Nullable error))reportHandler MTR_NEWLY_AVAILABLE;
-+ (void)readAttributeAcceptedCommandListWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer
-                                                     endpoint:(NSNumber *)endpoint
-                                                        queue:(dispatch_queue_t)queue
-                                                   completion:(void (^)(NSArray * _Nullable value,
-                                                                  NSError * _Nullable error))completion MTR_NEWLY_AVAILABLE;
-
-- (void)readAttributeEventListWithCompletion:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion
-    MTR_NEWLY_AVAILABLE;
-- (void)subscribeAttributeEventListWithParams:(MTRSubscribeParams *)params
-                      subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished
-                                reportHandler:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))reportHandler
-    MTR_NEWLY_AVAILABLE;
-+ (void)readAttributeEventListWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer
-                                           endpoint:(NSNumber *)endpoint
-                                              queue:(dispatch_queue_t)queue
-                                         completion:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion
-    MTR_NEWLY_AVAILABLE;
-
-- (void)readAttributeAttributeListWithCompletion:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion
-    MTR_NEWLY_AVAILABLE;
-- (void)subscribeAttributeAttributeListWithParams:(MTRSubscribeParams *)params
-                          subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished
-                                    reportHandler:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))reportHandler
-    MTR_NEWLY_AVAILABLE;
-+ (void)readAttributeAttributeListWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer
-                                               endpoint:(NSNumber *)endpoint
-                                                  queue:(dispatch_queue_t)queue
-                                             completion:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion
-    MTR_NEWLY_AVAILABLE;
-
-- (void)readAttributeFeatureMapWithCompletion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion
-    MTR_NEWLY_AVAILABLE;
-- (void)subscribeAttributeFeatureMapWithParams:(MTRSubscribeParams *)params
-                       subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished
-                                 reportHandler:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))reportHandler
-    MTR_NEWLY_AVAILABLE;
-+ (void)readAttributeFeatureMapWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer
-                                            endpoint:(NSNumber *)endpoint
-                                               queue:(dispatch_queue_t)queue
-                                          completion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion
-    MTR_NEWLY_AVAILABLE;
-
-- (void)readAttributeClusterRevisionWithCompletion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion
-    MTR_NEWLY_AVAILABLE;
-- (void)subscribeAttributeClusterRevisionWithParams:(MTRSubscribeParams *)params
-                            subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished
-                                      reportHandler:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))reportHandler
-    MTR_NEWLY_AVAILABLE;
-+ (void)readAttributeClusterRevisionWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer
-                                                 endpoint:(NSNumber *)endpoint
-                                                    queue:(dispatch_queue_t)queue
-                                               completion:(void (^)(NSNumber * _Nullable value,
-                                                              NSError * _Nullable error))completion MTR_NEWLY_AVAILABLE;
-
-- (instancetype)init NS_UNAVAILABLE;
-+ (instancetype)new NS_UNAVAILABLE;
-
-@end
-
-/**
  * Cluster HEPA Filter Monitoring
  *
  * Attributes and commands for monitoring HEPA filters in a device
@@ -24643,23 +24436,6 @@
     MTROperationalStateError MTR_NEWLY_AVAILABLE = 0x03,
 } MTR_NEWLY_AVAILABLE;
 
-typedef NS_ENUM(uint8_t, MTRRVCOperationalStateErrorState) {
-    MTRRVCOperationalStateErrorStateFailedToFindChargingDock MTR_NEWLY_AVAILABLE = 0x40,
-    MTRRVCOperationalStateErrorStateStuck MTR_NEWLY_AVAILABLE = 0x41,
-    MTRRVCOperationalStateErrorStateDustBinMissing MTR_NEWLY_AVAILABLE = 0x42,
-    MTRRVCOperationalStateErrorStateDustBinFull MTR_NEWLY_AVAILABLE = 0x43,
-    MTRRVCOperationalStateErrorStateWaterTankEmpty MTR_NEWLY_AVAILABLE = 0x44,
-    MTRRVCOperationalStateErrorStateWaterTankMissing MTR_NEWLY_AVAILABLE = 0x45,
-    MTRRVCOperationalStateErrorStateWaterTankLidOpen MTR_NEWLY_AVAILABLE = 0x46,
-    MTRRVCOperationalStateErrorStateMopCleaningPadMissing MTR_NEWLY_AVAILABLE = 0x47,
-} MTR_NEWLY_AVAILABLE;
-
-typedef NS_ENUM(uint8_t, MTRRVCOperationalStateOperationalState) {
-    MTRRVCOperationalStateOperationalStateSeekingCharger MTR_NEWLY_AVAILABLE = 0x40,
-    MTRRVCOperationalStateOperationalStateCharging MTR_NEWLY_AVAILABLE = 0x41,
-    MTRRVCOperationalStateOperationalStateDocked MTR_NEWLY_AVAILABLE = 0x42,
-} MTR_NEWLY_AVAILABLE;
-
 typedef NS_ENUM(uint8_t, MTRHEPAFilterMonitoringChangeIndication) {
     MTRHEPAFilterMonitoringChangeIndicationOK MTR_NEWLY_AVAILABLE = 0x00,
     MTRHEPAFilterMonitoringChangeIndicationWarning MTR_NEWLY_AVAILABLE = 0x01,
diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.mm b/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.mm
index eb201d0..cdf9f56 100644
--- a/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.mm
+++ b/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.mm
@@ -50705,715 +50705,6 @@
 
 @end
 
-@implementation MTRBaseClusterRVCOperationalState
-
-- (instancetype)initWithDevice:(MTRBaseDevice *)device endpointID:(NSNumber *)endpointID queue:(dispatch_queue_t)queue
-{
-    if (self = [super initWithQueue:queue]) {
-        if (device == nil) {
-            return nil;
-        }
-
-        _device = device;
-        _endpoint = [endpointID unsignedShortValue];
-    }
-    return self;
-}
-
-- (void)pauseWithCompletion:(void (^)(MTRRVCOperationalStateClusterOperationalCommandResponseParams * _Nullable data,
-                                NSError * _Nullable error))completion
-{
-    [self pauseWithParams:nil completion:completion];
-}
-- (void)pauseWithParams:(MTRRVCOperationalStateClusterPauseParams * _Nullable)params
-             completion:(void (^)(MTRRVCOperationalStateClusterOperationalCommandResponseParams * _Nullable data,
-                            NSError * _Nullable error))completion
-{
-    // Make a copy of params before we go async.
-    params = [params copy];
-    auto * bridge = new MTRRVCOperationalStateClusterOperationalCommandResponseCallbackBridge(self.callbackQueue, completion,
-        ^(ExchangeManager & exchangeManager, const SessionHandle & session,
-            RVCOperationalStateClusterOperationalCommandResponseCallbackType successCb, MTRErrorCallback failureCb,
-            MTRCallbackBridgeBase * bridge) {
-            auto * typedBridge = static_cast<MTRRVCOperationalStateClusterOperationalCommandResponseCallbackBridge *>(bridge);
-            Optional<uint16_t> timedInvokeTimeoutMs;
-            Optional<Timeout> invokeTimeout;
-            ListFreer listFreer;
-            RvcOperationalState::Commands::Pause::Type request;
-            if (params != nil) {
-                if (params.timedInvokeTimeoutMs != nil) {
-                    params.timedInvokeTimeoutMs = MTRClampedNumber(params.timedInvokeTimeoutMs, @(1), @(UINT16_MAX));
-                    timedInvokeTimeoutMs.SetValue(params.timedInvokeTimeoutMs.unsignedShortValue);
-                }
-                if (params.serverSideProcessingTimeout != nil) {
-                    // Clamp to a number of seconds that will not overflow 32-bit
-                    // int when converted to ms.
-                    auto * serverSideProcessingTimeout = MTRClampedNumber(params.serverSideProcessingTimeout, @(0), @(UINT16_MAX));
-                    invokeTimeout.SetValue(Seconds16(serverSideProcessingTimeout.unsignedShortValue));
-                }
-            }
-
-            return MTRStartInvokeInteraction(typedBridge, request, exchangeManager, session, successCb, failureCb, self->_endpoint,
-                timedInvokeTimeoutMs, invokeTimeout);
-        });
-    std::move(*bridge).DispatchAction(self.device);
-}
-
-- (void)stopWithCompletion:(void (^)(MTRRVCOperationalStateClusterOperationalCommandResponseParams * _Nullable data,
-                               NSError * _Nullable error))completion
-{
-    [self stopWithParams:nil completion:completion];
-}
-- (void)stopWithParams:(MTRRVCOperationalStateClusterStopParams * _Nullable)params
-            completion:(void (^)(MTRRVCOperationalStateClusterOperationalCommandResponseParams * _Nullable data,
-                           NSError * _Nullable error))completion
-{
-    // Make a copy of params before we go async.
-    params = [params copy];
-    auto * bridge = new MTRRVCOperationalStateClusterOperationalCommandResponseCallbackBridge(self.callbackQueue, completion,
-        ^(ExchangeManager & exchangeManager, const SessionHandle & session,
-            RVCOperationalStateClusterOperationalCommandResponseCallbackType successCb, MTRErrorCallback failureCb,
-            MTRCallbackBridgeBase * bridge) {
-            auto * typedBridge = static_cast<MTRRVCOperationalStateClusterOperationalCommandResponseCallbackBridge *>(bridge);
-            Optional<uint16_t> timedInvokeTimeoutMs;
-            Optional<Timeout> invokeTimeout;
-            ListFreer listFreer;
-            RvcOperationalState::Commands::Stop::Type request;
-            if (params != nil) {
-                if (params.timedInvokeTimeoutMs != nil) {
-                    params.timedInvokeTimeoutMs = MTRClampedNumber(params.timedInvokeTimeoutMs, @(1), @(UINT16_MAX));
-                    timedInvokeTimeoutMs.SetValue(params.timedInvokeTimeoutMs.unsignedShortValue);
-                }
-                if (params.serverSideProcessingTimeout != nil) {
-                    // Clamp to a number of seconds that will not overflow 32-bit
-                    // int when converted to ms.
-                    auto * serverSideProcessingTimeout = MTRClampedNumber(params.serverSideProcessingTimeout, @(0), @(UINT16_MAX));
-                    invokeTimeout.SetValue(Seconds16(serverSideProcessingTimeout.unsignedShortValue));
-                }
-            }
-
-            return MTRStartInvokeInteraction(typedBridge, request, exchangeManager, session, successCb, failureCb, self->_endpoint,
-                timedInvokeTimeoutMs, invokeTimeout);
-        });
-    std::move(*bridge).DispatchAction(self.device);
-}
-
-- (void)startWithCompletion:(void (^)(MTRRVCOperationalStateClusterOperationalCommandResponseParams * _Nullable data,
-                                NSError * _Nullable error))completion
-{
-    [self startWithParams:nil completion:completion];
-}
-- (void)startWithParams:(MTRRVCOperationalStateClusterStartParams * _Nullable)params
-             completion:(void (^)(MTRRVCOperationalStateClusterOperationalCommandResponseParams * _Nullable data,
-                            NSError * _Nullable error))completion
-{
-    // Make a copy of params before we go async.
-    params = [params copy];
-    auto * bridge = new MTRRVCOperationalStateClusterOperationalCommandResponseCallbackBridge(self.callbackQueue, completion,
-        ^(ExchangeManager & exchangeManager, const SessionHandle & session,
-            RVCOperationalStateClusterOperationalCommandResponseCallbackType successCb, MTRErrorCallback failureCb,
-            MTRCallbackBridgeBase * bridge) {
-            auto * typedBridge = static_cast<MTRRVCOperationalStateClusterOperationalCommandResponseCallbackBridge *>(bridge);
-            Optional<uint16_t> timedInvokeTimeoutMs;
-            Optional<Timeout> invokeTimeout;
-            ListFreer listFreer;
-            RvcOperationalState::Commands::Start::Type request;
-            if (params != nil) {
-                if (params.timedInvokeTimeoutMs != nil) {
-                    params.timedInvokeTimeoutMs = MTRClampedNumber(params.timedInvokeTimeoutMs, @(1), @(UINT16_MAX));
-                    timedInvokeTimeoutMs.SetValue(params.timedInvokeTimeoutMs.unsignedShortValue);
-                }
-                if (params.serverSideProcessingTimeout != nil) {
-                    // Clamp to a number of seconds that will not overflow 32-bit
-                    // int when converted to ms.
-                    auto * serverSideProcessingTimeout = MTRClampedNumber(params.serverSideProcessingTimeout, @(0), @(UINT16_MAX));
-                    invokeTimeout.SetValue(Seconds16(serverSideProcessingTimeout.unsignedShortValue));
-                }
-            }
-
-            return MTRStartInvokeInteraction(typedBridge, request, exchangeManager, session, successCb, failureCb, self->_endpoint,
-                timedInvokeTimeoutMs, invokeTimeout);
-        });
-    std::move(*bridge).DispatchAction(self.device);
-}
-
-- (void)resumeWithCompletion:(void (^)(MTRRVCOperationalStateClusterOperationalCommandResponseParams * _Nullable data,
-                                 NSError * _Nullable error))completion
-{
-    [self resumeWithParams:nil completion:completion];
-}
-- (void)resumeWithParams:(MTRRVCOperationalStateClusterResumeParams * _Nullable)params
-              completion:(void (^)(MTRRVCOperationalStateClusterOperationalCommandResponseParams * _Nullable data,
-                             NSError * _Nullable error))completion
-{
-    // Make a copy of params before we go async.
-    params = [params copy];
-    auto * bridge = new MTRRVCOperationalStateClusterOperationalCommandResponseCallbackBridge(self.callbackQueue, completion,
-        ^(ExchangeManager & exchangeManager, const SessionHandle & session,
-            RVCOperationalStateClusterOperationalCommandResponseCallbackType successCb, MTRErrorCallback failureCb,
-            MTRCallbackBridgeBase * bridge) {
-            auto * typedBridge = static_cast<MTRRVCOperationalStateClusterOperationalCommandResponseCallbackBridge *>(bridge);
-            Optional<uint16_t> timedInvokeTimeoutMs;
-            Optional<Timeout> invokeTimeout;
-            ListFreer listFreer;
-            RvcOperationalState::Commands::Resume::Type request;
-            if (params != nil) {
-                if (params.timedInvokeTimeoutMs != nil) {
-                    params.timedInvokeTimeoutMs = MTRClampedNumber(params.timedInvokeTimeoutMs, @(1), @(UINT16_MAX));
-                    timedInvokeTimeoutMs.SetValue(params.timedInvokeTimeoutMs.unsignedShortValue);
-                }
-                if (params.serverSideProcessingTimeout != nil) {
-                    // Clamp to a number of seconds that will not overflow 32-bit
-                    // int when converted to ms.
-                    auto * serverSideProcessingTimeout = MTRClampedNumber(params.serverSideProcessingTimeout, @(0), @(UINT16_MAX));
-                    invokeTimeout.SetValue(Seconds16(serverSideProcessingTimeout.unsignedShortValue));
-                }
-            }
-
-            return MTRStartInvokeInteraction(typedBridge, request, exchangeManager, session, successCb, failureCb, self->_endpoint,
-                timedInvokeTimeoutMs, invokeTimeout);
-        });
-    std::move(*bridge).DispatchAction(self.device);
-}
-
-- (void)readAttributePhaseListWithCompletion:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion
-{
-    MTRReadParams * params = [[MTRReadParams alloc] init];
-    using TypeInfo = RvcOperationalState::Attributes::PhaseList::TypeInfo;
-    return MTRReadAttribute<MTRRVCOperationalStatePhaseListListAttributeCallbackBridge, NSArray, TypeInfo::DecodableType>(
-        params, completion, self.callbackQueue, self.device, self->_endpoint, TypeInfo::GetClusterId(), TypeInfo::GetAttributeId());
-}
-
-- (void)subscribeAttributePhaseListWithParams:(MTRSubscribeParams * _Nonnull)params
-                      subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished
-                                reportHandler:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))reportHandler
-{
-    using TypeInfo = RvcOperationalState::Attributes::PhaseList::TypeInfo;
-    MTRSubscribeAttribute<MTRRVCOperationalStatePhaseListListAttributeCallbackSubscriptionBridge, NSArray, TypeInfo::DecodableType>(
-        params, subscriptionEstablished, reportHandler, self.callbackQueue, self.device, self->_endpoint, TypeInfo::GetClusterId(),
-        TypeInfo::GetAttributeId());
-}
-
-+ (void)readAttributePhaseListWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer
-                                           endpoint:(NSNumber *)endpoint
-                                              queue:(dispatch_queue_t)queue
-                                         completion:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion
-{
-    auto * bridge = new MTRRVCOperationalStatePhaseListListAttributeCallbackBridge(queue, completion);
-    std::move(*bridge).DispatchLocalAction(clusterStateCacheContainer.baseDevice,
-        ^(RVCOperationalStatePhaseListListAttributeCallback successCb, MTRErrorCallback failureCb) {
-            if (clusterStateCacheContainer.cppClusterStateCache) {
-                chip::app::ConcreteAttributePath path;
-                using TypeInfo = RvcOperationalState::Attributes::PhaseList::TypeInfo;
-                path.mEndpointId = static_cast<chip::EndpointId>([endpoint unsignedShortValue]);
-                path.mClusterId = TypeInfo::GetClusterId();
-                path.mAttributeId = TypeInfo::GetAttributeId();
-                TypeInfo::DecodableType value;
-                CHIP_ERROR err = clusterStateCacheContainer.cppClusterStateCache->Get<TypeInfo>(path, value);
-                if (err == CHIP_NO_ERROR) {
-                    successCb(bridge, value);
-                }
-                return err;
-            }
-            return CHIP_ERROR_NOT_FOUND;
-        });
-}
-
-- (void)readAttributeCurrentPhaseWithCompletion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion
-{
-    MTRReadParams * params = [[MTRReadParams alloc] init];
-    using TypeInfo = RvcOperationalState::Attributes::CurrentPhase::TypeInfo;
-    return MTRReadAttribute<MTRNullableInt8uAttributeCallbackBridge, NSNumber, TypeInfo::DecodableType>(
-        params, completion, self.callbackQueue, self.device, self->_endpoint, TypeInfo::GetClusterId(), TypeInfo::GetAttributeId());
-}
-
-- (void)subscribeAttributeCurrentPhaseWithParams:(MTRSubscribeParams * _Nonnull)params
-                         subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished
-                                   reportHandler:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))reportHandler
-{
-    using TypeInfo = RvcOperationalState::Attributes::CurrentPhase::TypeInfo;
-    MTRSubscribeAttribute<MTRNullableInt8uAttributeCallbackSubscriptionBridge, NSNumber, TypeInfo::DecodableType>(params,
-        subscriptionEstablished, reportHandler, self.callbackQueue, self.device, self->_endpoint, TypeInfo::GetClusterId(),
-        TypeInfo::GetAttributeId());
-}
-
-+ (void)readAttributeCurrentPhaseWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer
-                                              endpoint:(NSNumber *)endpoint
-                                                 queue:(dispatch_queue_t)queue
-                                            completion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion
-{
-    auto * bridge = new MTRNullableInt8uAttributeCallbackBridge(queue, completion);
-    std::move(*bridge).DispatchLocalAction(
-        clusterStateCacheContainer.baseDevice, ^(NullableInt8uAttributeCallback successCb, MTRErrorCallback failureCb) {
-            if (clusterStateCacheContainer.cppClusterStateCache) {
-                chip::app::ConcreteAttributePath path;
-                using TypeInfo = RvcOperationalState::Attributes::CurrentPhase::TypeInfo;
-                path.mEndpointId = static_cast<chip::EndpointId>([endpoint unsignedShortValue]);
-                path.mClusterId = TypeInfo::GetClusterId();
-                path.mAttributeId = TypeInfo::GetAttributeId();
-                TypeInfo::DecodableType value;
-                CHIP_ERROR err = clusterStateCacheContainer.cppClusterStateCache->Get<TypeInfo>(path, value);
-                if (err == CHIP_NO_ERROR) {
-                    successCb(bridge, value);
-                }
-                return err;
-            }
-            return CHIP_ERROR_NOT_FOUND;
-        });
-}
-
-- (void)readAttributeCountdownTimeWithCompletion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion
-{
-    MTRReadParams * params = [[MTRReadParams alloc] init];
-    using TypeInfo = RvcOperationalState::Attributes::CountdownTime::TypeInfo;
-    return MTRReadAttribute<MTRNullableInt32uAttributeCallbackBridge, NSNumber, TypeInfo::DecodableType>(
-        params, completion, self.callbackQueue, self.device, self->_endpoint, TypeInfo::GetClusterId(), TypeInfo::GetAttributeId());
-}
-
-- (void)subscribeAttributeCountdownTimeWithParams:(MTRSubscribeParams * _Nonnull)params
-                          subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished
-                                    reportHandler:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))reportHandler
-{
-    using TypeInfo = RvcOperationalState::Attributes::CountdownTime::TypeInfo;
-    MTRSubscribeAttribute<MTRNullableInt32uAttributeCallbackSubscriptionBridge, NSNumber, TypeInfo::DecodableType>(params,
-        subscriptionEstablished, reportHandler, self.callbackQueue, self.device, self->_endpoint, TypeInfo::GetClusterId(),
-        TypeInfo::GetAttributeId());
-}
-
-+ (void)readAttributeCountdownTimeWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer
-                                               endpoint:(NSNumber *)endpoint
-                                                  queue:(dispatch_queue_t)queue
-                                             completion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion
-{
-    auto * bridge = new MTRNullableInt32uAttributeCallbackBridge(queue, completion);
-    std::move(*bridge).DispatchLocalAction(
-        clusterStateCacheContainer.baseDevice, ^(NullableInt32uAttributeCallback successCb, MTRErrorCallback failureCb) {
-            if (clusterStateCacheContainer.cppClusterStateCache) {
-                chip::app::ConcreteAttributePath path;
-                using TypeInfo = RvcOperationalState::Attributes::CountdownTime::TypeInfo;
-                path.mEndpointId = static_cast<chip::EndpointId>([endpoint unsignedShortValue]);
-                path.mClusterId = TypeInfo::GetClusterId();
-                path.mAttributeId = TypeInfo::GetAttributeId();
-                TypeInfo::DecodableType value;
-                CHIP_ERROR err = clusterStateCacheContainer.cppClusterStateCache->Get<TypeInfo>(path, value);
-                if (err == CHIP_NO_ERROR) {
-                    successCb(bridge, value);
-                }
-                return err;
-            }
-            return CHIP_ERROR_NOT_FOUND;
-        });
-}
-
-- (void)readAttributeOperationalStateListWithCompletion:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion
-{
-    MTRReadParams * params = [[MTRReadParams alloc] init];
-    using TypeInfo = RvcOperationalState::Attributes::OperationalStateList::TypeInfo;
-    return MTRReadAttribute<MTRRVCOperationalStateOperationalStateListListAttributeCallbackBridge, NSArray,
-        TypeInfo::DecodableType>(
-        params, completion, self.callbackQueue, self.device, self->_endpoint, TypeInfo::GetClusterId(), TypeInfo::GetAttributeId());
-}
-
-- (void)subscribeAttributeOperationalStateListWithParams:(MTRSubscribeParams * _Nonnull)params
-                                 subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished
-                                           reportHandler:
-                                               (void (^)(NSArray * _Nullable value, NSError * _Nullable error))reportHandler
-{
-    using TypeInfo = RvcOperationalState::Attributes::OperationalStateList::TypeInfo;
-    MTRSubscribeAttribute<MTRRVCOperationalStateOperationalStateListListAttributeCallbackSubscriptionBridge, NSArray,
-        TypeInfo::DecodableType>(params, subscriptionEstablished, reportHandler, self.callbackQueue, self.device, self->_endpoint,
-        TypeInfo::GetClusterId(), TypeInfo::GetAttributeId());
-}
-
-+ (void)readAttributeOperationalStateListWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer
-                                                      endpoint:(NSNumber *)endpoint
-                                                         queue:(dispatch_queue_t)queue
-                                                    completion:
-                                                        (void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion
-{
-    auto * bridge = new MTRRVCOperationalStateOperationalStateListListAttributeCallbackBridge(queue, completion);
-    std::move(*bridge).DispatchLocalAction(clusterStateCacheContainer.baseDevice,
-        ^(RVCOperationalStateOperationalStateListListAttributeCallback successCb, MTRErrorCallback failureCb) {
-            if (clusterStateCacheContainer.cppClusterStateCache) {
-                chip::app::ConcreteAttributePath path;
-                using TypeInfo = RvcOperationalState::Attributes::OperationalStateList::TypeInfo;
-                path.mEndpointId = static_cast<chip::EndpointId>([endpoint unsignedShortValue]);
-                path.mClusterId = TypeInfo::GetClusterId();
-                path.mAttributeId = TypeInfo::GetAttributeId();
-                TypeInfo::DecodableType value;
-                CHIP_ERROR err = clusterStateCacheContainer.cppClusterStateCache->Get<TypeInfo>(path, value);
-                if (err == CHIP_NO_ERROR) {
-                    successCb(bridge, value);
-                }
-                return err;
-            }
-            return CHIP_ERROR_NOT_FOUND;
-        });
-}
-
-- (void)readAttributeOperationalStateWithCompletion:(void (^)(MTRRVCOperationalStateClusterOperationalStateStruct * _Nullable value,
-                                                        NSError * _Nullable error))completion
-{
-    MTRReadParams * params = [[MTRReadParams alloc] init];
-    using TypeInfo = RvcOperationalState::Attributes::OperationalState::TypeInfo;
-    return MTRReadAttribute<MTRRVCOperationalStateOperationalStateStructAttributeCallbackBridge,
-        MTRRVCOperationalStateClusterOperationalStateStruct, TypeInfo::DecodableType>(
-        params, completion, self.callbackQueue, self.device, self->_endpoint, TypeInfo::GetClusterId(), TypeInfo::GetAttributeId());
-}
-
-- (void)subscribeAttributeOperationalStateWithParams:(MTRSubscribeParams * _Nonnull)params
-                             subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished
-                                       reportHandler:
-                                           (void (^)(MTRRVCOperationalStateClusterOperationalStateStruct * _Nullable value,
-                                               NSError * _Nullable error))reportHandler
-{
-    using TypeInfo = RvcOperationalState::Attributes::OperationalState::TypeInfo;
-    MTRSubscribeAttribute<MTRRVCOperationalStateOperationalStateStructAttributeCallbackSubscriptionBridge,
-        MTRRVCOperationalStateClusterOperationalStateStruct, TypeInfo::DecodableType>(params, subscriptionEstablished,
-        reportHandler, self.callbackQueue, self.device, self->_endpoint, TypeInfo::GetClusterId(), TypeInfo::GetAttributeId());
-}
-
-+ (void)readAttributeOperationalStateWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer
-                                                  endpoint:(NSNumber *)endpoint
-                                                     queue:(dispatch_queue_t)queue
-                                                completion:
-                                                    (void (^)(MTRRVCOperationalStateClusterOperationalStateStruct * _Nullable value,
-                                                        NSError * _Nullable error))completion
-{
-    auto * bridge = new MTRRVCOperationalStateOperationalStateStructAttributeCallbackBridge(queue, completion);
-    std::move(*bridge).DispatchLocalAction(clusterStateCacheContainer.baseDevice,
-        ^(RVCOperationalStateOperationalStateStructAttributeCallback successCb, MTRErrorCallback failureCb) {
-            if (clusterStateCacheContainer.cppClusterStateCache) {
-                chip::app::ConcreteAttributePath path;
-                using TypeInfo = RvcOperationalState::Attributes::OperationalState::TypeInfo;
-                path.mEndpointId = static_cast<chip::EndpointId>([endpoint unsignedShortValue]);
-                path.mClusterId = TypeInfo::GetClusterId();
-                path.mAttributeId = TypeInfo::GetAttributeId();
-                TypeInfo::DecodableType value;
-                CHIP_ERROR err = clusterStateCacheContainer.cppClusterStateCache->Get<TypeInfo>(path, value);
-                if (err == CHIP_NO_ERROR) {
-                    successCb(bridge, value);
-                }
-                return err;
-            }
-            return CHIP_ERROR_NOT_FOUND;
-        });
-}
-
-- (void)readAttributeOperationalErrorWithCompletion:(void (^)(MTRRVCOperationalStateClusterErrorStateStruct * _Nullable value,
-                                                        NSError * _Nullable error))completion
-{
-    MTRReadParams * params = [[MTRReadParams alloc] init];
-    using TypeInfo = RvcOperationalState::Attributes::OperationalError::TypeInfo;
-    return MTRReadAttribute<MTRRVCOperationalStateOperationalErrorStructAttributeCallbackBridge,
-        MTRRVCOperationalStateClusterErrorStateStruct, TypeInfo::DecodableType>(
-        params, completion, self.callbackQueue, self.device, self->_endpoint, TypeInfo::GetClusterId(), TypeInfo::GetAttributeId());
-}
-
-- (void)subscribeAttributeOperationalErrorWithParams:(MTRSubscribeParams * _Nonnull)params
-                             subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished
-                                       reportHandler:(void (^)(MTRRVCOperationalStateClusterErrorStateStruct * _Nullable value,
-                                                         NSError * _Nullable error))reportHandler
-{
-    using TypeInfo = RvcOperationalState::Attributes::OperationalError::TypeInfo;
-    MTRSubscribeAttribute<MTRRVCOperationalStateOperationalErrorStructAttributeCallbackSubscriptionBridge,
-        MTRRVCOperationalStateClusterErrorStateStruct, TypeInfo::DecodableType>(params, subscriptionEstablished, reportHandler,
-        self.callbackQueue, self.device, self->_endpoint, TypeInfo::GetClusterId(), TypeInfo::GetAttributeId());
-}
-
-+ (void)readAttributeOperationalErrorWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer
-                                                  endpoint:(NSNumber *)endpoint
-                                                     queue:(dispatch_queue_t)queue
-                                                completion:
-                                                    (void (^)(MTRRVCOperationalStateClusterErrorStateStruct * _Nullable value,
-                                                        NSError * _Nullable error))completion
-{
-    auto * bridge = new MTRRVCOperationalStateOperationalErrorStructAttributeCallbackBridge(queue, completion);
-    std::move(*bridge).DispatchLocalAction(clusterStateCacheContainer.baseDevice,
-        ^(RVCOperationalStateOperationalErrorStructAttributeCallback successCb, MTRErrorCallback failureCb) {
-            if (clusterStateCacheContainer.cppClusterStateCache) {
-                chip::app::ConcreteAttributePath path;
-                using TypeInfo = RvcOperationalState::Attributes::OperationalError::TypeInfo;
-                path.mEndpointId = static_cast<chip::EndpointId>([endpoint unsignedShortValue]);
-                path.mClusterId = TypeInfo::GetClusterId();
-                path.mAttributeId = TypeInfo::GetAttributeId();
-                TypeInfo::DecodableType value;
-                CHIP_ERROR err = clusterStateCacheContainer.cppClusterStateCache->Get<TypeInfo>(path, value);
-                if (err == CHIP_NO_ERROR) {
-                    successCb(bridge, value);
-                }
-                return err;
-            }
-            return CHIP_ERROR_NOT_FOUND;
-        });
-}
-
-- (void)readAttributeGeneratedCommandListWithCompletion:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion
-{
-    MTRReadParams * params = [[MTRReadParams alloc] init];
-    using TypeInfo = RvcOperationalState::Attributes::GeneratedCommandList::TypeInfo;
-    return MTRReadAttribute<MTRRVCOperationalStateGeneratedCommandListListAttributeCallbackBridge, NSArray,
-        TypeInfo::DecodableType>(
-        params, completion, self.callbackQueue, self.device, self->_endpoint, TypeInfo::GetClusterId(), TypeInfo::GetAttributeId());
-}
-
-- (void)subscribeAttributeGeneratedCommandListWithParams:(MTRSubscribeParams * _Nonnull)params
-                                 subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished
-                                           reportHandler:
-                                               (void (^)(NSArray * _Nullable value, NSError * _Nullable error))reportHandler
-{
-    using TypeInfo = RvcOperationalState::Attributes::GeneratedCommandList::TypeInfo;
-    MTRSubscribeAttribute<MTRRVCOperationalStateGeneratedCommandListListAttributeCallbackSubscriptionBridge, NSArray,
-        TypeInfo::DecodableType>(params, subscriptionEstablished, reportHandler, self.callbackQueue, self.device, self->_endpoint,
-        TypeInfo::GetClusterId(), TypeInfo::GetAttributeId());
-}
-
-+ (void)readAttributeGeneratedCommandListWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer
-                                                      endpoint:(NSNumber *)endpoint
-                                                         queue:(dispatch_queue_t)queue
-                                                    completion:
-                                                        (void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion
-{
-    auto * bridge = new MTRRVCOperationalStateGeneratedCommandListListAttributeCallbackBridge(queue, completion);
-    std::move(*bridge).DispatchLocalAction(clusterStateCacheContainer.baseDevice,
-        ^(RVCOperationalStateGeneratedCommandListListAttributeCallback successCb, MTRErrorCallback failureCb) {
-            if (clusterStateCacheContainer.cppClusterStateCache) {
-                chip::app::ConcreteAttributePath path;
-                using TypeInfo = RvcOperationalState::Attributes::GeneratedCommandList::TypeInfo;
-                path.mEndpointId = static_cast<chip::EndpointId>([endpoint unsignedShortValue]);
-                path.mClusterId = TypeInfo::GetClusterId();
-                path.mAttributeId = TypeInfo::GetAttributeId();
-                TypeInfo::DecodableType value;
-                CHIP_ERROR err = clusterStateCacheContainer.cppClusterStateCache->Get<TypeInfo>(path, value);
-                if (err == CHIP_NO_ERROR) {
-                    successCb(bridge, value);
-                }
-                return err;
-            }
-            return CHIP_ERROR_NOT_FOUND;
-        });
-}
-
-- (void)readAttributeAcceptedCommandListWithCompletion:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion
-{
-    MTRReadParams * params = [[MTRReadParams alloc] init];
-    using TypeInfo = RvcOperationalState::Attributes::AcceptedCommandList::TypeInfo;
-    return MTRReadAttribute<MTRRVCOperationalStateAcceptedCommandListListAttributeCallbackBridge, NSArray, TypeInfo::DecodableType>(
-        params, completion, self.callbackQueue, self.device, self->_endpoint, TypeInfo::GetClusterId(), TypeInfo::GetAttributeId());
-}
-
-- (void)subscribeAttributeAcceptedCommandListWithParams:(MTRSubscribeParams * _Nonnull)params
-                                subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished
-                                          reportHandler:
-                                              (void (^)(NSArray * _Nullable value, NSError * _Nullable error))reportHandler
-{
-    using TypeInfo = RvcOperationalState::Attributes::AcceptedCommandList::TypeInfo;
-    MTRSubscribeAttribute<MTRRVCOperationalStateAcceptedCommandListListAttributeCallbackSubscriptionBridge, NSArray,
-        TypeInfo::DecodableType>(params, subscriptionEstablished, reportHandler, self.callbackQueue, self.device, self->_endpoint,
-        TypeInfo::GetClusterId(), TypeInfo::GetAttributeId());
-}
-
-+ (void)readAttributeAcceptedCommandListWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer
-                                                     endpoint:(NSNumber *)endpoint
-                                                        queue:(dispatch_queue_t)queue
-                                                   completion:
-                                                       (void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion
-{
-    auto * bridge = new MTRRVCOperationalStateAcceptedCommandListListAttributeCallbackBridge(queue, completion);
-    std::move(*bridge).DispatchLocalAction(clusterStateCacheContainer.baseDevice,
-        ^(RVCOperationalStateAcceptedCommandListListAttributeCallback successCb, MTRErrorCallback failureCb) {
-            if (clusterStateCacheContainer.cppClusterStateCache) {
-                chip::app::ConcreteAttributePath path;
-                using TypeInfo = RvcOperationalState::Attributes::AcceptedCommandList::TypeInfo;
-                path.mEndpointId = static_cast<chip::EndpointId>([endpoint unsignedShortValue]);
-                path.mClusterId = TypeInfo::GetClusterId();
-                path.mAttributeId = TypeInfo::GetAttributeId();
-                TypeInfo::DecodableType value;
-                CHIP_ERROR err = clusterStateCacheContainer.cppClusterStateCache->Get<TypeInfo>(path, value);
-                if (err == CHIP_NO_ERROR) {
-                    successCb(bridge, value);
-                }
-                return err;
-            }
-            return CHIP_ERROR_NOT_FOUND;
-        });
-}
-
-- (void)readAttributeEventListWithCompletion:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion
-{
-    MTRReadParams * params = [[MTRReadParams alloc] init];
-    using TypeInfo = RvcOperationalState::Attributes::EventList::TypeInfo;
-    return MTRReadAttribute<MTRRVCOperationalStateEventListListAttributeCallbackBridge, NSArray, TypeInfo::DecodableType>(
-        params, completion, self.callbackQueue, self.device, self->_endpoint, TypeInfo::GetClusterId(), TypeInfo::GetAttributeId());
-}
-
-- (void)subscribeAttributeEventListWithParams:(MTRSubscribeParams * _Nonnull)params
-                      subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished
-                                reportHandler:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))reportHandler
-{
-    using TypeInfo = RvcOperationalState::Attributes::EventList::TypeInfo;
-    MTRSubscribeAttribute<MTRRVCOperationalStateEventListListAttributeCallbackSubscriptionBridge, NSArray, TypeInfo::DecodableType>(
-        params, subscriptionEstablished, reportHandler, self.callbackQueue, self.device, self->_endpoint, TypeInfo::GetClusterId(),
-        TypeInfo::GetAttributeId());
-}
-
-+ (void)readAttributeEventListWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer
-                                           endpoint:(NSNumber *)endpoint
-                                              queue:(dispatch_queue_t)queue
-                                         completion:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion
-{
-    auto * bridge = new MTRRVCOperationalStateEventListListAttributeCallbackBridge(queue, completion);
-    std::move(*bridge).DispatchLocalAction(clusterStateCacheContainer.baseDevice,
-        ^(RVCOperationalStateEventListListAttributeCallback successCb, MTRErrorCallback failureCb) {
-            if (clusterStateCacheContainer.cppClusterStateCache) {
-                chip::app::ConcreteAttributePath path;
-                using TypeInfo = RvcOperationalState::Attributes::EventList::TypeInfo;
-                path.mEndpointId = static_cast<chip::EndpointId>([endpoint unsignedShortValue]);
-                path.mClusterId = TypeInfo::GetClusterId();
-                path.mAttributeId = TypeInfo::GetAttributeId();
-                TypeInfo::DecodableType value;
-                CHIP_ERROR err = clusterStateCacheContainer.cppClusterStateCache->Get<TypeInfo>(path, value);
-                if (err == CHIP_NO_ERROR) {
-                    successCb(bridge, value);
-                }
-                return err;
-            }
-            return CHIP_ERROR_NOT_FOUND;
-        });
-}
-
-- (void)readAttributeAttributeListWithCompletion:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion
-{
-    MTRReadParams * params = [[MTRReadParams alloc] init];
-    using TypeInfo = RvcOperationalState::Attributes::AttributeList::TypeInfo;
-    return MTRReadAttribute<MTRRVCOperationalStateAttributeListListAttributeCallbackBridge, NSArray, TypeInfo::DecodableType>(
-        params, completion, self.callbackQueue, self.device, self->_endpoint, TypeInfo::GetClusterId(), TypeInfo::GetAttributeId());
-}
-
-- (void)subscribeAttributeAttributeListWithParams:(MTRSubscribeParams * _Nonnull)params
-                          subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished
-                                    reportHandler:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))reportHandler
-{
-    using TypeInfo = RvcOperationalState::Attributes::AttributeList::TypeInfo;
-    MTRSubscribeAttribute<MTRRVCOperationalStateAttributeListListAttributeCallbackSubscriptionBridge, NSArray,
-        TypeInfo::DecodableType>(params, subscriptionEstablished, reportHandler, self.callbackQueue, self.device, self->_endpoint,
-        TypeInfo::GetClusterId(), TypeInfo::GetAttributeId());
-}
-
-+ (void)readAttributeAttributeListWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer
-                                               endpoint:(NSNumber *)endpoint
-                                                  queue:(dispatch_queue_t)queue
-                                             completion:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion
-{
-    auto * bridge = new MTRRVCOperationalStateAttributeListListAttributeCallbackBridge(queue, completion);
-    std::move(*bridge).DispatchLocalAction(clusterStateCacheContainer.baseDevice,
-        ^(RVCOperationalStateAttributeListListAttributeCallback successCb, MTRErrorCallback failureCb) {
-            if (clusterStateCacheContainer.cppClusterStateCache) {
-                chip::app::ConcreteAttributePath path;
-                using TypeInfo = RvcOperationalState::Attributes::AttributeList::TypeInfo;
-                path.mEndpointId = static_cast<chip::EndpointId>([endpoint unsignedShortValue]);
-                path.mClusterId = TypeInfo::GetClusterId();
-                path.mAttributeId = TypeInfo::GetAttributeId();
-                TypeInfo::DecodableType value;
-                CHIP_ERROR err = clusterStateCacheContainer.cppClusterStateCache->Get<TypeInfo>(path, value);
-                if (err == CHIP_NO_ERROR) {
-                    successCb(bridge, value);
-                }
-                return err;
-            }
-            return CHIP_ERROR_NOT_FOUND;
-        });
-}
-
-- (void)readAttributeFeatureMapWithCompletion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion
-{
-    MTRReadParams * params = [[MTRReadParams alloc] init];
-    using TypeInfo = RvcOperationalState::Attributes::FeatureMap::TypeInfo;
-    return MTRReadAttribute<MTRInt32uAttributeCallbackBridge, NSNumber, TypeInfo::DecodableType>(
-        params, completion, self.callbackQueue, self.device, self->_endpoint, TypeInfo::GetClusterId(), TypeInfo::GetAttributeId());
-}
-
-- (void)subscribeAttributeFeatureMapWithParams:(MTRSubscribeParams * _Nonnull)params
-                       subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished
-                                 reportHandler:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))reportHandler
-{
-    using TypeInfo = RvcOperationalState::Attributes::FeatureMap::TypeInfo;
-    MTRSubscribeAttribute<MTRInt32uAttributeCallbackSubscriptionBridge, NSNumber, TypeInfo::DecodableType>(params,
-        subscriptionEstablished, reportHandler, self.callbackQueue, self.device, self->_endpoint, TypeInfo::GetClusterId(),
-        TypeInfo::GetAttributeId());
-}
-
-+ (void)readAttributeFeatureMapWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer
-                                            endpoint:(NSNumber *)endpoint
-                                               queue:(dispatch_queue_t)queue
-                                          completion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion
-{
-    auto * bridge = new MTRInt32uAttributeCallbackBridge(queue, completion);
-    std::move(*bridge).DispatchLocalAction(
-        clusterStateCacheContainer.baseDevice, ^(Int32uAttributeCallback successCb, MTRErrorCallback failureCb) {
-            if (clusterStateCacheContainer.cppClusterStateCache) {
-                chip::app::ConcreteAttributePath path;
-                using TypeInfo = RvcOperationalState::Attributes::FeatureMap::TypeInfo;
-                path.mEndpointId = static_cast<chip::EndpointId>([endpoint unsignedShortValue]);
-                path.mClusterId = TypeInfo::GetClusterId();
-                path.mAttributeId = TypeInfo::GetAttributeId();
-                TypeInfo::DecodableType value;
-                CHIP_ERROR err = clusterStateCacheContainer.cppClusterStateCache->Get<TypeInfo>(path, value);
-                if (err == CHIP_NO_ERROR) {
-                    successCb(bridge, value);
-                }
-                return err;
-            }
-            return CHIP_ERROR_NOT_FOUND;
-        });
-}
-
-- (void)readAttributeClusterRevisionWithCompletion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion
-{
-    MTRReadParams * params = [[MTRReadParams alloc] init];
-    using TypeInfo = RvcOperationalState::Attributes::ClusterRevision::TypeInfo;
-    return MTRReadAttribute<MTRInt16uAttributeCallbackBridge, NSNumber, TypeInfo::DecodableType>(
-        params, completion, self.callbackQueue, self.device, self->_endpoint, TypeInfo::GetClusterId(), TypeInfo::GetAttributeId());
-}
-
-- (void)subscribeAttributeClusterRevisionWithParams:(MTRSubscribeParams * _Nonnull)params
-                            subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished
-                                      reportHandler:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))reportHandler
-{
-    using TypeInfo = RvcOperationalState::Attributes::ClusterRevision::TypeInfo;
-    MTRSubscribeAttribute<MTRInt16uAttributeCallbackSubscriptionBridge, NSNumber, TypeInfo::DecodableType>(params,
-        subscriptionEstablished, reportHandler, self.callbackQueue, self.device, self->_endpoint, TypeInfo::GetClusterId(),
-        TypeInfo::GetAttributeId());
-}
-
-+ (void)readAttributeClusterRevisionWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer
-                                                 endpoint:(NSNumber *)endpoint
-                                                    queue:(dispatch_queue_t)queue
-                                               completion:
-                                                   (void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion
-{
-    auto * bridge = new MTRInt16uAttributeCallbackBridge(queue, completion);
-    std::move(*bridge).DispatchLocalAction(
-        clusterStateCacheContainer.baseDevice, ^(Int16uAttributeCallback successCb, MTRErrorCallback failureCb) {
-            if (clusterStateCacheContainer.cppClusterStateCache) {
-                chip::app::ConcreteAttributePath path;
-                using TypeInfo = RvcOperationalState::Attributes::ClusterRevision::TypeInfo;
-                path.mEndpointId = static_cast<chip::EndpointId>([endpoint unsignedShortValue]);
-                path.mClusterId = TypeInfo::GetClusterId();
-                path.mAttributeId = TypeInfo::GetAttributeId();
-                TypeInfo::DecodableType value;
-                CHIP_ERROR err = clusterStateCacheContainer.cppClusterStateCache->Get<TypeInfo>(path, value);
-                if (err == CHIP_NO_ERROR) {
-                    successCb(bridge, value);
-                }
-                return err;
-            }
-            return CHIP_ERROR_NOT_FOUND;
-        });
-}
-
-@end
-
 @implementation MTRBaseClusterHEPAFilterMonitoring
 
 - (instancetype)initWithDevice:(MTRBaseDevice *)device endpointID:(NSNumber *)endpointID queue:(dispatch_queue_t)queue
diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters_Internal.h b/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters_Internal.h
index d713545..1063a35 100644
--- a/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters_Internal.h
+++ b/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters_Internal.h
@@ -225,11 +225,6 @@
 @property (nonatomic, assign, readonly) chip::EndpointId endpoint;
 @end
 
-@interface MTRBaseClusterRVCOperationalState ()
-@property (nonatomic, strong, readonly) MTRBaseDevice * device;
-@property (nonatomic, assign, readonly) chip::EndpointId endpoint;
-@end
-
 @interface MTRBaseClusterHEPAFilterMonitoring ()
 @property (nonatomic, strong, readonly) MTRBaseDevice * device;
 @property (nonatomic, assign, readonly) chip::EndpointId endpoint;
diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRCallbackBridge.h b/src/darwin/Framework/CHIP/zap-generated/MTRCallbackBridge.h
index 74d4cfe..e239e1f 100644
--- a/src/darwin/Framework/CHIP/zap-generated/MTRCallbackBridge.h
+++ b/src/darwin/Framework/CHIP/zap-generated/MTRCallbackBridge.h
@@ -87,8 +87,6 @@
     void *, const chip::app::Clusters::GroupKeyManagement::Commands::KeySetReadAllIndicesResponse::DecodableType &);
 typedef void (*OperationalStateClusterOperationalCommandResponseCallbackType)(
     void *, const chip::app::Clusters::OperationalState::Commands::OperationalCommandResponse::DecodableType &);
-typedef void (*RVCOperationalStateClusterOperationalCommandResponseCallbackType)(
-    void *, const chip::app::Clusters::RvcOperationalState::Commands::OperationalCommandResponse::DecodableType &);
 typedef void (*DoorLockClusterGetWeekDayScheduleResponseCallbackType)(
     void *, const chip::app::Clusters::DoorLock::Commands::GetWeekDayScheduleResponse::DecodableType &);
 typedef void (*DoorLockClusterGetYearDayScheduleResponseCallbackType)(
@@ -416,14 +414,6 @@
     void *, chip::app::Clusters::OperationalState::OperationalStateEnum);
 typedef void (*NullableOperationalStateClusterOperationalStateEnumAttributeCallback)(
     void *, const chip::app::DataModel::Nullable<chip::app::Clusters::OperationalState::OperationalStateEnum> &);
-typedef void (*RVCOperationalStateClusterErrorStateEnumAttributeCallback)(void *,
-                                                                          chip::app::Clusters::RvcOperationalState::ErrorStateEnum);
-typedef void (*NullableRVCOperationalStateClusterErrorStateEnumAttributeCallback)(
-    void *, const chip::app::DataModel::Nullable<chip::app::Clusters::RvcOperationalState::ErrorStateEnum> &);
-typedef void (*RVCOperationalStateClusterOperationalStateEnumAttributeCallback)(
-    void *, chip::app::Clusters::RvcOperationalState::OperationalStateEnum);
-typedef void (*NullableRVCOperationalStateClusterOperationalStateEnumAttributeCallback)(
-    void *, const chip::app::DataModel::Nullable<chip::app::Clusters::RvcOperationalState::OperationalStateEnum> &);
 typedef void (*HEPAFilterMonitoringClusterChangeIndicationEnumAttributeCallback)(
     void *, chip::app::Clusters::HepaFilterMonitoring::ChangeIndicationEnum);
 typedef void (*NullableHEPAFilterMonitoringClusterChangeIndicationEnumAttributeCallback)(
@@ -1231,24 +1221,6 @@
                                                                const chip::app::DataModel::DecodableList<chip::EventId> & data);
 typedef void (*OperationalStateAttributeListListAttributeCallback)(
     void * context, const chip::app::DataModel::DecodableList<chip::AttributeId> & data);
-typedef void (*RVCOperationalStatePhaseListListAttributeCallback)(
-    void * context, const chip::app::DataModel::Nullable<chip::app::DataModel::DecodableList<chip::CharSpan>> & data);
-typedef void (*RVCOperationalStateOperationalStateListListAttributeCallback)(
-    void * context,
-    const chip::app::DataModel::DecodableList<
-        chip::app::Clusters::RvcOperationalState::Structs::OperationalStateStruct::DecodableType> & data);
-typedef void (*RVCOperationalStateOperationalStateStructAttributeCallback)(
-    void *, const chip::app::Clusters::RvcOperationalState::Structs::OperationalStateStruct::DecodableType &);
-typedef void (*RVCOperationalStateOperationalErrorStructAttributeCallback)(
-    void *, const chip::app::Clusters::RvcOperationalState::Structs::ErrorStateStruct::DecodableType &);
-typedef void (*RVCOperationalStateGeneratedCommandListListAttributeCallback)(
-    void * context, const chip::app::DataModel::DecodableList<chip::CommandId> & data);
-typedef void (*RVCOperationalStateAcceptedCommandListListAttributeCallback)(
-    void * context, const chip::app::DataModel::DecodableList<chip::CommandId> & data);
-typedef void (*RVCOperationalStateEventListListAttributeCallback)(void * context,
-                                                                  const chip::app::DataModel::DecodableList<chip::EventId> & data);
-typedef void (*RVCOperationalStateAttributeListListAttributeCallback)(
-    void * context, const chip::app::DataModel::DecodableList<chip::AttributeId> & data);
 typedef void (*HEPAFilterMonitoringGeneratedCommandListListAttributeCallback)(
     void * context, const chip::app::DataModel::DecodableList<chip::CommandId> & data);
 typedef void (*HEPAFilterMonitoringAcceptedCommandListListAttributeCallback)(
@@ -9619,275 +9591,6 @@
     MTRSubscriptionEstablishedHandler mEstablishedHandler;
 };
 
-class MTRRVCOperationalStatePhaseListListAttributeCallbackBridge
-    : public MTRCallbackBridge<RVCOperationalStatePhaseListListAttributeCallback>
-{
-public:
-    MTRRVCOperationalStatePhaseListListAttributeCallbackBridge(dispatch_queue_t queue, ResponseHandler handler) :
-        MTRCallbackBridge<RVCOperationalStatePhaseListListAttributeCallback>(queue, handler, OnSuccessFn){};
-
-    MTRRVCOperationalStatePhaseListListAttributeCallbackBridge(dispatch_queue_t queue, ResponseHandler handler,
-                                                               MTRActionBlock action) :
-        MTRCallbackBridge<RVCOperationalStatePhaseListListAttributeCallback>(queue, handler, action, OnSuccessFn){};
-
-    static void OnSuccessFn(void * context,
-                            const chip::app::DataModel::Nullable<chip::app::DataModel::DecodableList<chip::CharSpan>> & value);
-};
-
-class MTRRVCOperationalStatePhaseListListAttributeCallbackSubscriptionBridge
-    : public MTRRVCOperationalStatePhaseListListAttributeCallbackBridge
-{
-public:
-    MTRRVCOperationalStatePhaseListListAttributeCallbackSubscriptionBridge(dispatch_queue_t queue, ResponseHandler handler,
-                                                                           MTRActionBlock action,
-                                                                           MTRSubscriptionEstablishedHandler establishedHandler) :
-        MTRRVCOperationalStatePhaseListListAttributeCallbackBridge(queue, handler, action),
-        mEstablishedHandler(establishedHandler)
-    {}
-
-    void OnSubscriptionEstablished();
-    using MTRRVCOperationalStatePhaseListListAttributeCallbackBridge::KeepAliveOnCallback;
-    using MTRRVCOperationalStatePhaseListListAttributeCallbackBridge::OnDone;
-
-private:
-    MTRSubscriptionEstablishedHandler mEstablishedHandler;
-};
-
-class MTRRVCOperationalStateOperationalStateListListAttributeCallbackBridge
-    : public MTRCallbackBridge<RVCOperationalStateOperationalStateListListAttributeCallback>
-{
-public:
-    MTRRVCOperationalStateOperationalStateListListAttributeCallbackBridge(dispatch_queue_t queue, ResponseHandler handler) :
-        MTRCallbackBridge<RVCOperationalStateOperationalStateListListAttributeCallback>(queue, handler, OnSuccessFn){};
-
-    MTRRVCOperationalStateOperationalStateListListAttributeCallbackBridge(dispatch_queue_t queue, ResponseHandler handler,
-                                                                          MTRActionBlock action) :
-        MTRCallbackBridge<RVCOperationalStateOperationalStateListListAttributeCallback>(queue, handler, action, OnSuccessFn){};
-
-    static void OnSuccessFn(void * context,
-                            const chip::app::DataModel::DecodableList<
-                                chip::app::Clusters::RvcOperationalState::Structs::OperationalStateStruct::DecodableType> & value);
-};
-
-class MTRRVCOperationalStateOperationalStateListListAttributeCallbackSubscriptionBridge
-    : public MTRRVCOperationalStateOperationalStateListListAttributeCallbackBridge
-{
-public:
-    MTRRVCOperationalStateOperationalStateListListAttributeCallbackSubscriptionBridge(
-        dispatch_queue_t queue, ResponseHandler handler, MTRActionBlock action,
-        MTRSubscriptionEstablishedHandler establishedHandler) :
-        MTRRVCOperationalStateOperationalStateListListAttributeCallbackBridge(queue, handler, action),
-        mEstablishedHandler(establishedHandler)
-    {}
-
-    void OnSubscriptionEstablished();
-    using MTRRVCOperationalStateOperationalStateListListAttributeCallbackBridge::KeepAliveOnCallback;
-    using MTRRVCOperationalStateOperationalStateListListAttributeCallbackBridge::OnDone;
-
-private:
-    MTRSubscriptionEstablishedHandler mEstablishedHandler;
-};
-
-class MTRRVCOperationalStateOperationalStateStructAttributeCallbackBridge
-    : public MTRCallbackBridge<RVCOperationalStateOperationalStateStructAttributeCallback>
-{
-public:
-    MTRRVCOperationalStateOperationalStateStructAttributeCallbackBridge(dispatch_queue_t queue, ResponseHandler handler) :
-        MTRCallbackBridge<RVCOperationalStateOperationalStateStructAttributeCallback>(queue, handler, OnSuccessFn){};
-
-    MTRRVCOperationalStateOperationalStateStructAttributeCallbackBridge(dispatch_queue_t queue, ResponseHandler handler,
-                                                                        MTRActionBlock action) :
-        MTRCallbackBridge<RVCOperationalStateOperationalStateStructAttributeCallback>(queue, handler, action, OnSuccessFn){};
-
-    static void OnSuccessFn(void * context,
-                            const chip::app::Clusters::RvcOperationalState::Structs::OperationalStateStruct::DecodableType & value);
-};
-
-class MTRRVCOperationalStateOperationalStateStructAttributeCallbackSubscriptionBridge
-    : public MTRRVCOperationalStateOperationalStateStructAttributeCallbackBridge
-{
-public:
-    MTRRVCOperationalStateOperationalStateStructAttributeCallbackSubscriptionBridge(
-        dispatch_queue_t queue, ResponseHandler handler, MTRActionBlock action,
-        MTRSubscriptionEstablishedHandler establishedHandler) :
-        MTRRVCOperationalStateOperationalStateStructAttributeCallbackBridge(queue, handler, action),
-        mEstablishedHandler(establishedHandler)
-    {}
-
-    void OnSubscriptionEstablished();
-    using MTRRVCOperationalStateOperationalStateStructAttributeCallbackBridge::KeepAliveOnCallback;
-    using MTRRVCOperationalStateOperationalStateStructAttributeCallbackBridge::OnDone;
-
-private:
-    MTRSubscriptionEstablishedHandler mEstablishedHandler;
-};
-
-class MTRRVCOperationalStateOperationalErrorStructAttributeCallbackBridge
-    : public MTRCallbackBridge<RVCOperationalStateOperationalErrorStructAttributeCallback>
-{
-public:
-    MTRRVCOperationalStateOperationalErrorStructAttributeCallbackBridge(dispatch_queue_t queue, ResponseHandler handler) :
-        MTRCallbackBridge<RVCOperationalStateOperationalErrorStructAttributeCallback>(queue, handler, OnSuccessFn){};
-
-    MTRRVCOperationalStateOperationalErrorStructAttributeCallbackBridge(dispatch_queue_t queue, ResponseHandler handler,
-                                                                        MTRActionBlock action) :
-        MTRCallbackBridge<RVCOperationalStateOperationalErrorStructAttributeCallback>(queue, handler, action, OnSuccessFn){};
-
-    static void OnSuccessFn(void * context,
-                            const chip::app::Clusters::RvcOperationalState::Structs::ErrorStateStruct::DecodableType & value);
-};
-
-class MTRRVCOperationalStateOperationalErrorStructAttributeCallbackSubscriptionBridge
-    : public MTRRVCOperationalStateOperationalErrorStructAttributeCallbackBridge
-{
-public:
-    MTRRVCOperationalStateOperationalErrorStructAttributeCallbackSubscriptionBridge(
-        dispatch_queue_t queue, ResponseHandler handler, MTRActionBlock action,
-        MTRSubscriptionEstablishedHandler establishedHandler) :
-        MTRRVCOperationalStateOperationalErrorStructAttributeCallbackBridge(queue, handler, action),
-        mEstablishedHandler(establishedHandler)
-    {}
-
-    void OnSubscriptionEstablished();
-    using MTRRVCOperationalStateOperationalErrorStructAttributeCallbackBridge::KeepAliveOnCallback;
-    using MTRRVCOperationalStateOperationalErrorStructAttributeCallbackBridge::OnDone;
-
-private:
-    MTRSubscriptionEstablishedHandler mEstablishedHandler;
-};
-
-class MTRRVCOperationalStateGeneratedCommandListListAttributeCallbackBridge
-    : public MTRCallbackBridge<RVCOperationalStateGeneratedCommandListListAttributeCallback>
-{
-public:
-    MTRRVCOperationalStateGeneratedCommandListListAttributeCallbackBridge(dispatch_queue_t queue, ResponseHandler handler) :
-        MTRCallbackBridge<RVCOperationalStateGeneratedCommandListListAttributeCallback>(queue, handler, OnSuccessFn){};
-
-    MTRRVCOperationalStateGeneratedCommandListListAttributeCallbackBridge(dispatch_queue_t queue, ResponseHandler handler,
-                                                                          MTRActionBlock action) :
-        MTRCallbackBridge<RVCOperationalStateGeneratedCommandListListAttributeCallback>(queue, handler, action, OnSuccessFn){};
-
-    static void OnSuccessFn(void * context, const chip::app::DataModel::DecodableList<chip::CommandId> & value);
-};
-
-class MTRRVCOperationalStateGeneratedCommandListListAttributeCallbackSubscriptionBridge
-    : public MTRRVCOperationalStateGeneratedCommandListListAttributeCallbackBridge
-{
-public:
-    MTRRVCOperationalStateGeneratedCommandListListAttributeCallbackSubscriptionBridge(
-        dispatch_queue_t queue, ResponseHandler handler, MTRActionBlock action,
-        MTRSubscriptionEstablishedHandler establishedHandler) :
-        MTRRVCOperationalStateGeneratedCommandListListAttributeCallbackBridge(queue, handler, action),
-        mEstablishedHandler(establishedHandler)
-    {}
-
-    void OnSubscriptionEstablished();
-    using MTRRVCOperationalStateGeneratedCommandListListAttributeCallbackBridge::KeepAliveOnCallback;
-    using MTRRVCOperationalStateGeneratedCommandListListAttributeCallbackBridge::OnDone;
-
-private:
-    MTRSubscriptionEstablishedHandler mEstablishedHandler;
-};
-
-class MTRRVCOperationalStateAcceptedCommandListListAttributeCallbackBridge
-    : public MTRCallbackBridge<RVCOperationalStateAcceptedCommandListListAttributeCallback>
-{
-public:
-    MTRRVCOperationalStateAcceptedCommandListListAttributeCallbackBridge(dispatch_queue_t queue, ResponseHandler handler) :
-        MTRCallbackBridge<RVCOperationalStateAcceptedCommandListListAttributeCallback>(queue, handler, OnSuccessFn){};
-
-    MTRRVCOperationalStateAcceptedCommandListListAttributeCallbackBridge(dispatch_queue_t queue, ResponseHandler handler,
-                                                                         MTRActionBlock action) :
-        MTRCallbackBridge<RVCOperationalStateAcceptedCommandListListAttributeCallback>(queue, handler, action, OnSuccessFn){};
-
-    static void OnSuccessFn(void * context, const chip::app::DataModel::DecodableList<chip::CommandId> & value);
-};
-
-class MTRRVCOperationalStateAcceptedCommandListListAttributeCallbackSubscriptionBridge
-    : public MTRRVCOperationalStateAcceptedCommandListListAttributeCallbackBridge
-{
-public:
-    MTRRVCOperationalStateAcceptedCommandListListAttributeCallbackSubscriptionBridge(
-        dispatch_queue_t queue, ResponseHandler handler, MTRActionBlock action,
-        MTRSubscriptionEstablishedHandler establishedHandler) :
-        MTRRVCOperationalStateAcceptedCommandListListAttributeCallbackBridge(queue, handler, action),
-        mEstablishedHandler(establishedHandler)
-    {}
-
-    void OnSubscriptionEstablished();
-    using MTRRVCOperationalStateAcceptedCommandListListAttributeCallbackBridge::KeepAliveOnCallback;
-    using MTRRVCOperationalStateAcceptedCommandListListAttributeCallbackBridge::OnDone;
-
-private:
-    MTRSubscriptionEstablishedHandler mEstablishedHandler;
-};
-
-class MTRRVCOperationalStateEventListListAttributeCallbackBridge
-    : public MTRCallbackBridge<RVCOperationalStateEventListListAttributeCallback>
-{
-public:
-    MTRRVCOperationalStateEventListListAttributeCallbackBridge(dispatch_queue_t queue, ResponseHandler handler) :
-        MTRCallbackBridge<RVCOperationalStateEventListListAttributeCallback>(queue, handler, OnSuccessFn){};
-
-    MTRRVCOperationalStateEventListListAttributeCallbackBridge(dispatch_queue_t queue, ResponseHandler handler,
-                                                               MTRActionBlock action) :
-        MTRCallbackBridge<RVCOperationalStateEventListListAttributeCallback>(queue, handler, action, OnSuccessFn){};
-
-    static void OnSuccessFn(void * context, const chip::app::DataModel::DecodableList<chip::EventId> & value);
-};
-
-class MTRRVCOperationalStateEventListListAttributeCallbackSubscriptionBridge
-    : public MTRRVCOperationalStateEventListListAttributeCallbackBridge
-{
-public:
-    MTRRVCOperationalStateEventListListAttributeCallbackSubscriptionBridge(dispatch_queue_t queue, ResponseHandler handler,
-                                                                           MTRActionBlock action,
-                                                                           MTRSubscriptionEstablishedHandler establishedHandler) :
-        MTRRVCOperationalStateEventListListAttributeCallbackBridge(queue, handler, action),
-        mEstablishedHandler(establishedHandler)
-    {}
-
-    void OnSubscriptionEstablished();
-    using MTRRVCOperationalStateEventListListAttributeCallbackBridge::KeepAliveOnCallback;
-    using MTRRVCOperationalStateEventListListAttributeCallbackBridge::OnDone;
-
-private:
-    MTRSubscriptionEstablishedHandler mEstablishedHandler;
-};
-
-class MTRRVCOperationalStateAttributeListListAttributeCallbackBridge
-    : public MTRCallbackBridge<RVCOperationalStateAttributeListListAttributeCallback>
-{
-public:
-    MTRRVCOperationalStateAttributeListListAttributeCallbackBridge(dispatch_queue_t queue, ResponseHandler handler) :
-        MTRCallbackBridge<RVCOperationalStateAttributeListListAttributeCallback>(queue, handler, OnSuccessFn){};
-
-    MTRRVCOperationalStateAttributeListListAttributeCallbackBridge(dispatch_queue_t queue, ResponseHandler handler,
-                                                                   MTRActionBlock action) :
-        MTRCallbackBridge<RVCOperationalStateAttributeListListAttributeCallback>(queue, handler, action, OnSuccessFn){};
-
-    static void OnSuccessFn(void * context, const chip::app::DataModel::DecodableList<chip::AttributeId> & value);
-};
-
-class MTRRVCOperationalStateAttributeListListAttributeCallbackSubscriptionBridge
-    : public MTRRVCOperationalStateAttributeListListAttributeCallbackBridge
-{
-public:
-    MTRRVCOperationalStateAttributeListListAttributeCallbackSubscriptionBridge(
-        dispatch_queue_t queue, ResponseHandler handler, MTRActionBlock action,
-        MTRSubscriptionEstablishedHandler establishedHandler) :
-        MTRRVCOperationalStateAttributeListListAttributeCallbackBridge(queue, handler, action),
-        mEstablishedHandler(establishedHandler)
-    {}
-
-    void OnSubscriptionEstablished();
-    using MTRRVCOperationalStateAttributeListListAttributeCallbackBridge::KeepAliveOnCallback;
-    using MTRRVCOperationalStateAttributeListListAttributeCallbackBridge::OnDone;
-
-private:
-    MTRSubscriptionEstablishedHandler mEstablishedHandler;
-};
-
 class MTRHEPAFilterMonitoringGeneratedCommandListListAttributeCallbackBridge
     : public MTRCallbackBridge<HEPAFilterMonitoringGeneratedCommandListListAttributeCallback>
 {
@@ -17061,22 +16764,6 @@
                 const chip::app::Clusters::OperationalState::Commands::OperationalCommandResponse::DecodableType & data);
 };
 
-class MTRRVCOperationalStateClusterOperationalCommandResponseCallbackBridge
-    : public MTRCallbackBridge<RVCOperationalStateClusterOperationalCommandResponseCallbackType>
-{
-public:
-    MTRRVCOperationalStateClusterOperationalCommandResponseCallbackBridge(dispatch_queue_t queue, ResponseHandler handler) :
-        MTRCallbackBridge<RVCOperationalStateClusterOperationalCommandResponseCallbackType>(queue, handler, OnSuccessFn){};
-
-    MTRRVCOperationalStateClusterOperationalCommandResponseCallbackBridge(dispatch_queue_t queue, ResponseHandler handler,
-                                                                          MTRActionBlock action) :
-        MTRCallbackBridge<RVCOperationalStateClusterOperationalCommandResponseCallbackType>(queue, handler, action, OnSuccessFn){};
-
-    static void
-    OnSuccessFn(void * context,
-                const chip::app::Clusters::RvcOperationalState::Commands::OperationalCommandResponse::DecodableType & data);
-};
-
 class MTRDoorLockClusterGetWeekDayScheduleResponseCallbackBridge
     : public MTRCallbackBridge<DoorLockClusterGetWeekDayScheduleResponseCallbackType>
 {
@@ -22658,144 +22345,6 @@
     MTRSubscriptionEstablishedHandler mEstablishedHandler;
 };
 
-class MTRRVCOperationalStateClusterErrorStateEnumAttributeCallbackBridge
-    : public MTRCallbackBridge<RVCOperationalStateClusterErrorStateEnumAttributeCallback>
-{
-public:
-    MTRRVCOperationalStateClusterErrorStateEnumAttributeCallbackBridge(dispatch_queue_t queue, ResponseHandler handler) :
-        MTRCallbackBridge<RVCOperationalStateClusterErrorStateEnumAttributeCallback>(queue, handler, OnSuccessFn){};
-
-    MTRRVCOperationalStateClusterErrorStateEnumAttributeCallbackBridge(dispatch_queue_t queue, ResponseHandler handler,
-                                                                       MTRActionBlock action) :
-        MTRCallbackBridge<RVCOperationalStateClusterErrorStateEnumAttributeCallback>(queue, handler, action, OnSuccessFn){};
-
-    static void OnSuccessFn(void * context, chip::app::Clusters::RvcOperationalState::ErrorStateEnum value);
-};
-
-class MTRRVCOperationalStateClusterErrorStateEnumAttributeCallbackSubscriptionBridge
-    : public MTRRVCOperationalStateClusterErrorStateEnumAttributeCallbackBridge
-{
-public:
-    MTRRVCOperationalStateClusterErrorStateEnumAttributeCallbackSubscriptionBridge(
-        dispatch_queue_t queue, ResponseHandler handler, MTRActionBlock action,
-        MTRSubscriptionEstablishedHandler establishedHandler) :
-        MTRRVCOperationalStateClusterErrorStateEnumAttributeCallbackBridge(queue, handler, action),
-        mEstablishedHandler(establishedHandler)
-    {}
-
-    void OnSubscriptionEstablished();
-    using MTRRVCOperationalStateClusterErrorStateEnumAttributeCallbackBridge::KeepAliveOnCallback;
-    using MTRRVCOperationalStateClusterErrorStateEnumAttributeCallbackBridge::OnDone;
-
-private:
-    MTRSubscriptionEstablishedHandler mEstablishedHandler;
-};
-
-class MTRNullableRVCOperationalStateClusterErrorStateEnumAttributeCallbackBridge
-    : public MTRCallbackBridge<NullableRVCOperationalStateClusterErrorStateEnumAttributeCallback>
-{
-public:
-    MTRNullableRVCOperationalStateClusterErrorStateEnumAttributeCallbackBridge(dispatch_queue_t queue, ResponseHandler handler) :
-        MTRCallbackBridge<NullableRVCOperationalStateClusterErrorStateEnumAttributeCallback>(queue, handler, OnSuccessFn){};
-
-    MTRNullableRVCOperationalStateClusterErrorStateEnumAttributeCallbackBridge(dispatch_queue_t queue, ResponseHandler handler,
-                                                                               MTRActionBlock action) :
-        MTRCallbackBridge<NullableRVCOperationalStateClusterErrorStateEnumAttributeCallback>(queue, handler, action, OnSuccessFn){};
-
-    static void OnSuccessFn(void * context,
-                            const chip::app::DataModel::Nullable<chip::app::Clusters::RvcOperationalState::ErrorStateEnum> & value);
-};
-
-class MTRNullableRVCOperationalStateClusterErrorStateEnumAttributeCallbackSubscriptionBridge
-    : public MTRNullableRVCOperationalStateClusterErrorStateEnumAttributeCallbackBridge
-{
-public:
-    MTRNullableRVCOperationalStateClusterErrorStateEnumAttributeCallbackSubscriptionBridge(
-        dispatch_queue_t queue, ResponseHandler handler, MTRActionBlock action,
-        MTRSubscriptionEstablishedHandler establishedHandler) :
-        MTRNullableRVCOperationalStateClusterErrorStateEnumAttributeCallbackBridge(queue, handler, action),
-        mEstablishedHandler(establishedHandler)
-    {}
-
-    void OnSubscriptionEstablished();
-    using MTRNullableRVCOperationalStateClusterErrorStateEnumAttributeCallbackBridge::KeepAliveOnCallback;
-    using MTRNullableRVCOperationalStateClusterErrorStateEnumAttributeCallbackBridge::OnDone;
-
-private:
-    MTRSubscriptionEstablishedHandler mEstablishedHandler;
-};
-
-class MTRRVCOperationalStateClusterOperationalStateEnumAttributeCallbackBridge
-    : public MTRCallbackBridge<RVCOperationalStateClusterOperationalStateEnumAttributeCallback>
-{
-public:
-    MTRRVCOperationalStateClusterOperationalStateEnumAttributeCallbackBridge(dispatch_queue_t queue, ResponseHandler handler) :
-        MTRCallbackBridge<RVCOperationalStateClusterOperationalStateEnumAttributeCallback>(queue, handler, OnSuccessFn){};
-
-    MTRRVCOperationalStateClusterOperationalStateEnumAttributeCallbackBridge(dispatch_queue_t queue, ResponseHandler handler,
-                                                                             MTRActionBlock action) :
-        MTRCallbackBridge<RVCOperationalStateClusterOperationalStateEnumAttributeCallback>(queue, handler, action, OnSuccessFn){};
-
-    static void OnSuccessFn(void * context, chip::app::Clusters::RvcOperationalState::OperationalStateEnum value);
-};
-
-class MTRRVCOperationalStateClusterOperationalStateEnumAttributeCallbackSubscriptionBridge
-    : public MTRRVCOperationalStateClusterOperationalStateEnumAttributeCallbackBridge
-{
-public:
-    MTRRVCOperationalStateClusterOperationalStateEnumAttributeCallbackSubscriptionBridge(
-        dispatch_queue_t queue, ResponseHandler handler, MTRActionBlock action,
-        MTRSubscriptionEstablishedHandler establishedHandler) :
-        MTRRVCOperationalStateClusterOperationalStateEnumAttributeCallbackBridge(queue, handler, action),
-        mEstablishedHandler(establishedHandler)
-    {}
-
-    void OnSubscriptionEstablished();
-    using MTRRVCOperationalStateClusterOperationalStateEnumAttributeCallbackBridge::KeepAliveOnCallback;
-    using MTRRVCOperationalStateClusterOperationalStateEnumAttributeCallbackBridge::OnDone;
-
-private:
-    MTRSubscriptionEstablishedHandler mEstablishedHandler;
-};
-
-class MTRNullableRVCOperationalStateClusterOperationalStateEnumAttributeCallbackBridge
-    : public MTRCallbackBridge<NullableRVCOperationalStateClusterOperationalStateEnumAttributeCallback>
-{
-public:
-    MTRNullableRVCOperationalStateClusterOperationalStateEnumAttributeCallbackBridge(dispatch_queue_t queue,
-                                                                                     ResponseHandler handler) :
-        MTRCallbackBridge<NullableRVCOperationalStateClusterOperationalStateEnumAttributeCallback>(queue, handler, OnSuccessFn){};
-
-    MTRNullableRVCOperationalStateClusterOperationalStateEnumAttributeCallbackBridge(dispatch_queue_t queue,
-                                                                                     ResponseHandler handler,
-                                                                                     MTRActionBlock action) :
-        MTRCallbackBridge<NullableRVCOperationalStateClusterOperationalStateEnumAttributeCallback>(queue, handler, action,
-                                                                                                   OnSuccessFn){};
-
-    static void
-    OnSuccessFn(void * context,
-                const chip::app::DataModel::Nullable<chip::app::Clusters::RvcOperationalState::OperationalStateEnum> & value);
-};
-
-class MTRNullableRVCOperationalStateClusterOperationalStateEnumAttributeCallbackSubscriptionBridge
-    : public MTRNullableRVCOperationalStateClusterOperationalStateEnumAttributeCallbackBridge
-{
-public:
-    MTRNullableRVCOperationalStateClusterOperationalStateEnumAttributeCallbackSubscriptionBridge(
-        dispatch_queue_t queue, ResponseHandler handler, MTRActionBlock action,
-        MTRSubscriptionEstablishedHandler establishedHandler) :
-        MTRNullableRVCOperationalStateClusterOperationalStateEnumAttributeCallbackBridge(queue, handler, action),
-        mEstablishedHandler(establishedHandler)
-    {}
-
-    void OnSubscriptionEstablished();
-    using MTRNullableRVCOperationalStateClusterOperationalStateEnumAttributeCallbackBridge::KeepAliveOnCallback;
-    using MTRNullableRVCOperationalStateClusterOperationalStateEnumAttributeCallbackBridge::OnDone;
-
-private:
-    MTRSubscriptionEstablishedHandler mEstablishedHandler;
-};
-
 class MTRHEPAFilterMonitoringClusterChangeIndicationEnumAttributeCallbackBridge
     : public MTRCallbackBridge<HEPAFilterMonitoringClusterChangeIndicationEnumAttributeCallback>
 {
diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRCallbackBridge.mm b/src/darwin/Framework/CHIP/zap-generated/MTRCallbackBridge.mm
index 6314800..2a0dd1d 100644
--- a/src/darwin/Framework/CHIP/zap-generated/MTRCallbackBridge.mm
+++ b/src/darwin/Framework/CHIP/zap-generated/MTRCallbackBridge.mm
@@ -9229,333 +9229,6 @@
     }
 }
 
-void MTRRVCOperationalStatePhaseListListAttributeCallbackBridge::OnSuccessFn(
-    void * context, const chip::app::DataModel::Nullable<chip::app::DataModel::DecodableList<chip::CharSpan>> & value)
-{
-    NSArray * _Nullable objCValue;
-    if (value.IsNull()) {
-        objCValue = nil;
-    } else {
-        { // Scope for our temporary variables
-            auto * array_1 = [NSMutableArray new];
-            auto iter_1 = value.Value().begin();
-            while (iter_1.Next()) {
-                auto & entry_1 = iter_1.GetValue();
-                NSString * newElement_1;
-                newElement_1 = AsString(entry_1);
-                if (newElement_1 == nil) {
-                    CHIP_ERROR err = CHIP_ERROR_INVALID_ARGUMENT;
-                    OnFailureFn(context, err);
-                    return;
-                }
-                [array_1 addObject:newElement_1];
-            }
-            CHIP_ERROR err = iter_1.GetStatus();
-            if (err != CHIP_NO_ERROR) {
-                OnFailureFn(context, err);
-                return;
-            }
-            objCValue = array_1;
-        }
-    }
-    DispatchSuccess(context, objCValue);
-};
-
-void MTRRVCOperationalStatePhaseListListAttributeCallbackSubscriptionBridge::OnSubscriptionEstablished()
-{
-    if (!mQueue) {
-        return;
-    }
-
-    if (mEstablishedHandler != nil) {
-        dispatch_async(mQueue, mEstablishedHandler);
-        // On failure, mEstablishedHandler will be cleaned up by our destructor,
-        // but we can clean it up earlier on successful subscription
-        // establishment.
-        mEstablishedHandler = nil;
-    }
-}
-
-void MTRRVCOperationalStateOperationalStateListListAttributeCallbackBridge::OnSuccessFn(void * context,
-    const chip::app::DataModel::DecodableList<
-        chip::app::Clusters::RvcOperationalState::Structs::OperationalStateStruct::DecodableType> & value)
-{
-    NSArray * _Nonnull objCValue;
-    { // Scope for our temporary variables
-        auto * array_0 = [NSMutableArray new];
-        auto iter_0 = value.begin();
-        while (iter_0.Next()) {
-            auto & entry_0 = iter_0.GetValue();
-            MTRRVCOperationalStateClusterOperationalStateStruct * newElement_0;
-            newElement_0 = [MTRRVCOperationalStateClusterOperationalStateStruct new];
-            newElement_0.operationalStateID = [NSNumber numberWithUnsignedChar:entry_0.operationalStateID];
-            if (entry_0.operationalStateLabel.HasValue()) {
-                newElement_0.operationalStateLabel = AsString(entry_0.operationalStateLabel.Value());
-                if (newElement_0.operationalStateLabel == nil) {
-                    CHIP_ERROR err = CHIP_ERROR_INVALID_ARGUMENT;
-                    OnFailureFn(context, err);
-                    return;
-                }
-            } else {
-                newElement_0.operationalStateLabel = nil;
-            }
-            [array_0 addObject:newElement_0];
-        }
-        CHIP_ERROR err = iter_0.GetStatus();
-        if (err != CHIP_NO_ERROR) {
-            OnFailureFn(context, err);
-            return;
-        }
-        objCValue = array_0;
-    }
-    DispatchSuccess(context, objCValue);
-};
-
-void MTRRVCOperationalStateOperationalStateListListAttributeCallbackSubscriptionBridge::OnSubscriptionEstablished()
-{
-    if (!mQueue) {
-        return;
-    }
-
-    if (mEstablishedHandler != nil) {
-        dispatch_async(mQueue, mEstablishedHandler);
-        // On failure, mEstablishedHandler will be cleaned up by our destructor,
-        // but we can clean it up earlier on successful subscription
-        // establishment.
-        mEstablishedHandler = nil;
-    }
-}
-
-void MTRRVCOperationalStateOperationalStateStructAttributeCallbackBridge::OnSuccessFn(
-    void * context, const chip::app::Clusters::RvcOperationalState::Structs::OperationalStateStruct::DecodableType & value)
-{
-    MTRRVCOperationalStateClusterOperationalStateStruct * _Nonnull objCValue;
-    objCValue = [MTRRVCOperationalStateClusterOperationalStateStruct new];
-    objCValue.operationalStateID = [NSNumber numberWithUnsignedChar:value.operationalStateID];
-    if (value.operationalStateLabel.HasValue()) {
-        objCValue.operationalStateLabel = AsString(value.operationalStateLabel.Value());
-        if (objCValue.operationalStateLabel == nil) {
-            CHIP_ERROR err = CHIP_ERROR_INVALID_ARGUMENT;
-            OnFailureFn(context, err);
-            return;
-        }
-    } else {
-        objCValue.operationalStateLabel = nil;
-    }
-    DispatchSuccess(context, objCValue);
-};
-
-void MTRRVCOperationalStateOperationalStateStructAttributeCallbackSubscriptionBridge::OnSubscriptionEstablished()
-{
-    if (!mQueue) {
-        return;
-    }
-
-    if (mEstablishedHandler != nil) {
-        dispatch_async(mQueue, mEstablishedHandler);
-        // On failure, mEstablishedHandler will be cleaned up by our destructor,
-        // but we can clean it up earlier on successful subscription
-        // establishment.
-        mEstablishedHandler = nil;
-    }
-}
-
-void MTRRVCOperationalStateOperationalErrorStructAttributeCallbackBridge::OnSuccessFn(
-    void * context, const chip::app::Clusters::RvcOperationalState::Structs::ErrorStateStruct::DecodableType & value)
-{
-    MTRRVCOperationalStateClusterErrorStateStruct * _Nonnull objCValue;
-    objCValue = [MTRRVCOperationalStateClusterErrorStateStruct new];
-    objCValue.errorStateID = [NSNumber numberWithUnsignedChar:value.errorStateID];
-    if (value.errorStateLabel.HasValue()) {
-        objCValue.errorStateLabel = AsString(value.errorStateLabel.Value());
-        if (objCValue.errorStateLabel == nil) {
-            CHIP_ERROR err = CHIP_ERROR_INVALID_ARGUMENT;
-            OnFailureFn(context, err);
-            return;
-        }
-    } else {
-        objCValue.errorStateLabel = nil;
-    }
-    if (value.errorStateDetails.HasValue()) {
-        objCValue.errorStateDetails = AsString(value.errorStateDetails.Value());
-        if (objCValue.errorStateDetails == nil) {
-            CHIP_ERROR err = CHIP_ERROR_INVALID_ARGUMENT;
-            OnFailureFn(context, err);
-            return;
-        }
-    } else {
-        objCValue.errorStateDetails = nil;
-    }
-    DispatchSuccess(context, objCValue);
-};
-
-void MTRRVCOperationalStateOperationalErrorStructAttributeCallbackSubscriptionBridge::OnSubscriptionEstablished()
-{
-    if (!mQueue) {
-        return;
-    }
-
-    if (mEstablishedHandler != nil) {
-        dispatch_async(mQueue, mEstablishedHandler);
-        // On failure, mEstablishedHandler will be cleaned up by our destructor,
-        // but we can clean it up earlier on successful subscription
-        // establishment.
-        mEstablishedHandler = nil;
-    }
-}
-
-void MTRRVCOperationalStateGeneratedCommandListListAttributeCallbackBridge::OnSuccessFn(
-    void * context, const chip::app::DataModel::DecodableList<chip::CommandId> & value)
-{
-    NSArray * _Nonnull objCValue;
-    { // Scope for our temporary variables
-        auto * array_0 = [NSMutableArray new];
-        auto iter_0 = value.begin();
-        while (iter_0.Next()) {
-            auto & entry_0 = iter_0.GetValue();
-            NSNumber * newElement_0;
-            newElement_0 = [NSNumber numberWithUnsignedInt:entry_0];
-            [array_0 addObject:newElement_0];
-        }
-        CHIP_ERROR err = iter_0.GetStatus();
-        if (err != CHIP_NO_ERROR) {
-            OnFailureFn(context, err);
-            return;
-        }
-        objCValue = array_0;
-    }
-    DispatchSuccess(context, objCValue);
-};
-
-void MTRRVCOperationalStateGeneratedCommandListListAttributeCallbackSubscriptionBridge::OnSubscriptionEstablished()
-{
-    if (!mQueue) {
-        return;
-    }
-
-    if (mEstablishedHandler != nil) {
-        dispatch_async(mQueue, mEstablishedHandler);
-        // On failure, mEstablishedHandler will be cleaned up by our destructor,
-        // but we can clean it up earlier on successful subscription
-        // establishment.
-        mEstablishedHandler = nil;
-    }
-}
-
-void MTRRVCOperationalStateAcceptedCommandListListAttributeCallbackBridge::OnSuccessFn(
-    void * context, const chip::app::DataModel::DecodableList<chip::CommandId> & value)
-{
-    NSArray * _Nonnull objCValue;
-    { // Scope for our temporary variables
-        auto * array_0 = [NSMutableArray new];
-        auto iter_0 = value.begin();
-        while (iter_0.Next()) {
-            auto & entry_0 = iter_0.GetValue();
-            NSNumber * newElement_0;
-            newElement_0 = [NSNumber numberWithUnsignedInt:entry_0];
-            [array_0 addObject:newElement_0];
-        }
-        CHIP_ERROR err = iter_0.GetStatus();
-        if (err != CHIP_NO_ERROR) {
-            OnFailureFn(context, err);
-            return;
-        }
-        objCValue = array_0;
-    }
-    DispatchSuccess(context, objCValue);
-};
-
-void MTRRVCOperationalStateAcceptedCommandListListAttributeCallbackSubscriptionBridge::OnSubscriptionEstablished()
-{
-    if (!mQueue) {
-        return;
-    }
-
-    if (mEstablishedHandler != nil) {
-        dispatch_async(mQueue, mEstablishedHandler);
-        // On failure, mEstablishedHandler will be cleaned up by our destructor,
-        // but we can clean it up earlier on successful subscription
-        // establishment.
-        mEstablishedHandler = nil;
-    }
-}
-
-void MTRRVCOperationalStateEventListListAttributeCallbackBridge::OnSuccessFn(
-    void * context, const chip::app::DataModel::DecodableList<chip::EventId> & value)
-{
-    NSArray * _Nonnull objCValue;
-    { // Scope for our temporary variables
-        auto * array_0 = [NSMutableArray new];
-        auto iter_0 = value.begin();
-        while (iter_0.Next()) {
-            auto & entry_0 = iter_0.GetValue();
-            NSNumber * newElement_0;
-            newElement_0 = [NSNumber numberWithUnsignedInt:entry_0];
-            [array_0 addObject:newElement_0];
-        }
-        CHIP_ERROR err = iter_0.GetStatus();
-        if (err != CHIP_NO_ERROR) {
-            OnFailureFn(context, err);
-            return;
-        }
-        objCValue = array_0;
-    }
-    DispatchSuccess(context, objCValue);
-};
-
-void MTRRVCOperationalStateEventListListAttributeCallbackSubscriptionBridge::OnSubscriptionEstablished()
-{
-    if (!mQueue) {
-        return;
-    }
-
-    if (mEstablishedHandler != nil) {
-        dispatch_async(mQueue, mEstablishedHandler);
-        // On failure, mEstablishedHandler will be cleaned up by our destructor,
-        // but we can clean it up earlier on successful subscription
-        // establishment.
-        mEstablishedHandler = nil;
-    }
-}
-
-void MTRRVCOperationalStateAttributeListListAttributeCallbackBridge::OnSuccessFn(
-    void * context, const chip::app::DataModel::DecodableList<chip::AttributeId> & value)
-{
-    NSArray * _Nonnull objCValue;
-    { // Scope for our temporary variables
-        auto * array_0 = [NSMutableArray new];
-        auto iter_0 = value.begin();
-        while (iter_0.Next()) {
-            auto & entry_0 = iter_0.GetValue();
-            NSNumber * newElement_0;
-            newElement_0 = [NSNumber numberWithUnsignedInt:entry_0];
-            [array_0 addObject:newElement_0];
-        }
-        CHIP_ERROR err = iter_0.GetStatus();
-        if (err != CHIP_NO_ERROR) {
-            OnFailureFn(context, err);
-            return;
-        }
-        objCValue = array_0;
-    }
-    DispatchSuccess(context, objCValue);
-};
-
-void MTRRVCOperationalStateAttributeListListAttributeCallbackSubscriptionBridge::OnSubscriptionEstablished()
-{
-    if (!mQueue) {
-        return;
-    }
-
-    if (mEstablishedHandler != nil) {
-        dispatch_async(mQueue, mEstablishedHandler);
-        // On failure, mEstablishedHandler will be cleaned up by our destructor,
-        // but we can clean it up earlier on successful subscription
-        // establishment.
-        mEstablishedHandler = nil;
-    }
-}
-
 void MTRHEPAFilterMonitoringGeneratedCommandListListAttributeCallbackBridge::OnSuccessFn(
     void * context, const chip::app::DataModel::DecodableList<chip::CommandId> & value)
 {
@@ -17740,18 +17413,6 @@
     DispatchSuccess(context, response);
 };
 
-void MTRRVCOperationalStateClusterOperationalCommandResponseCallbackBridge::OnSuccessFn(
-    void * context, const chip::app::Clusters::RvcOperationalState::Commands::OperationalCommandResponse::DecodableType & data)
-{
-    auto * response = [MTRRVCOperationalStateClusterOperationalCommandResponseParams new];
-    CHIP_ERROR err = [response _setFieldsFromDecodableStruct:data];
-    if (err != CHIP_NO_ERROR) {
-        OnFailureFn(context, err);
-        return;
-    }
-    DispatchSuccess(context, response);
-};
-
 void MTRDoorLockClusterGetWeekDayScheduleResponseCallbackBridge::OnSuccessFn(
     void * context, const chip::app::Clusters::DoorLock::Commands::GetWeekDayScheduleResponse::DecodableType & data)
 {
@@ -21823,106 +21484,6 @@
     }
 }
 
-void MTRRVCOperationalStateClusterErrorStateEnumAttributeCallbackBridge::OnSuccessFn(
-    void * context, chip::app::Clusters::RvcOperationalState::ErrorStateEnum value)
-{
-    NSNumber * _Nonnull objCValue;
-    objCValue = [NSNumber numberWithUnsignedChar:chip::to_underlying(value)];
-    DispatchSuccess(context, objCValue);
-};
-
-void MTRRVCOperationalStateClusterErrorStateEnumAttributeCallbackSubscriptionBridge::OnSubscriptionEstablished()
-{
-    if (!mQueue) {
-        return;
-    }
-
-    if (mEstablishedHandler != nil) {
-        dispatch_async(mQueue, mEstablishedHandler);
-        // On failure, mEstablishedHandler will be cleaned up by our destructor,
-        // but we can clean it up earlier on successful subscription
-        // establishment.
-        mEstablishedHandler = nil;
-    }
-}
-
-void MTRNullableRVCOperationalStateClusterErrorStateEnumAttributeCallbackBridge::OnSuccessFn(
-    void * context, const chip::app::DataModel::Nullable<chip::app::Clusters::RvcOperationalState::ErrorStateEnum> & value)
-{
-    NSNumber * _Nullable objCValue;
-    if (value.IsNull()) {
-        objCValue = nil;
-    } else {
-        objCValue = [NSNumber numberWithUnsignedChar:chip::to_underlying(value.Value())];
-    }
-    DispatchSuccess(context, objCValue);
-};
-
-void MTRNullableRVCOperationalStateClusterErrorStateEnumAttributeCallbackSubscriptionBridge::OnSubscriptionEstablished()
-{
-    if (!mQueue) {
-        return;
-    }
-
-    if (mEstablishedHandler != nil) {
-        dispatch_async(mQueue, mEstablishedHandler);
-        // On failure, mEstablishedHandler will be cleaned up by our destructor,
-        // but we can clean it up earlier on successful subscription
-        // establishment.
-        mEstablishedHandler = nil;
-    }
-}
-
-void MTRRVCOperationalStateClusterOperationalStateEnumAttributeCallbackBridge::OnSuccessFn(
-    void * context, chip::app::Clusters::RvcOperationalState::OperationalStateEnum value)
-{
-    NSNumber * _Nonnull objCValue;
-    objCValue = [NSNumber numberWithUnsignedChar:chip::to_underlying(value)];
-    DispatchSuccess(context, objCValue);
-};
-
-void MTRRVCOperationalStateClusterOperationalStateEnumAttributeCallbackSubscriptionBridge::OnSubscriptionEstablished()
-{
-    if (!mQueue) {
-        return;
-    }
-
-    if (mEstablishedHandler != nil) {
-        dispatch_async(mQueue, mEstablishedHandler);
-        // On failure, mEstablishedHandler will be cleaned up by our destructor,
-        // but we can clean it up earlier on successful subscription
-        // establishment.
-        mEstablishedHandler = nil;
-    }
-}
-
-void MTRNullableRVCOperationalStateClusterOperationalStateEnumAttributeCallbackBridge::OnSuccessFn(
-    void * context, const chip::app::DataModel::Nullable<chip::app::Clusters::RvcOperationalState::OperationalStateEnum> & value)
-{
-    NSNumber * _Nullable objCValue;
-    if (value.IsNull()) {
-        objCValue = nil;
-    } else {
-        objCValue = [NSNumber numberWithUnsignedChar:chip::to_underlying(value.Value())];
-    }
-    DispatchSuccess(context, objCValue);
-};
-
-void MTRNullableRVCOperationalStateClusterOperationalStateEnumAttributeCallbackSubscriptionBridge::OnSubscriptionEstablished()
-{
-    if (!mQueue) {
-        return;
-    }
-
-    if (mEstablishedHandler != nil) {
-        dispatch_async(mQueue, mEstablishedHandler);
-        // On failure, mEstablishedHandler will be cleaned up by our destructor,
-        // but we can clean it up earlier on successful subscription
-        // establishment.
-        mEstablishedHandler = nil;
-    }
-}
-
 void MTRHEPAFilterMonitoringClusterChangeIndicationEnumAttributeCallbackBridge::OnSuccessFn(
     void * context, chip::app::Clusters::HepaFilterMonitoring::ChangeIndicationEnum value)
 {
diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRClusterConstants.h b/src/darwin/Framework/CHIP/zap-generated/MTRClusterConstants.h
index 92f35f6..0e06ba4 100644
--- a/src/darwin/Framework/CHIP/zap-generated/MTRClusterConstants.h
+++ b/src/darwin/Framework/CHIP/zap-generated/MTRClusterConstants.h
@@ -281,7 +281,6 @@
     MTRClusterIDTypeAirQualityID MTR_NEWLY_AVAILABLE = 0x0000005B,
     MTRClusterIDTypeSmokeCOAlarmID MTR_NEWLY_AVAILABLE = 0x0000005C,
     MTRClusterIDTypeOperationalStateID MTR_NEWLY_AVAILABLE = 0x00000060,
-    MTRClusterIDTypeRVCOperationalStateID MTR_NEWLY_AVAILABLE = 0x00000061,
     MTRClusterIDTypeHEPAFilterMonitoringID MTR_NEWLY_AVAILABLE = 0x00000071,
     MTRClusterIDTypeActivatedCarbonFilterMonitoringID MTR_NEWLY_AVAILABLE = 0x00000072,
     MTRClusterIDTypeDoorLockID API_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)) = 0x00000101,
@@ -3826,26 +3825,6 @@
     MTRAttributeIDTypeClusterOperationalStateAttributeClusterRevisionID MTR_NEWLY_AVAILABLE
     = MTRAttributeIDTypeGlobalAttributeClusterRevisionID,
 
-    // Cluster RVCOperationalState attributes
-    MTRAttributeIDTypeClusterRVCOperationalStateAttributePhaseListID MTR_NEWLY_AVAILABLE = 0x00000000,
-    MTRAttributeIDTypeClusterRVCOperationalStateAttributeCurrentPhaseID MTR_NEWLY_AVAILABLE = 0x00000001,
-    MTRAttributeIDTypeClusterRVCOperationalStateAttributeCountdownTimeID MTR_NEWLY_AVAILABLE = 0x00000002,
-    MTRAttributeIDTypeClusterRVCOperationalStateAttributeOperationalStateListID MTR_NEWLY_AVAILABLE = 0x00000003,
-    MTRAttributeIDTypeClusterRVCOperationalStateAttributeOperationalStateID MTR_NEWLY_AVAILABLE = 0x00000004,
-    MTRAttributeIDTypeClusterRVCOperationalStateAttributeOperationalErrorID MTR_NEWLY_AVAILABLE = 0x00000005,
-    MTRAttributeIDTypeClusterRVCOperationalStateAttributeGeneratedCommandListID MTR_NEWLY_AVAILABLE
-    = MTRAttributeIDTypeGlobalAttributeGeneratedCommandListID,
-    MTRAttributeIDTypeClusterRVCOperationalStateAttributeAcceptedCommandListID MTR_NEWLY_AVAILABLE
-    = MTRAttributeIDTypeGlobalAttributeAcceptedCommandListID,
-    MTRAttributeIDTypeClusterRVCOperationalStateAttributeEventListID MTR_NEWLY_AVAILABLE
-    = MTRAttributeIDTypeGlobalAttributeEventListID,
-    MTRAttributeIDTypeClusterRVCOperationalStateAttributeAttributeListID MTR_NEWLY_AVAILABLE
-    = MTRAttributeIDTypeGlobalAttributeAttributeListID,
-    MTRAttributeIDTypeClusterRVCOperationalStateAttributeFeatureMapID MTR_NEWLY_AVAILABLE
-    = MTRAttributeIDTypeGlobalAttributeFeatureMapID,
-    MTRAttributeIDTypeClusterRVCOperationalStateAttributeClusterRevisionID MTR_NEWLY_AVAILABLE
-    = MTRAttributeIDTypeGlobalAttributeClusterRevisionID,
-
     // Cluster HEPAFilterMonitoring attributes
     MTRAttributeIDTypeClusterHEPAFilterMonitoringAttributeConditionID MTR_NEWLY_AVAILABLE = 0x00000000,
     MTRAttributeIDTypeClusterHEPAFilterMonitoringAttributeDegradationDirectionID MTR_NEWLY_AVAILABLE = 0x00000001,
@@ -9297,13 +9276,6 @@
     MTRCommandIDTypeClusterOperationalStateCommandResumeID MTR_NEWLY_AVAILABLE = 0x00000003,
     MTRCommandIDTypeClusterOperationalStateCommandOperationalCommandResponseID MTR_NEWLY_AVAILABLE = 0x00000004,
 
-    // Cluster RVCOperationalState commands
-    MTRCommandIDTypeClusterRVCOperationalStateCommandPauseID MTR_NEWLY_AVAILABLE = 0x00000000,
-    MTRCommandIDTypeClusterRVCOperationalStateCommandStopID MTR_NEWLY_AVAILABLE = 0x00000001,
-    MTRCommandIDTypeClusterRVCOperationalStateCommandStartID MTR_NEWLY_AVAILABLE = 0x00000002,
-    MTRCommandIDTypeClusterRVCOperationalStateCommandResumeID MTR_NEWLY_AVAILABLE = 0x00000003,
-    MTRCommandIDTypeClusterRVCOperationalStateCommandOperationalCommandResponseID MTR_NEWLY_AVAILABLE = 0x00000004,
-
     // Cluster HEPAFilterMonitoring commands
     MTRCommandIDTypeClusterHEPAFilterMonitoringCommandResetConditionID MTR_NEWLY_AVAILABLE = 0x00000000,
 
@@ -10453,10 +10425,6 @@
     MTREventIDTypeClusterOperationalStateEventOperationalErrorID MTR_NEWLY_AVAILABLE = 0x00000000,
     MTREventIDTypeClusterOperationalStateEventOperationCompletionID MTR_NEWLY_AVAILABLE = 0x00000001,
 
-    // Cluster RVCOperationalState events
-    MTREventIDTypeClusterRVCOperationalStateEventOperationalErrorID MTR_NEWLY_AVAILABLE = 0x00000000,
-    MTREventIDTypeClusterRVCOperationalStateEventOperationCompletionID MTR_NEWLY_AVAILABLE = 0x00000001,
-
     // Cluster DoorLock deprecated event names
     MTRClusterDoorLockEventDoorLockAlarmID MTR_DEPRECATED("Please use MTREventIDTypeClusterDoorLockEventDoorLockAlarmID",
         ios(16.1, 16.4), macos(13.0, 13.3), watchos(9.1, 9.4), tvos(16.1, 16.4))
diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRClusters.h b/src/darwin/Framework/CHIP/zap-generated/MTRClusters.h
index 7f62aa4..dcc4a19 100644
--- a/src/darwin/Framework/CHIP/zap-generated/MTRClusters.h
+++ b/src/darwin/Framework/CHIP/zap-generated/MTRClusters.h
@@ -3057,83 +3057,6 @@
 @end
 
 /**
- * Cluster RVC Operational State
- *    This cluster supports remotely monitoring and, where supported, changing the operational state of a Robotic Vacuum.
- */
-MTR_NEWLY_AVAILABLE
-@interface MTRClusterRVCOperationalState : MTRCluster
-
-- (instancetype _Nullable)initWithDevice:(MTRDevice *)device
-                              endpointID:(NSNumber *)endpointID
-                                   queue:(dispatch_queue_t)queue NS_DESIGNATED_INITIALIZER MTR_NEWLY_AVAILABLE;
-
-- (void)pauseWithParams:(MTRRVCOperationalStateClusterPauseParams * _Nullable)params
-           expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
-    expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
-               completion:(void (^)(MTRRVCOperationalStateClusterOperationalCommandResponseParams * _Nullable data,
-                              NSError * _Nullable error))completion MTR_NEWLY_AVAILABLE;
-- (void)pauseWithExpectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
-          expectedValueInterval:(NSNumber *)expectedValueIntervalMs
-                     completion:(void (^)(MTRRVCOperationalStateClusterOperationalCommandResponseParams * _Nullable data,
-                                    NSError * _Nullable error))completion MTR_NEWLY_AVAILABLE;
-- (void)stopWithParams:(MTRRVCOperationalStateClusterStopParams * _Nullable)params
-           expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
-    expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
-               completion:(void (^)(MTRRVCOperationalStateClusterOperationalCommandResponseParams * _Nullable data,
-                              NSError * _Nullable error))completion MTR_NEWLY_AVAILABLE;
-- (void)stopWithExpectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
-         expectedValueInterval:(NSNumber *)expectedValueIntervalMs
-                    completion:(void (^)(MTRRVCOperationalStateClusterOperationalCommandResponseParams * _Nullable data,
-                                   NSError * _Nullable error))completion MTR_NEWLY_AVAILABLE;
-- (void)startWithParams:(MTRRVCOperationalStateClusterStartParams * _Nullable)params
-           expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
-    expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
-               completion:(void (^)(MTRRVCOperationalStateClusterOperationalCommandResponseParams * _Nullable data,
-                              NSError * _Nullable error))completion MTR_NEWLY_AVAILABLE;
-- (void)startWithExpectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
-          expectedValueInterval:(NSNumber *)expectedValueIntervalMs
-                     completion:(void (^)(MTRRVCOperationalStateClusterOperationalCommandResponseParams * _Nullable data,
-                                    NSError * _Nullable error))completion MTR_NEWLY_AVAILABLE;
-- (void)resumeWithParams:(MTRRVCOperationalStateClusterResumeParams * _Nullable)params
-           expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedDataValueDictionaries
-    expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs
-               completion:(void (^)(MTRRVCOperationalStateClusterOperationalCommandResponseParams * _Nullable data,
-                              NSError * _Nullable error))completion MTR_NEWLY_AVAILABLE;
-- (void)resumeWithExpectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
-           expectedValueInterval:(NSNumber *)expectedValueIntervalMs
-                      completion:(void (^)(MTRRVCOperationalStateClusterOperationalCommandResponseParams * _Nullable data,
-                                     NSError * _Nullable error))completion MTR_NEWLY_AVAILABLE;
-
-- (NSDictionary<NSString *, id> *)readAttributePhaseListWithParams:(MTRReadParams * _Nullable)params MTR_NEWLY_AVAILABLE;
-
-- (NSDictionary<NSString *, id> *)readAttributeCurrentPhaseWithParams:(MTRReadParams * _Nullable)params MTR_NEWLY_AVAILABLE;
-
-- (NSDictionary<NSString *, id> *)readAttributeCountdownTimeWithParams:(MTRReadParams * _Nullable)params MTR_NEWLY_AVAILABLE;
-
-- (NSDictionary<NSString *, id> *)readAttributeOperationalStateListWithParams:(MTRReadParams * _Nullable)params MTR_NEWLY_AVAILABLE;
-
-- (NSDictionary<NSString *, id> *)readAttributeOperationalStateWithParams:(MTRReadParams * _Nullable)params MTR_NEWLY_AVAILABLE;
-
-- (NSDictionary<NSString *, id> *)readAttributeOperationalErrorWithParams:(MTRReadParams * _Nullable)params MTR_NEWLY_AVAILABLE;
-
-- (NSDictionary<NSString *, id> *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params MTR_NEWLY_AVAILABLE;
-
-- (NSDictionary<NSString *, id> *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params MTR_NEWLY_AVAILABLE;
-
-- (NSDictionary<NSString *, id> *)readAttributeEventListWithParams:(MTRReadParams * _Nullable)params MTR_NEWLY_AVAILABLE;
-
-- (NSDictionary<NSString *, id> *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params MTR_NEWLY_AVAILABLE;
-
-- (NSDictionary<NSString *, id> *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params MTR_NEWLY_AVAILABLE;
-
-- (NSDictionary<NSString *, id> *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params MTR_NEWLY_AVAILABLE;
-
-- (instancetype)init NS_UNAVAILABLE;
-+ (instancetype)new NS_UNAVAILABLE;
-
-@end
-
-/**
  * Cluster HEPA Filter Monitoring
  *    Attributes and commands for monitoring HEPA filters in a device
  */
diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRClusters.mm b/src/darwin/Framework/CHIP/zap-generated/MTRClusters.mm
index 99f1566..2f1684e 100644
--- a/src/darwin/Framework/CHIP/zap-generated/MTRClusters.mm
+++ b/src/darwin/Framework/CHIP/zap-generated/MTRClusters.mm
@@ -13913,423 +13913,6 @@
 
 @end
 
-@implementation MTRClusterRVCOperationalState
-
-- (instancetype)initWithDevice:(MTRDevice *)device endpointID:(NSNumber *)endpointID queue:(dispatch_queue_t)queue
-{
-    if (self = [super initWithQueue:queue]) {
-        if (device == nil) {
-            return nil;
-        }
-
-        _endpoint = [endpointID unsignedShortValue];
-        _device = device;
-    }
-    return self;
-}
-
-- (void)pauseWithExpectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
-          expectedValueInterval:(NSNumber *)expectedValueIntervalMs
-                     completion:(void (^)(MTRRVCOperationalStateClusterOperationalCommandResponseParams * _Nullable data,
-                                    NSError * _Nullable error))completion
-{
-    [self pauseWithParams:nil expectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs completion:completion];
-}
-- (void)pauseWithParams:(MTRRVCOperationalStateClusterPauseParams * _Nullable)params
-           expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
-    expectedValueInterval:(NSNumber *)expectedValueIntervalMs
-               completion:(void (^)(MTRRVCOperationalStateClusterOperationalCommandResponseParams * _Nullable data,
-                              NSError * _Nullable error))completion
-{
-    NSString * logPrefix = [NSString stringWithFormat:@"MTRDevice command %u %u %u %u", self.device.deviceController.fabricIndex,
-                                     _endpoint, (unsigned int) MTRClusterIDTypeRVCOperationalStateID,
-                                     (unsigned int) MTRCommandIDTypeClusterRVCOperationalStateCommandPauseID];
-    // Make a copy of params before we go async.
-    params = [params copy];
-    NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
-    if (timedInvokeTimeoutMsParam) {
-        timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
-    }
-    MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.device.queue];
-    MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
-        MTRClustersLogDequeue(logPrefix, self.device.asyncCallbackWorkQueue);
-        MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
-                                                                controller:self.device.deviceController];
-        auto * bridge = new MTRRVCOperationalStateClusterOperationalCommandResponseCallbackBridge(
-            self.device.queue,
-            ^(id _Nullable value, NSError * _Nullable error) {
-                MTRClustersLogCompletion(logPrefix, value, error);
-                dispatch_async(self.callbackQueue, ^{
-                    completion(value, error);
-                });
-                [workItem endWork];
-            },
-            ^(ExchangeManager & exchangeManager, const SessionHandle & session,
-                RVCOperationalStateClusterOperationalCommandResponseCallbackType successCb, MTRErrorCallback failureCb,
-                MTRCallbackBridgeBase * bridge) {
-                auto * typedBridge = static_cast<MTRRVCOperationalStateClusterOperationalCommandResponseCallbackBridge *>(bridge);
-                Optional<uint16_t> timedInvokeTimeoutMs;
-                Optional<Timeout> invokeTimeout;
-                ListFreer listFreer;
-                RvcOperationalState::Commands::Pause::Type request;
-                if (timedInvokeTimeoutMsParam != nil) {
-                    timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
-                }
-                if (params != nil) {
-                    if (params.serverSideProcessingTimeout != nil) {
-                        // Clamp to a number of seconds that will not overflow 32-bit
-                        // int when converted to ms.
-                        auto * serverSideProcessingTimeout
-                            = MTRClampedNumber(params.serverSideProcessingTimeout, @(0), @(UINT16_MAX));
-                        invokeTimeout.SetValue(Seconds16(serverSideProcessingTimeout.unsignedShortValue));
-                    }
-                }
-
-                return MTRStartInvokeInteraction(typedBridge, request, exchangeManager, session, successCb, failureCb,
-                    self->_endpoint, timedInvokeTimeoutMs, invokeTimeout);
-            });
-        std::move(*bridge).DispatchAction(baseDevice);
-    };
-    workItem.readyHandler = readyHandler;
-    MTRClustersLogEnqueue(logPrefix, self.device.asyncCallbackWorkQueue);
-    [self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
-
-    if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
-        expectedValues = nil;
-    } else {
-        expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
-    }
-    if (expectedValues) {
-        [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
-    }
-}
-
-- (void)stopWithExpectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
-         expectedValueInterval:(NSNumber *)expectedValueIntervalMs
-                    completion:(void (^)(MTRRVCOperationalStateClusterOperationalCommandResponseParams * _Nullable data,
-                                   NSError * _Nullable error))completion
-{
-    [self stopWithParams:nil expectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs completion:completion];
-}
-- (void)stopWithParams:(MTRRVCOperationalStateClusterStopParams * _Nullable)params
-           expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
-    expectedValueInterval:(NSNumber *)expectedValueIntervalMs
-               completion:(void (^)(MTRRVCOperationalStateClusterOperationalCommandResponseParams * _Nullable data,
-                              NSError * _Nullable error))completion
-{
-    NSString * logPrefix = [NSString stringWithFormat:@"MTRDevice command %u %u %u %u", self.device.deviceController.fabricIndex,
-                                     _endpoint, (unsigned int) MTRClusterIDTypeRVCOperationalStateID,
-                                     (unsigned int) MTRCommandIDTypeClusterRVCOperationalStateCommandStopID];
-    // Make a copy of params before we go async.
-    params = [params copy];
-    NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
-    if (timedInvokeTimeoutMsParam) {
-        timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
-    }
-    MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.device.queue];
-    MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
-        MTRClustersLogDequeue(logPrefix, self.device.asyncCallbackWorkQueue);
-        MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
-                                                                controller:self.device.deviceController];
-        auto * bridge = new MTRRVCOperationalStateClusterOperationalCommandResponseCallbackBridge(
-            self.device.queue,
-            ^(id _Nullable value, NSError * _Nullable error) {
-                MTRClustersLogCompletion(logPrefix, value, error);
-                dispatch_async(self.callbackQueue, ^{
-                    completion(value, error);
-                });
-                [workItem endWork];
-            },
-            ^(ExchangeManager & exchangeManager, const SessionHandle & session,
-                RVCOperationalStateClusterOperationalCommandResponseCallbackType successCb, MTRErrorCallback failureCb,
-                MTRCallbackBridgeBase * bridge) {
-                auto * typedBridge = static_cast<MTRRVCOperationalStateClusterOperationalCommandResponseCallbackBridge *>(bridge);
-                Optional<uint16_t> timedInvokeTimeoutMs;
-                Optional<Timeout> invokeTimeout;
-                ListFreer listFreer;
-                RvcOperationalState::Commands::Stop::Type request;
-                if (timedInvokeTimeoutMsParam != nil) {
-                    timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
-                }
-                if (params != nil) {
-                    if (params.serverSideProcessingTimeout != nil) {
-                        // Clamp to a number of seconds that will not overflow 32-bit
-                        // int when converted to ms.
-                        auto * serverSideProcessingTimeout
-                            = MTRClampedNumber(params.serverSideProcessingTimeout, @(0), @(UINT16_MAX));
-                        invokeTimeout.SetValue(Seconds16(serverSideProcessingTimeout.unsignedShortValue));
-                    }
-                }
-
-                return MTRStartInvokeInteraction(typedBridge, request, exchangeManager, session, successCb, failureCb,
-                    self->_endpoint, timedInvokeTimeoutMs, invokeTimeout);
-            });
-        std::move(*bridge).DispatchAction(baseDevice);
-    };
-    workItem.readyHandler = readyHandler;
-    MTRClustersLogEnqueue(logPrefix, self.device.asyncCallbackWorkQueue);
-    [self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
-
-    if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
-        expectedValues = nil;
-    } else {
-        expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
-    }
-    if (expectedValues) {
-        [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
-    }
-}
-
-- (void)startWithExpectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
-          expectedValueInterval:(NSNumber *)expectedValueIntervalMs
-                     completion:(void (^)(MTRRVCOperationalStateClusterOperationalCommandResponseParams * _Nullable data,
-                                    NSError * _Nullable error))completion
-{
-    [self startWithParams:nil expectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs completion:completion];
-}
-- (void)startWithParams:(MTRRVCOperationalStateClusterStartParams * _Nullable)params
-           expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
-    expectedValueInterval:(NSNumber *)expectedValueIntervalMs
-               completion:(void (^)(MTRRVCOperationalStateClusterOperationalCommandResponseParams * _Nullable data,
-                              NSError * _Nullable error))completion
-{
-    NSString * logPrefix = [NSString stringWithFormat:@"MTRDevice command %u %u %u %u", self.device.deviceController.fabricIndex,
-                                     _endpoint, (unsigned int) MTRClusterIDTypeRVCOperationalStateID,
-                                     (unsigned int) MTRCommandIDTypeClusterRVCOperationalStateCommandStartID];
-    // Make a copy of params before we go async.
-    params = [params copy];
-    NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
-    if (timedInvokeTimeoutMsParam) {
-        timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
-    }
-    MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.device.queue];
-    MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
-        MTRClustersLogDequeue(logPrefix, self.device.asyncCallbackWorkQueue);
-        MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
-                                                                controller:self.device.deviceController];
-        auto * bridge = new MTRRVCOperationalStateClusterOperationalCommandResponseCallbackBridge(
-            self.device.queue,
-            ^(id _Nullable value, NSError * _Nullable error) {
-                MTRClustersLogCompletion(logPrefix, value, error);
-                dispatch_async(self.callbackQueue, ^{
-                    completion(value, error);
-                });
-                [workItem endWork];
-            },
-            ^(ExchangeManager & exchangeManager, const SessionHandle & session,
-                RVCOperationalStateClusterOperationalCommandResponseCallbackType successCb, MTRErrorCallback failureCb,
-                MTRCallbackBridgeBase * bridge) {
-                auto * typedBridge = static_cast<MTRRVCOperationalStateClusterOperationalCommandResponseCallbackBridge *>(bridge);
-                Optional<uint16_t> timedInvokeTimeoutMs;
-                Optional<Timeout> invokeTimeout;
-                ListFreer listFreer;
-                RvcOperationalState::Commands::Start::Type request;
-                if (timedInvokeTimeoutMsParam != nil) {
-                    timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
-                }
-                if (params != nil) {
-                    if (params.serverSideProcessingTimeout != nil) {
-                        // Clamp to a number of seconds that will not overflow 32-bit
-                        // int when converted to ms.
-                        auto * serverSideProcessingTimeout
-                            = MTRClampedNumber(params.serverSideProcessingTimeout, @(0), @(UINT16_MAX));
-                        invokeTimeout.SetValue(Seconds16(serverSideProcessingTimeout.unsignedShortValue));
-                    }
-                }
-
-                return MTRStartInvokeInteraction(typedBridge, request, exchangeManager, session, successCb, failureCb,
-                    self->_endpoint, timedInvokeTimeoutMs, invokeTimeout);
-            });
-        std::move(*bridge).DispatchAction(baseDevice);
-    };
-    workItem.readyHandler = readyHandler;
-    MTRClustersLogEnqueue(logPrefix, self.device.asyncCallbackWorkQueue);
-    [self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
-
-    if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
-        expectedValues = nil;
-    } else {
-        expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
-    }
-    if (expectedValues) {
-        [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
-    }
-}
-
-- (void)resumeWithExpectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
-           expectedValueInterval:(NSNumber *)expectedValueIntervalMs
-                      completion:(void (^)(MTRRVCOperationalStateClusterOperationalCommandResponseParams * _Nullable data,
-                                     NSError * _Nullable error))completion
-{
-    [self resumeWithParams:nil expectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs completion:completion];
-}
-- (void)resumeWithParams:(MTRRVCOperationalStateClusterResumeParams * _Nullable)params
-           expectedValues:(NSArray<NSDictionary<NSString *, id> *> *)expectedValues
-    expectedValueInterval:(NSNumber *)expectedValueIntervalMs
-               completion:(void (^)(MTRRVCOperationalStateClusterOperationalCommandResponseParams * _Nullable data,
-                              NSError * _Nullable error))completion
-{
-    NSString * logPrefix = [NSString stringWithFormat:@"MTRDevice command %u %u %u %u", self.device.deviceController.fabricIndex,
-                                     _endpoint, (unsigned int) MTRClusterIDTypeRVCOperationalStateID,
-                                     (unsigned int) MTRCommandIDTypeClusterRVCOperationalStateCommandResumeID];
-    // Make a copy of params before we go async.
-    params = [params copy];
-    NSNumber * timedInvokeTimeoutMsParam = params.timedInvokeTimeoutMs;
-    if (timedInvokeTimeoutMsParam) {
-        timedInvokeTimeoutMsParam = MTRClampedNumber(timedInvokeTimeoutMsParam, @(1), @(UINT16_MAX));
-    }
-    MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.device.queue];
-    MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) {
-        MTRClustersLogDequeue(logPrefix, self.device.asyncCallbackWorkQueue);
-        MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID
-                                                                controller:self.device.deviceController];
-        auto * bridge = new MTRRVCOperationalStateClusterOperationalCommandResponseCallbackBridge(
-            self.device.queue,
-            ^(id _Nullable value, NSError * _Nullable error) {
-                MTRClustersLogCompletion(logPrefix, value, error);
-                dispatch_async(self.callbackQueue, ^{
-                    completion(value, error);
-                });
-                [workItem endWork];
-            },
-            ^(ExchangeManager & exchangeManager, const SessionHandle & session,
-                RVCOperationalStateClusterOperationalCommandResponseCallbackType successCb, MTRErrorCallback failureCb,
-                MTRCallbackBridgeBase * bridge) {
-                auto * typedBridge = static_cast<MTRRVCOperationalStateClusterOperationalCommandResponseCallbackBridge *>(bridge);
-                Optional<uint16_t> timedInvokeTimeoutMs;
-                Optional<Timeout> invokeTimeout;
-                ListFreer listFreer;
-                RvcOperationalState::Commands::Resume::Type request;
-                if (timedInvokeTimeoutMsParam != nil) {
-                    timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue);
-                }
-                if (params != nil) {
-                    if (params.serverSideProcessingTimeout != nil) {
-                        // Clamp to a number of seconds that will not overflow 32-bit
-                        // int when converted to ms.
-                        auto * serverSideProcessingTimeout
-                            = MTRClampedNumber(params.serverSideProcessingTimeout, @(0), @(UINT16_MAX));
-                        invokeTimeout.SetValue(Seconds16(serverSideProcessingTimeout.unsignedShortValue));
-                    }
-                }
-
-                return MTRStartInvokeInteraction(typedBridge, request, exchangeManager, session, successCb, failureCb,
-                    self->_endpoint, timedInvokeTimeoutMs, invokeTimeout);
-            });
-        std::move(*bridge).DispatchAction(baseDevice);
-    };
-    workItem.readyHandler = readyHandler;
-    MTRClustersLogEnqueue(logPrefix, self.device.asyncCallbackWorkQueue);
-    [self.device.asyncCallbackWorkQueue enqueueWorkItem:workItem];
-
-    if (!expectedValueIntervalMs || ([expectedValueIntervalMs compare:@(0)] == NSOrderedAscending)) {
-        expectedValues = nil;
-    } else {
-        expectedValueIntervalMs = MTRClampedNumber(expectedValueIntervalMs, @(1), @(UINT32_MAX));
-    }
-    if (expectedValues) {
-        [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs];
-    }
-}
-
-- (NSDictionary<NSString *, id> *)readAttributePhaseListWithParams:(MTRReadParams * _Nullable)params
-{
-    return [self.device readAttributeWithEndpointID:@(_endpoint)
-                                          clusterID:@(MTRClusterIDTypeRVCOperationalStateID)
-                                        attributeID:@(MTRAttributeIDTypeClusterRVCOperationalStateAttributePhaseListID)
-                                             params:params];
-}
-
-- (NSDictionary<NSString *, id> *)readAttributeCurrentPhaseWithParams:(MTRReadParams * _Nullable)params
-{
-    return [self.device readAttributeWithEndpointID:@(_endpoint)
-                                          clusterID:@(MTRClusterIDTypeRVCOperationalStateID)
-                                        attributeID:@(MTRAttributeIDTypeClusterRVCOperationalStateAttributeCurrentPhaseID)
-                                             params:params];
-}
-
-- (NSDictionary<NSString *, id> *)readAttributeCountdownTimeWithParams:(MTRReadParams * _Nullable)params
-{
-    return [self.device readAttributeWithEndpointID:@(_endpoint)
-                                          clusterID:@(MTRClusterIDTypeRVCOperationalStateID)
-                                        attributeID:@(MTRAttributeIDTypeClusterRVCOperationalStateAttributeCountdownTimeID)
-                                             params:params];
-}
-
-- (NSDictionary<NSString *, id> *)readAttributeOperationalStateListWithParams:(MTRReadParams * _Nullable)params
-{
-    return [self.device readAttributeWithEndpointID:@(_endpoint)
-                                          clusterID:@(MTRClusterIDTypeRVCOperationalStateID)
-                                        attributeID:@(MTRAttributeIDTypeClusterRVCOperationalStateAttributeOperationalStateListID)
-                                             params:params];
-}
-
-- (NSDictionary<NSString *, id> *)readAttributeOperationalStateWithParams:(MTRReadParams * _Nullable)params
-{
-    return [self.device readAttributeWithEndpointID:@(_endpoint)
-                                          clusterID:@(MTRClusterIDTypeRVCOperationalStateID)
-                                        attributeID:@(MTRAttributeIDTypeClusterRVCOperationalStateAttributeOperationalStateID)
-                                             params:params];
-}
-
-- (NSDictionary<NSString *, id> *)readAttributeOperationalErrorWithParams:(MTRReadParams * _Nullable)params
-{
-    return [self.device readAttributeWithEndpointID:@(_endpoint)
-                                          clusterID:@(MTRClusterIDTypeRVCOperationalStateID)
-                                        attributeID:@(MTRAttributeIDTypeClusterRVCOperationalStateAttributeOperationalErrorID)
-                                             params:params];
-}
-
-- (NSDictionary<NSString *, id> *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params
-{
-    return [self.device readAttributeWithEndpointID:@(_endpoint)
-                                          clusterID:@(MTRClusterIDTypeRVCOperationalStateID)
-                                        attributeID:@(MTRAttributeIDTypeClusterRVCOperationalStateAttributeGeneratedCommandListID)
-                                             params:params];
-}
-
-- (NSDictionary<NSString *, id> *)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params
-{
-    return [self.device readAttributeWithEndpointID:@(_endpoint)
-                                          clusterID:@(MTRClusterIDTypeRVCOperationalStateID)
-                                        attributeID:@(MTRAttributeIDTypeClusterRVCOperationalStateAttributeAcceptedCommandListID)
-                                             params:params];
-}
-
-- (NSDictionary<NSString *, id> *)readAttributeEventListWithParams:(MTRReadParams * _Nullable)params
-{
-    return [self.device readAttributeWithEndpointID:@(_endpoint)
-                                          clusterID:@(MTRClusterIDTypeRVCOperationalStateID)
-                                        attributeID:@(MTRAttributeIDTypeClusterRVCOperationalStateAttributeEventListID)
-                                             params:params];
-}
-
-- (NSDictionary<NSString *, id> *)readAttributeAttributeListWithParams:(MTRReadParams * _Nullable)params
-{
-    return [self.device readAttributeWithEndpointID:@(_endpoint)
-                                          clusterID:@(MTRClusterIDTypeRVCOperationalStateID)
-                                        attributeID:@(MTRAttributeIDTypeClusterRVCOperationalStateAttributeAttributeListID)
-                                             params:params];
-}
-
-- (NSDictionary<NSString *, id> *)readAttributeFeatureMapWithParams:(MTRReadParams * _Nullable)params
-{
-    return [self.device readAttributeWithEndpointID:@(_endpoint)
-                                          clusterID:@(MTRClusterIDTypeRVCOperationalStateID)
-                                        attributeID:@(MTRAttributeIDTypeClusterRVCOperationalStateAttributeFeatureMapID)
-                                             params:params];
-}
-
-- (NSDictionary<NSString *, id> *)readAttributeClusterRevisionWithParams:(MTRReadParams * _Nullable)params
-{
-    return [self.device readAttributeWithEndpointID:@(_endpoint)
-                                          clusterID:@(MTRClusterIDTypeRVCOperationalStateID)
-                                        attributeID:@(MTRAttributeIDTypeClusterRVCOperationalStateAttributeClusterRevisionID)
-                                             params:params];
-}
-
-@end
-
 @implementation MTRClusterHEPAFilterMonitoring
 
 - (instancetype)initWithDevice:(MTRDevice *)device endpointID:(NSNumber *)endpointID queue:(dispatch_queue_t)queue
diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRClusters_Internal.h b/src/darwin/Framework/CHIP/zap-generated/MTRClusters_Internal.h
index 849782b..8c73815 100644
--- a/src/darwin/Framework/CHIP/zap-generated/MTRClusters_Internal.h
+++ b/src/darwin/Framework/CHIP/zap-generated/MTRClusters_Internal.h
@@ -226,11 +226,6 @@
 @property (nonatomic, readonly) MTRDevice * device;
 @end
 
-@interface MTRClusterRVCOperationalState ()
-@property (nonatomic, readonly) uint16_t endpoint;
-@property (nonatomic, readonly) MTRDevice * device;
-@end
-
 @interface MTRClusterHEPAFilterMonitoring ()
 @property (nonatomic, readonly) uint16_t endpoint;
 @property (nonatomic, readonly) MTRDevice * device;
diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.h b/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.h
index 8838c0c..c8e9c13 100644
--- a/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.h
+++ b/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.h
@@ -4267,137 +4267,6 @@
 @end
 
 MTR_NEWLY_AVAILABLE
-@interface MTRRVCOperationalStateClusterPauseParams : NSObject <NSCopying>
-/**
- * Controls whether the command is a timed command (using Timed Invoke).
- *
- * If nil (the default value), a regular invoke is done for commands that do
- * not require a timed invoke and a timed invoke with some default timed request
- * timeout is done for commands that require a timed invoke.
- *
- * If not nil, a timed invoke is done, with the provided value used as the timed
- * request timeout.  The value should be chosen small enough to provide the
- * desired security properties but large enough that it will allow a round-trip
- * from the sever to the client (for the status response and actual invoke
- * request) within the timeout window.
- *
- */
-@property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs;
-
-/**
- * Controls how much time, in seconds, we will allow for the server to process the command.
- *
- * The command will then time out if that much time, plus an allowance for retransmits due to network failures, passes.
- *
- * If nil, the framework will try to select an appropriate timeout value itself.
- */
-@property (nonatomic, copy, nullable) NSNumber * serverSideProcessingTimeout;
-@end
-
-MTR_NEWLY_AVAILABLE
-@interface MTRRVCOperationalStateClusterStopParams : NSObject <NSCopying>
-/**
- * Controls whether the command is a timed command (using Timed Invoke).
- *
- * If nil (the default value), a regular invoke is done for commands that do
- * not require a timed invoke and a timed invoke with some default timed request
- * timeout is done for commands that require a timed invoke.
- *
- * If not nil, a timed invoke is done, with the provided value used as the timed
- * request timeout.  The value should be chosen small enough to provide the
- * desired security properties but large enough that it will allow a round-trip
- * from the sever to the client (for the status response and actual invoke
- * request) within the timeout window.
- *
- */
-@property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs;
-
-/**
- * Controls how much time, in seconds, we will allow for the server to process the command.
- *
- * The command will then time out if that much time, plus an allowance for retransmits due to network failures, passes.
- *
- * If nil, the framework will try to select an appropriate timeout value itself.
- */
-@property (nonatomic, copy, nullable) NSNumber * serverSideProcessingTimeout;
-@end
-
-MTR_NEWLY_AVAILABLE
-@interface MTRRVCOperationalStateClusterStartParams : NSObject <NSCopying>
-/**
- * Controls whether the command is a timed command (using Timed Invoke).
- *
- * If nil (the default value), a regular invoke is done for commands that do
- * not require a timed invoke and a timed invoke with some default timed request
- * timeout is done for commands that require a timed invoke.
- *
- * If not nil, a timed invoke is done, with the provided value used as the timed
- * request timeout.  The value should be chosen small enough to provide the
- * desired security properties but large enough that it will allow a round-trip
- * from the sever to the client (for the status response and actual invoke
- * request) within the timeout window.
- *
- */
-@property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs;
-
-/**
- * Controls how much time, in seconds, we will allow for the server to process the command.
- *
- * The command will then time out if that much time, plus an allowance for retransmits due to network failures, passes.
- *
- * If nil, the framework will try to select an appropriate timeout value itself.
- */
-@property (nonatomic, copy, nullable) NSNumber * serverSideProcessingTimeout;
-@end
-
-MTR_NEWLY_AVAILABLE
-@interface MTRRVCOperationalStateClusterResumeParams : NSObject <NSCopying>
-/**
- * Controls whether the command is a timed command (using Timed Invoke).
- *
- * If nil (the default value), a regular invoke is done for commands that do
- * not require a timed invoke and a timed invoke with some default timed request
- * timeout is done for commands that require a timed invoke.
- *
- * If not nil, a timed invoke is done, with the provided value used as the timed
- * request timeout.  The value should be chosen small enough to provide the
- * desired security properties but large enough that it will allow a round-trip
- * from the sever to the client (for the status response and actual invoke
- * request) within the timeout window.
- *
- */
-@property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs;
-
-/**
- * Controls how much time, in seconds, we will allow for the server to process the command.
- *
- * The command will then time out if that much time, plus an allowance for retransmits due to network failures, passes.
- *
- * If nil, the framework will try to select an appropriate timeout value itself.
- */
-@property (nonatomic, copy, nullable) NSNumber * serverSideProcessingTimeout;
-@end
-
-MTR_NEWLY_AVAILABLE
-@interface MTRRVCOperationalStateClusterOperationalCommandResponseParams : NSObject <NSCopying>
-
-@property (nonatomic, copy) MTRRVCOperationalStateClusterErrorStateStruct * _Nonnull commandResponseState MTR_NEWLY_AVAILABLE;
-
-/**
- * Initialize an MTRRVCOperationalStateClusterOperationalCommandResponseParams with a response-value dictionary
- * of the sort that MTRDeviceResponseHandler would receive.
- *
- * Will return nil and hand out an error if the response-value dictionary is not
- * a command data response or is not the right command response.
- *
- * Will return nil and hand out an error if the data response does not match the known
- * schema for this command.
- */
-- (nullable instancetype)initWithResponseValue:(NSDictionary<NSString *, id> *)responseValue
-                                         error:(NSError * __autoreleasing *)error MTR_NEWLY_AVAILABLE;
-@end
-
-MTR_NEWLY_AVAILABLE
 @interface MTRHEPAFilterMonitoringClusterResetConditionParams : NSObject <NSCopying>
 /**
  * Controls whether the command is a timed command (using Timed Invoke).
diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.mm b/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.mm
index 7e03309..a99cceb 100644
--- a/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.mm
+++ b/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.mm
@@ -6714,213 +6714,6 @@
     return CHIP_NO_ERROR;
 }
 @end
-@implementation MTRRVCOperationalStateClusterPauseParams
-- (instancetype)init
-{
-    if (self = [super init]) {
-        _timedInvokeTimeoutMs = nil;
-        _serverSideProcessingTimeout = nil;
-    }
-    return self;
-}
-
-- (id)copyWithZone:(NSZone * _Nullable)zone;
-{
-    auto other = [[MTRRVCOperationalStateClusterPauseParams alloc] init];
-
-    other.timedInvokeTimeoutMs = self.timedInvokeTimeoutMs;
-    other.serverSideProcessingTimeout = self.serverSideProcessingTimeout;
-
-    return other;
-}
-
-- (NSString *)description
-{
-    NSString * descriptionString = [NSString stringWithFormat:@"<%@: >", NSStringFromClass([self class])];
-    return descriptionString;
-}
-
-@end
-@implementation MTRRVCOperationalStateClusterStopParams
-- (instancetype)init
-{
-    if (self = [super init]) {
-        _timedInvokeTimeoutMs = nil;
-        _serverSideProcessingTimeout = nil;
-    }
-    return self;
-}
-
-- (id)copyWithZone:(NSZone * _Nullable)zone;
-{
-    auto other = [[MTRRVCOperationalStateClusterStopParams alloc] init];
-
-    other.timedInvokeTimeoutMs = self.timedInvokeTimeoutMs;
-    other.serverSideProcessingTimeout = self.serverSideProcessingTimeout;
-
-    return other;
-}
-
-- (NSString *)description
-{
-    NSString * descriptionString = [NSString stringWithFormat:@"<%@: >", NSStringFromClass([self class])];
-    return descriptionString;
-}
-
-@end
-@implementation MTRRVCOperationalStateClusterStartParams
-- (instancetype)init
-{
-    if (self = [super init]) {
-        _timedInvokeTimeoutMs = nil;
-        _serverSideProcessingTimeout = nil;
-    }
-    return self;
-}
-
-- (id)copyWithZone:(NSZone * _Nullable)zone;
-{
-    auto other = [[MTRRVCOperationalStateClusterStartParams alloc] init];
-
-    other.timedInvokeTimeoutMs = self.timedInvokeTimeoutMs;
-    other.serverSideProcessingTimeout = self.serverSideProcessingTimeout;
-
-    return other;
-}
-
-- (NSString *)description
-{
-    NSString * descriptionString = [NSString stringWithFormat:@"<%@: >", NSStringFromClass([self class])];
-    return descriptionString;
-}
-
-@end
-@implementation MTRRVCOperationalStateClusterResumeParams
-- (instancetype)init
-{
-    if (self = [super init]) {
-        _timedInvokeTimeoutMs = nil;
-        _serverSideProcessingTimeout = nil;
-    }
-    return self;
-}
-
-- (id)copyWithZone:(NSZone * _Nullable)zone;
-{
-    auto other = [[MTRRVCOperationalStateClusterResumeParams alloc] init];
-
-    other.timedInvokeTimeoutMs = self.timedInvokeTimeoutMs;
-    other.serverSideProcessingTimeout = self.serverSideProcessingTimeout;
-
-    return other;
-}
-
-- (NSString *)description
-{
-    NSString * descriptionString = [NSString stringWithFormat:@"<%@: >", NSStringFromClass([self class])];
-    return descriptionString;
-}
-
-@end
-@implementation MTRRVCOperationalStateClusterOperationalCommandResponseParams
-- (instancetype)init
-{
-    if (self = [super init]) {
-
-        _commandResponseState = [MTRRVCOperationalStateClusterErrorStateStruct new];
-    }
-    return self;
-}
-
-- (id)copyWithZone:(NSZone * _Nullable)zone;
-{
-    auto other = [[MTRRVCOperationalStateClusterOperationalCommandResponseParams alloc] init];
-
-    other.commandResponseState = self.commandResponseState;
-
-    return other;
-}
-
-- (NSString *)description
-{
-    NSString * descriptionString =
-        [NSString stringWithFormat:@"<%@: commandResponseState:%@; >", NSStringFromClass([self class]), _commandResponseState];
-    return descriptionString;
-}
-
-- (nullable instancetype)initWithResponseValue:(NSDictionary<NSString *, id> *)responseValue
-                                         error:(NSError * __autoreleasing *)error
-{
-    if (!(self = [super init])) {
-        return nil;
-    }
-
-    using DecodableType = chip::app::Clusters::RvcOperationalState::Commands::OperationalCommandResponse::DecodableType;
-    chip::System::PacketBufferHandle buffer = [MTRBaseDevice _responseDataForCommand:responseValue
-                                                                           clusterID:DecodableType::GetClusterId()
-                                                                           commandID:DecodableType::GetCommandId()
-                                                                               error:error];
-    if (buffer.IsNull()) {
-        return nil;
-    }
-
-    chip::TLV::TLVReader reader;
-    reader.Init(buffer->Start(), buffer->DataLength());
-
-    CHIP_ERROR err = reader.Next(chip::TLV::AnonymousTag());
-    if (err == CHIP_NO_ERROR) {
-        DecodableType decodedStruct;
-        err = chip::app::DataModel::Decode(reader, decodedStruct);
-        if (err == CHIP_NO_ERROR) {
-            err = [self _setFieldsFromDecodableStruct:decodedStruct];
-            if (err == CHIP_NO_ERROR) {
-                return self;
-            }
-        }
-    }
-
-    NSString * errorStr = [NSString stringWithFormat:@"Command payload decoding failed: %s", err.AsString()];
-    MTR_LOG_ERROR("%s", errorStr.UTF8String);
-    if (error != nil) {
-        NSDictionary * userInfo = @{ NSLocalizedFailureReasonErrorKey : NSLocalizedString(errorStr, nil) };
-        *error = [NSError errorWithDomain:MTRErrorDomain code:MTRErrorCodeSchemaMismatch userInfo:userInfo];
-    }
-    return nil;
-}
-
-@end
-
-@implementation MTRRVCOperationalStateClusterOperationalCommandResponseParams (InternalMethods)
-
-- (CHIP_ERROR)_setFieldsFromDecodableStruct:
-    (const chip::app::Clusters::RvcOperationalState::Commands::OperationalCommandResponse::DecodableType &)decodableStruct
-{
-    {
-        self.commandResponseState = [MTRRVCOperationalStateClusterErrorStateStruct new];
-        self.commandResponseState.errorStateID =
-            [NSNumber numberWithUnsignedChar:decodableStruct.commandResponseState.errorStateID];
-        if (decodableStruct.commandResponseState.errorStateLabel.HasValue()) {
-            self.commandResponseState.errorStateLabel = AsString(decodableStruct.commandResponseState.errorStateLabel.Value());
-            if (self.commandResponseState.errorStateLabel == nil) {
-                CHIP_ERROR err = CHIP_ERROR_INVALID_ARGUMENT;
-                return err;
-            }
-        } else {
-            self.commandResponseState.errorStateLabel = nil;
-        }
-        if (decodableStruct.commandResponseState.errorStateDetails.HasValue()) {
-            self.commandResponseState.errorStateDetails = AsString(decodableStruct.commandResponseState.errorStateDetails.Value());
-            if (self.commandResponseState.errorStateDetails == nil) {
-                CHIP_ERROR err = CHIP_ERROR_INVALID_ARGUMENT;
-                return err;
-            }
-        } else {
-            self.commandResponseState.errorStateDetails = nil;
-        }
-    }
-    return CHIP_NO_ERROR;
-}
-@end
 @implementation MTRHEPAFilterMonitoringClusterResetConditionParams
 - (instancetype)init
 {
diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloads_Internal.h b/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloads_Internal.h
index 51c8bc3..28f95b1 100644
--- a/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloads_Internal.h
+++ b/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloads_Internal.h
@@ -224,13 +224,6 @@
 
 @end
 
-@interface MTRRVCOperationalStateClusterOperationalCommandResponseParams (InternalMethods)
-
-- (CHIP_ERROR)_setFieldsFromDecodableStruct:
-    (const chip::app::Clusters::RvcOperationalState::Commands::OperationalCommandResponse::DecodableType &)decodableStruct;
-
-@end
-
 @interface MTRDoorLockClusterGetWeekDayScheduleResponseParams (InternalMethods)
 
 - (CHIP_ERROR)_setFieldsFromDecodableStruct:
diff --git a/src/darwin/Framework/CHIP/zap-generated/MTREventTLVValueDecoder.mm b/src/darwin/Framework/CHIP/zap-generated/MTREventTLVValueDecoder.mm
index 193a8a3..7705e88 100644
--- a/src/darwin/Framework/CHIP/zap-generated/MTREventTLVValueDecoder.mm
+++ b/src/darwin/Framework/CHIP/zap-generated/MTREventTLVValueDecoder.mm
@@ -1848,99 +1848,6 @@
     *aError = CHIP_ERROR_IM_MALFORMED_EVENT_PATH_IB;
     return nil;
 }
-static id _Nullable DecodeEventPayloadForRVCOperationalStateCluster(EventId aEventId, TLV::TLVReader & aReader, CHIP_ERROR * aError)
-{
-    using namespace Clusters::RvcOperationalState;
-    switch (aEventId) {
-    case Events::OperationalError::Id: {
-        Events::OperationalError::DecodableType cppValue;
-        *aError = DataModel::Decode(aReader, cppValue);
-        if (*aError != CHIP_NO_ERROR) {
-            return nil;
-        }
-
-        __auto_type * value = [MTRRVCOperationalStateClusterOperationalErrorEvent new];
-
-        do {
-            MTRRVCOperationalStateClusterErrorStateStruct * _Nonnull memberValue;
-            memberValue = [MTRRVCOperationalStateClusterErrorStateStruct new];
-            memberValue.errorStateID = [NSNumber numberWithUnsignedChar:cppValue.errorState.errorStateID];
-            if (cppValue.errorState.errorStateLabel.HasValue()) {
-                memberValue.errorStateLabel = AsString(cppValue.errorState.errorStateLabel.Value());
-                if (memberValue.errorStateLabel == nil) {
-                    CHIP_ERROR err = CHIP_ERROR_INVALID_ARGUMENT;
-                    *aError = err;
-                    return nil;
-                }
-            } else {
-                memberValue.errorStateLabel = nil;
-            }
-            if (cppValue.errorState.errorStateDetails.HasValue()) {
-                memberValue.errorStateDetails = AsString(cppValue.errorState.errorStateDetails.Value());
-                if (memberValue.errorStateDetails == nil) {
-                    CHIP_ERROR err = CHIP_ERROR_INVALID_ARGUMENT;
-                    *aError = err;
-                    return nil;
-                }
-            } else {
-                memberValue.errorStateDetails = nil;
-            }
-            value.errorState = memberValue;
-        } while (0);
-
-        return value;
-    }
-    case Events::OperationCompletion::Id: {
-        Events::OperationCompletion::DecodableType cppValue;
-        *aError = DataModel::Decode(aReader, cppValue);
-        if (*aError != CHIP_NO_ERROR) {
-            return nil;
-        }
-
-        __auto_type * value = [MTRRVCOperationalStateClusterOperationCompletionEvent new];
-
-        do {
-            NSNumber * _Nonnull memberValue;
-            memberValue = [NSNumber numberWithUnsignedChar:cppValue.completionErrorCode];
-            value.completionErrorCode = memberValue;
-        } while (0);
-        do {
-            NSNumber * _Nullable memberValue;
-            if (cppValue.totalOperationalTime.HasValue()) {
-                if (cppValue.totalOperationalTime.Value().IsNull()) {
-                    memberValue = nil;
-                } else {
-                    memberValue = [NSNumber numberWithUnsignedInt:cppValue.totalOperationalTime.Value().Value()];
-                }
-            } else {
-                memberValue = nil;
-            }
-            value.totalOperationalTime = memberValue;
-        } while (0);
-        do {
-            NSNumber * _Nullable memberValue;
-            if (cppValue.pausedTime.HasValue()) {
-                if (cppValue.pausedTime.Value().IsNull()) {
-                    memberValue = nil;
-                } else {
-                    memberValue = [NSNumber numberWithUnsignedInt:cppValue.pausedTime.Value().Value()];
-                }
-            } else {
-                memberValue = nil;
-            }
-            value.pausedTime = memberValue;
-        } while (0);
-
-        return value;
-    }
-    default: {
-        break;
-    }
-    }
-
-    *aError = CHIP_ERROR_IM_MALFORMED_EVENT_PATH_IB;
-    return nil;
-}
 static id _Nullable DecodeEventPayloadForHEPAFilterMonitoringCluster(
     EventId aEventId, TLV::TLVReader & aReader, CHIP_ERROR * aError)
 {
@@ -3143,9 +3050,6 @@
     case Clusters::OperationalState::Id: {
         return DecodeEventPayloadForOperationalStateCluster(aPath.mEventId, aReader, aError);
     }
-    case Clusters::RvcOperationalState::Id: {
-        return DecodeEventPayloadForRVCOperationalStateCluster(aPath.mEventId, aReader, aError);
-    }
     case Clusters::HepaFilterMonitoring::Id: {
         return DecodeEventPayloadForHEPAFilterMonitoringCluster(aPath.mEventId, aReader, aError);
     }
diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRStructsObjc.h b/src/darwin/Framework/CHIP/zap-generated/MTRStructsObjc.h
index 63264e7..076ed26 100644
--- a/src/darwin/Framework/CHIP/zap-generated/MTRStructsObjc.h
+++ b/src/darwin/Framework/CHIP/zap-generated/MTRStructsObjc.h
@@ -781,31 +781,6 @@
 @property (nonatomic, copy) NSNumber * _Nullable pausedTime MTR_NEWLY_AVAILABLE;
 @end
 
-MTR_NEWLY_AVAILABLE
-@interface MTRRVCOperationalStateClusterErrorStateStruct : NSObject <NSCopying>
-@property (nonatomic, copy) NSNumber * _Nonnull errorStateID MTR_NEWLY_AVAILABLE;
-@property (nonatomic, copy) NSString * _Nullable errorStateLabel MTR_NEWLY_AVAILABLE;
-@property (nonatomic, copy) NSString * _Nullable errorStateDetails MTR_NEWLY_AVAILABLE;
-@end
-
-MTR_NEWLY_AVAILABLE
-@interface MTRRVCOperationalStateClusterOperationalStateStruct : NSObject <NSCopying>
-@property (nonatomic, copy) NSNumber * _Nonnull operationalStateID MTR_NEWLY_AVAILABLE;
-@property (nonatomic, copy) NSString * _Nullable operationalStateLabel MTR_NEWLY_AVAILABLE;
-@end
-
-MTR_NEWLY_AVAILABLE
-@interface MTRRVCOperationalStateClusterOperationalErrorEvent : NSObject <NSCopying>
-@property (nonatomic, copy) MTRRVCOperationalStateClusterErrorStateStruct * _Nonnull errorState MTR_NEWLY_AVAILABLE;
-@end
-
-MTR_NEWLY_AVAILABLE
-@interface MTRRVCOperationalStateClusterOperationCompletionEvent : NSObject <NSCopying>
-@property (nonatomic, copy) NSNumber * _Nonnull completionErrorCode MTR_NEWLY_AVAILABLE;
-@property (nonatomic, copy) NSNumber * _Nullable totalOperationalTime MTR_NEWLY_AVAILABLE;
-@property (nonatomic, copy) NSNumber * _Nullable pausedTime MTR_NEWLY_AVAILABLE;
-@end
-
 API_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4))
 @interface MTRDoorLockClusterCredentialStruct : NSObject <NSCopying>
 @property (nonatomic, copy) NSNumber * _Nonnull credentialType API_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4));
diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRStructsObjc.mm b/src/darwin/Framework/CHIP/zap-generated/MTRStructsObjc.mm
index 17046b2..f81221f 100644
--- a/src/darwin/Framework/CHIP/zap-generated/MTRStructsObjc.mm
+++ b/src/darwin/Framework/CHIP/zap-generated/MTRStructsObjc.mm
@@ -3104,134 +3104,6 @@
 
 @end
 
-@implementation MTRRVCOperationalStateClusterErrorStateStruct
-- (instancetype)init
-{
-    if (self = [super init]) {
-
-        _errorStateID = @(0);
-
-        _errorStateLabel = nil;
-
-        _errorStateDetails = nil;
-    }
-    return self;
-}
-
-- (id)copyWithZone:(NSZone * _Nullable)zone
-{
-    auto other = [[MTRRVCOperationalStateClusterErrorStateStruct alloc] init];
-
-    other.errorStateID = self.errorStateID;
-    other.errorStateLabel = self.errorStateLabel;
-    other.errorStateDetails = self.errorStateDetails;
-
-    return other;
-}
-
-- (NSString *)description
-{
-    NSString * descriptionString = [NSString stringWithFormat:@"<%@: errorStateID:%@; errorStateLabel:%@; errorStateDetails:%@; >",
-                                             NSStringFromClass([self class]), _errorStateID, _errorStateLabel, _errorStateDetails];
-    return descriptionString;
-}
-
-@end
-
-@implementation MTRRVCOperationalStateClusterOperationalStateStruct
-- (instancetype)init
-{
-    if (self = [super init]) {
-
-        _operationalStateID = @(0);
-
-        _operationalStateLabel = nil;
-    }
-    return self;
-}
-
-- (id)copyWithZone:(NSZone * _Nullable)zone
-{
-    auto other = [[MTRRVCOperationalStateClusterOperationalStateStruct alloc] init];
-
-    other.operationalStateID = self.operationalStateID;
-    other.operationalStateLabel = self.operationalStateLabel;
-
-    return other;
-}
-
-- (NSString *)description
-{
-    NSString * descriptionString = [NSString stringWithFormat:@"<%@: operationalStateID:%@; operationalStateLabel:%@; >",
-                                             NSStringFromClass([self class]), _operationalStateID, _operationalStateLabel];
-    return descriptionString;
-}
-
-@end
-
-@implementation MTRRVCOperationalStateClusterOperationalErrorEvent
-- (instancetype)init
-{
-    if (self = [super init]) {
-
-        _errorState = [MTRRVCOperationalStateClusterErrorStateStruct new];
-    }
-    return self;
-}
-
-- (id)copyWithZone:(NSZone * _Nullable)zone
-{
-    auto other = [[MTRRVCOperationalStateClusterOperationalErrorEvent alloc] init];
-
-    other.errorState = self.errorState;
-
-    return other;
-}
-
-- (NSString *)description
-{
-    NSString * descriptionString =
-        [NSString stringWithFormat:@"<%@: errorState:%@; >", NSStringFromClass([self class]), _errorState];
-    return descriptionString;
-}
-
-@end
-
-@implementation MTRRVCOperationalStateClusterOperationCompletionEvent
-- (instancetype)init
-{
-    if (self = [super init]) {
-
-        _completionErrorCode = @(0);
-
-        _totalOperationalTime = nil;
-
-        _pausedTime = nil;
-    }
-    return self;
-}
-
-- (id)copyWithZone:(NSZone * _Nullable)zone
-{
-    auto other = [[MTRRVCOperationalStateClusterOperationCompletionEvent alloc] init];
-
-    other.completionErrorCode = self.completionErrorCode;
-    other.totalOperationalTime = self.totalOperationalTime;
-    other.pausedTime = self.pausedTime;
-
-    return other;
-}
-
-- (NSString *)description
-{
-    NSString * descriptionString =
-        [NSString stringWithFormat:@"<%@: completionErrorCode:%@; totalOperationalTime:%@; pausedTime:%@; >",
-                  NSStringFromClass([self class]), _completionErrorCode, _totalOperationalTime, _pausedTime];
-    return descriptionString;
-}
-
-@end
-
 @implementation MTRDoorLockClusterCredentialStruct
 - (instancetype)init
 {
diff --git a/zzz_generated/darwin-framework-tool/zap-generated/cluster/Commands.h b/zzz_generated/darwin-framework-tool/zap-generated/cluster/Commands.h
index a0ad2c6..16b8371 100644
--- a/zzz_generated/darwin-framework-tool/zap-generated/cluster/Commands.h
+++ b/zzz_generated/darwin-framework-tool/zap-generated/cluster/Commands.h
@@ -45033,1056 +45033,6 @@
 };
 
 /*----------------------------------------------------------------------------*\
-| Cluster RvcOperationalState                                         | 0x0061 |
-|------------------------------------------------------------------------------|
-| Commands:                                                           |        |
-| * Pause                                                             |   0x00 |
-| * Stop                                                              |   0x01 |
-| * Start                                                             |   0x02 |
-| * Resume                                                            |   0x03 |
-|------------------------------------------------------------------------------|
-| Attributes:                                                         |        |
-| * PhaseList                                                         | 0x0000 |
-| * CurrentPhase                                                      | 0x0001 |
-| * CountdownTime                                                     | 0x0002 |
-| * OperationalStateList                                              | 0x0003 |
-| * OperationalState                                                  | 0x0004 |
-| * OperationalError                                                  | 0x0005 |
-| * GeneratedCommandList                                              | 0xFFF8 |
-| * AcceptedCommandList                                               | 0xFFF9 |
-| * EventList                                                         | 0xFFFA |
-| * AttributeList                                                     | 0xFFFB |
-| * FeatureMap                                                        | 0xFFFC |
-| * ClusterRevision                                                   | 0xFFFD |
-|------------------------------------------------------------------------------|
-| Events:                                                             |        |
-| * OperationalError                                                  | 0x0000 |
-| * OperationCompletion                                               | 0x0001 |
-\*----------------------------------------------------------------------------*/
-
-/*
- * Command Pause
- */
-class RvcOperationalStatePause : public ClusterCommand {
-public:
-    RvcOperationalStatePause()
-        : ClusterCommand("pause")
-    {
-        ClusterCommand::AddArguments();
-    }
-
-    CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override
-    {
-        ChipLogProgress(chipTool, "Sending cluster (0x00000061) command (0x00000000) on endpoint %u", endpointId);
-
-        dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL);
-        __auto_type * cluster = [[MTRBaseClusterRVCOperationalState alloc] initWithDevice:device
-                                                                               endpointID:@(endpointId)
-                                                                                    queue:callbackQueue];
-        __auto_type * params = [[MTRRVCOperationalStateClusterPauseParams alloc] init];
-        params.timedInvokeTimeoutMs
-            = mTimedInteractionTimeoutMs.HasValue() ? [NSNumber numberWithUnsignedShort:mTimedInteractionTimeoutMs.Value()] : nil;
-        uint16_t repeatCount = mRepeatCount.ValueOr(1);
-        uint16_t __block responsesNeeded = repeatCount;
-        while (repeatCount--) {
-            [cluster pauseWithParams:params
-                          completion:^(MTRRVCOperationalStateClusterOperationalCommandResponseParams * _Nullable values,
-                              NSError * _Nullable error) {
-                              NSLog(@"Values: %@", values);
-                              responsesNeeded--;
-                              if (error != nil) {
-                                  mError = error;
-                                  LogNSError("Error", error);
-                              }
-                              if (responsesNeeded == 0) {
-                                  SetCommandExitStatus(mError);
-                              }
-                          }];
-        }
-        return CHIP_NO_ERROR;
-    }
-
-private:
-};
-
-/*
- * Command Stop
- */
-class RvcOperationalStateStop : public ClusterCommand {
-public:
-    RvcOperationalStateStop()
-        : ClusterCommand("stop")
-    {
-        ClusterCommand::AddArguments();
-    }
-
-    CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override
-    {
-        ChipLogProgress(chipTool, "Sending cluster (0x00000061) command (0x00000001) on endpoint %u", endpointId);
-
-        dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL);
-        __auto_type * cluster = [[MTRBaseClusterRVCOperationalState alloc] initWithDevice:device
-                                                                               endpointID:@(endpointId)
-                                                                                    queue:callbackQueue];
-        __auto_type * params = [[MTRRVCOperationalStateClusterStopParams alloc] init];
-        params.timedInvokeTimeoutMs
-            = mTimedInteractionTimeoutMs.HasValue() ? [NSNumber numberWithUnsignedShort:mTimedInteractionTimeoutMs.Value()] : nil;
-        uint16_t repeatCount = mRepeatCount.ValueOr(1);
-        uint16_t __block responsesNeeded = repeatCount;
-        while (repeatCount--) {
-            [cluster stopWithParams:params
-                         completion:^(MTRRVCOperationalStateClusterOperationalCommandResponseParams * _Nullable values,
-                             NSError * _Nullable error) {
-                             NSLog(@"Values: %@", values);
-                             responsesNeeded--;
-                             if (error != nil) {
-                                 mError = error;
-                                 LogNSError("Error", error);
-                             }
-                             if (responsesNeeded == 0) {
-                                 SetCommandExitStatus(mError);
-                             }
-                         }];
-        }
-        return CHIP_NO_ERROR;
-    }
-
-private:
-};
-
-/*
- * Command Start
- */
-class RvcOperationalStateStart : public ClusterCommand {
-public:
-    RvcOperationalStateStart()
-        : ClusterCommand("start")
-    {
-        ClusterCommand::AddArguments();
-    }
-
-    CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override
-    {
-        ChipLogProgress(chipTool, "Sending cluster (0x00000061) command (0x00000002) on endpoint %u", endpointId);
-
-        dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL);
-        __auto_type * cluster = [[MTRBaseClusterRVCOperationalState alloc] initWithDevice:device
-                                                                               endpointID:@(endpointId)
-                                                                                    queue:callbackQueue];
-        __auto_type * params = [[MTRRVCOperationalStateClusterStartParams alloc] init];
-        params.timedInvokeTimeoutMs
-            = mTimedInteractionTimeoutMs.HasValue() ? [NSNumber numberWithUnsignedShort:mTimedInteractionTimeoutMs.Value()] : nil;
-        uint16_t repeatCount = mRepeatCount.ValueOr(1);
-        uint16_t __block responsesNeeded = repeatCount;
-        while (repeatCount--) {
-            [cluster startWithParams:params
-                          completion:^(MTRRVCOperationalStateClusterOperationalCommandResponseParams * _Nullable values,
-                              NSError * _Nullable error) {
-                              NSLog(@"Values: %@", values);
-                              responsesNeeded--;
-                              if (error != nil) {
-                                  mError = error;
-                                  LogNSError("Error", error);
-                              }
-                              if (responsesNeeded == 0) {
-                                  SetCommandExitStatus(mError);
-                              }
-                          }];
-        }
-        return CHIP_NO_ERROR;
-    }
-
-private:
-};
-
-/*
- * Command Resume
- */
-class RvcOperationalStateResume : public ClusterCommand {
-public:
-    RvcOperationalStateResume()
-        : ClusterCommand("resume")
-    {
-        ClusterCommand::AddArguments();
-    }
-
-    CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override
-    {
-        ChipLogProgress(chipTool, "Sending cluster (0x00000061) command (0x00000003) on endpoint %u", endpointId);
-
-        dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL);
-        __auto_type * cluster = [[MTRBaseClusterRVCOperationalState alloc] initWithDevice:device
-                                                                               endpointID:@(endpointId)
-                                                                                    queue:callbackQueue];
-        __auto_type * params = [[MTRRVCOperationalStateClusterResumeParams alloc] init];
-        params.timedInvokeTimeoutMs
-            = mTimedInteractionTimeoutMs.HasValue() ? [NSNumber numberWithUnsignedShort:mTimedInteractionTimeoutMs.Value()] : nil;
-        uint16_t repeatCount = mRepeatCount.ValueOr(1);
-        uint16_t __block responsesNeeded = repeatCount;
-        while (repeatCount--) {
-            [cluster resumeWithParams:params
-                           completion:^(MTRRVCOperationalStateClusterOperationalCommandResponseParams * _Nullable values,
-                               NSError * _Nullable error) {
-                               NSLog(@"Values: %@", values);
-                               responsesNeeded--;
-                               if (error != nil) {
-                                   mError = error;
-                                   LogNSError("Error", error);
-                               }
-                               if (responsesNeeded == 0) {
-                                   SetCommandExitStatus(mError);
-                               }
-                           }];
-        }
-        return CHIP_NO_ERROR;
-    }
-
-private:
-};
-
-/*
- * Attribute PhaseList
- */
-class ReadRvcOperationalStatePhaseList : public ReadAttribute {
-public:
-    ReadRvcOperationalStatePhaseList()
-        : ReadAttribute("phase-list")
-    {
-    }
-
-    ~ReadRvcOperationalStatePhaseList() {}
-
-    CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override
-    {
-        ChipLogProgress(chipTool, "Sending cluster (0x00000061) ReadAttribute (0x00000000) on endpoint %u", endpointId);
-
-        dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL);
-        __auto_type * cluster = [[MTRBaseClusterRVCOperationalState alloc] initWithDevice:device
-                                                                               endpointID:@(endpointId)
-                                                                                    queue:callbackQueue];
-        [cluster readAttributePhaseListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable error) {
-            NSLog(@"RVCOperationalState.PhaseList response %@", [value description]);
-            if (error != nil) {
-                LogNSError("RVCOperationalState PhaseList read Error", error);
-            }
-            SetCommandExitStatus(error);
-        }];
-        return CHIP_NO_ERROR;
-    }
-};
-
-class SubscribeAttributeRvcOperationalStatePhaseList : public SubscribeAttribute {
-public:
-    SubscribeAttributeRvcOperationalStatePhaseList()
-        : SubscribeAttribute("phase-list")
-    {
-    }
-
-    ~SubscribeAttributeRvcOperationalStatePhaseList() {}
-
-    CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override
-    {
-        ChipLogProgress(chipTool, "Sending cluster (0x00000061) ReportAttribute (0x00000000) on endpoint %u", endpointId);
-        dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL);
-        __auto_type * cluster = [[MTRBaseClusterRVCOperationalState alloc] initWithDevice:device
-                                                                               endpointID:@(endpointId)
-                                                                                    queue:callbackQueue];
-        __auto_type * params = [[MTRSubscribeParams alloc] initWithMinInterval:@(mMinInterval) maxInterval:@(mMaxInterval)];
-        if (mKeepSubscriptions.HasValue()) {
-            params.replaceExistingSubscriptions = !mKeepSubscriptions.Value();
-        }
-        if (mFabricFiltered.HasValue()) {
-            params.filterByFabric = mFabricFiltered.Value();
-        }
-        if (mAutoResubscribe.HasValue()) {
-            params.resubscribeAutomatically = mAutoResubscribe.Value();
-        }
-        [cluster subscribeAttributePhaseListWithParams:params
-            subscriptionEstablished:^() {
-                mSubscriptionEstablished = YES;
-            }
-            reportHandler:^(NSArray * _Nullable value, NSError * _Nullable error) {
-                NSLog(@"RVCOperationalState.PhaseList response %@", [value description]);
-                SetCommandExitStatus(error);
-            }];
-
-        return CHIP_NO_ERROR;
-    }
-};
-
-/*
- * Attribute CurrentPhase
- */
-class ReadRvcOperationalStateCurrentPhase : public ReadAttribute {
-public:
-    ReadRvcOperationalStateCurrentPhase()
-        : ReadAttribute("current-phase")
-    {
-    }
-
-    ~ReadRvcOperationalStateCurrentPhase() {}
-
-    CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override
-    {
-        ChipLogProgress(chipTool, "Sending cluster (0x00000061) ReadAttribute (0x00000001) on endpoint %u", endpointId);
-
-        dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL);
-        __auto_type * cluster = [[MTRBaseClusterRVCOperationalState alloc] initWithDevice:device
-                                                                               endpointID:@(endpointId)
-                                                                                    queue:callbackQueue];
-        [cluster readAttributeCurrentPhaseWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable error) {
-            NSLog(@"RVCOperationalState.CurrentPhase response %@", [value description]);
-            if (error != nil) {
-                LogNSError("RVCOperationalState CurrentPhase read Error", error);
-            }
-            SetCommandExitStatus(error);
-        }];
-        return CHIP_NO_ERROR;
-    }
-};
-
-class SubscribeAttributeRvcOperationalStateCurrentPhase : public SubscribeAttribute {
-public:
-    SubscribeAttributeRvcOperationalStateCurrentPhase()
-        : SubscribeAttribute("current-phase")
-    {
-    }
-
-    ~SubscribeAttributeRvcOperationalStateCurrentPhase() {}
-
-    CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override
-    {
-        ChipLogProgress(chipTool, "Sending cluster (0x00000061) ReportAttribute (0x00000001) on endpoint %u", endpointId);
-        dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL);
-        __auto_type * cluster = [[MTRBaseClusterRVCOperationalState alloc] initWithDevice:device
-                                                                               endpointID:@(endpointId)
-                                                                                    queue:callbackQueue];
-        __auto_type * params = [[MTRSubscribeParams alloc] initWithMinInterval:@(mMinInterval) maxInterval:@(mMaxInterval)];
-        if (mKeepSubscriptions.HasValue()) {
-            params.replaceExistingSubscriptions = !mKeepSubscriptions.Value();
-        }
-        if (mFabricFiltered.HasValue()) {
-            params.filterByFabric = mFabricFiltered.Value();
-        }
-        if (mAutoResubscribe.HasValue()) {
-            params.resubscribeAutomatically = mAutoResubscribe.Value();
-        }
-        [cluster subscribeAttributeCurrentPhaseWithParams:params
-            subscriptionEstablished:^() {
-                mSubscriptionEstablished = YES;
-            }
-            reportHandler:^(NSNumber * _Nullable value, NSError * _Nullable error) {
-                NSLog(@"RVCOperationalState.CurrentPhase response %@", [value description]);
-                SetCommandExitStatus(error);
-            }];
-
-        return CHIP_NO_ERROR;
-    }
-};
-
-/*
- * Attribute CountdownTime
- */
-class ReadRvcOperationalStateCountdownTime : public ReadAttribute {
-public:
-    ReadRvcOperationalStateCountdownTime()
-        : ReadAttribute("countdown-time")
-    {
-    }
-
-    ~ReadRvcOperationalStateCountdownTime() {}
-
-    CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override
-    {
-        ChipLogProgress(chipTool, "Sending cluster (0x00000061) ReadAttribute (0x00000002) on endpoint %u", endpointId);
-
-        dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL);
-        __auto_type * cluster = [[MTRBaseClusterRVCOperationalState alloc] initWithDevice:device
-                                                                               endpointID:@(endpointId)
-                                                                                    queue:callbackQueue];
-        [cluster readAttributeCountdownTimeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable error) {
-            NSLog(@"RVCOperationalState.CountdownTime response %@", [value description]);
-            if (error != nil) {
-                LogNSError("RVCOperationalState CountdownTime read Error", error);
-            }
-            SetCommandExitStatus(error);
-        }];
-        return CHIP_NO_ERROR;
-    }
-};
-
-class SubscribeAttributeRvcOperationalStateCountdownTime : public SubscribeAttribute {
-public:
-    SubscribeAttributeRvcOperationalStateCountdownTime()
-        : SubscribeAttribute("countdown-time")
-    {
-    }
-
-    ~SubscribeAttributeRvcOperationalStateCountdownTime() {}
-
-    CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override
-    {
-        ChipLogProgress(chipTool, "Sending cluster (0x00000061) ReportAttribute (0x00000002) on endpoint %u", endpointId);
-        dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL);
-        __auto_type * cluster = [[MTRBaseClusterRVCOperationalState alloc] initWithDevice:device
-                                                                               endpointID:@(endpointId)
-                                                                                    queue:callbackQueue];
-        __auto_type * params = [[MTRSubscribeParams alloc] initWithMinInterval:@(mMinInterval) maxInterval:@(mMaxInterval)];
-        if (mKeepSubscriptions.HasValue()) {
-            params.replaceExistingSubscriptions = !mKeepSubscriptions.Value();
-        }
-        if (mFabricFiltered.HasValue()) {
-            params.filterByFabric = mFabricFiltered.Value();
-        }
-        if (mAutoResubscribe.HasValue()) {
-            params.resubscribeAutomatically = mAutoResubscribe.Value();
-        }
-        [cluster subscribeAttributeCountdownTimeWithParams:params
-            subscriptionEstablished:^() {
-                mSubscriptionEstablished = YES;
-            }
-            reportHandler:^(NSNumber * _Nullable value, NSError * _Nullable error) {
-                NSLog(@"RVCOperationalState.CountdownTime response %@", [value description]);
-                SetCommandExitStatus(error);
-            }];
-
-        return CHIP_NO_ERROR;
-    }
-};
-
-/*
- * Attribute OperationalStateList
- */
-class ReadRvcOperationalStateOperationalStateList : public ReadAttribute {
-public:
-    ReadRvcOperationalStateOperationalStateList()
-        : ReadAttribute("operational-state-list")
-    {
-    }
-
-    ~ReadRvcOperationalStateOperationalStateList() {}
-
-    CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override
-    {
-        ChipLogProgress(chipTool, "Sending cluster (0x00000061) ReadAttribute (0x00000003) on endpoint %u", endpointId);
-
-        dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL);
-        __auto_type * cluster = [[MTRBaseClusterRVCOperationalState alloc] initWithDevice:device
-                                                                               endpointID:@(endpointId)
-                                                                                    queue:callbackQueue];
-        [cluster readAttributeOperationalStateListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable error) {
-            NSLog(@"RVCOperationalState.OperationalStateList response %@", [value description]);
-            if (error != nil) {
-                LogNSError("RVCOperationalState OperationalStateList read Error", error);
-            }
-            SetCommandExitStatus(error);
-        }];
-        return CHIP_NO_ERROR;
-    }
-};
-
-class SubscribeAttributeRvcOperationalStateOperationalStateList : public SubscribeAttribute {
-public:
-    SubscribeAttributeRvcOperationalStateOperationalStateList()
-        : SubscribeAttribute("operational-state-list")
-    {
-    }
-
-    ~SubscribeAttributeRvcOperationalStateOperationalStateList() {}
-
-    CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override
-    {
-        ChipLogProgress(chipTool, "Sending cluster (0x00000061) ReportAttribute (0x00000003) on endpoint %u", endpointId);
-        dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL);
-        __auto_type * cluster = [[MTRBaseClusterRVCOperationalState alloc] initWithDevice:device
-                                                                               endpointID:@(endpointId)
-                                                                                    queue:callbackQueue];
-        __auto_type * params = [[MTRSubscribeParams alloc] initWithMinInterval:@(mMinInterval) maxInterval:@(mMaxInterval)];
-        if (mKeepSubscriptions.HasValue()) {
-            params.replaceExistingSubscriptions = !mKeepSubscriptions.Value();
-        }
-        if (mFabricFiltered.HasValue()) {
-            params.filterByFabric = mFabricFiltered.Value();
-        }
-        if (mAutoResubscribe.HasValue()) {
-            params.resubscribeAutomatically = mAutoResubscribe.Value();
-        }
-        [cluster subscribeAttributeOperationalStateListWithParams:params
-            subscriptionEstablished:^() {
-                mSubscriptionEstablished = YES;
-            }
-            reportHandler:^(NSArray * _Nullable value, NSError * _Nullable error) {
-                NSLog(@"RVCOperationalState.OperationalStateList response %@", [value description]);
-                SetCommandExitStatus(error);
-            }];
-
-        return CHIP_NO_ERROR;
-    }
-};
-
-/*
- * Attribute OperationalState
- */
-class ReadRvcOperationalStateOperationalState : public ReadAttribute {
-public:
-    ReadRvcOperationalStateOperationalState()
-        : ReadAttribute("operational-state")
-    {
-    }
-
-    ~ReadRvcOperationalStateOperationalState() {}
-
-    CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override
-    {
-        ChipLogProgress(chipTool, "Sending cluster (0x00000061) ReadAttribute (0x00000004) on endpoint %u", endpointId);
-
-        dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL);
-        __auto_type * cluster = [[MTRBaseClusterRVCOperationalState alloc] initWithDevice:device
-                                                                               endpointID:@(endpointId)
-                                                                                    queue:callbackQueue];
-        [cluster readAttributeOperationalStateWithCompletion:^(
-            MTRRVCOperationalStateClusterOperationalStateStruct * _Nullable value, NSError * _Nullable error) {
-            NSLog(@"RVCOperationalState.OperationalState response %@", [value description]);
-            if (error != nil) {
-                LogNSError("RVCOperationalState OperationalState read Error", error);
-            }
-            SetCommandExitStatus(error);
-        }];
-        return CHIP_NO_ERROR;
-    }
-};
-
-class SubscribeAttributeRvcOperationalStateOperationalState : public SubscribeAttribute {
-public:
-    SubscribeAttributeRvcOperationalStateOperationalState()
-        : SubscribeAttribute("operational-state")
-    {
-    }
-
-    ~SubscribeAttributeRvcOperationalStateOperationalState() {}
-
-    CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override
-    {
-        ChipLogProgress(chipTool, "Sending cluster (0x00000061) ReportAttribute (0x00000004) on endpoint %u", endpointId);
-        dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL);
-        __auto_type * cluster = [[MTRBaseClusterRVCOperationalState alloc] initWithDevice:device
-                                                                               endpointID:@(endpointId)
-                                                                                    queue:callbackQueue];
-        __auto_type * params = [[MTRSubscribeParams alloc] initWithMinInterval:@(mMinInterval) maxInterval:@(mMaxInterval)];
-        if (mKeepSubscriptions.HasValue()) {
-            params.replaceExistingSubscriptions = !mKeepSubscriptions.Value();
-        }
-        if (mFabricFiltered.HasValue()) {
-            params.filterByFabric = mFabricFiltered.Value();
-        }
-        if (mAutoResubscribe.HasValue()) {
-            params.resubscribeAutomatically = mAutoResubscribe.Value();
-        }
-        [cluster subscribeAttributeOperationalStateWithParams:params
-            subscriptionEstablished:^() {
-                mSubscriptionEstablished = YES;
-            }
-            reportHandler:^(MTRRVCOperationalStateClusterOperationalStateStruct * _Nullable value, NSError * _Nullable error) {
-                NSLog(@"RVCOperationalState.OperationalState response %@", [value description]);
-                SetCommandExitStatus(error);
-            }];
-
-        return CHIP_NO_ERROR;
-    }
-};
-
-/*
- * Attribute OperationalError
- */
-class ReadRvcOperationalStateOperationalError : public ReadAttribute {
-public:
-    ReadRvcOperationalStateOperationalError()
-        : ReadAttribute("operational-error")
-    {
-    }
-
-    ~ReadRvcOperationalStateOperationalError() {}
-
-    CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override
-    {
-        ChipLogProgress(chipTool, "Sending cluster (0x00000061) ReadAttribute (0x00000005) on endpoint %u", endpointId);
-
-        dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL);
-        __auto_type * cluster = [[MTRBaseClusterRVCOperationalState alloc] initWithDevice:device
-                                                                               endpointID:@(endpointId)
-                                                                                    queue:callbackQueue];
-        [cluster readAttributeOperationalErrorWithCompletion:^(
-            MTRRVCOperationalStateClusterErrorStateStruct * _Nullable value, NSError * _Nullable error) {
-            NSLog(@"RVCOperationalState.OperationalError response %@", [value description]);
-            if (error != nil) {
-                LogNSError("RVCOperationalState OperationalError read Error", error);
-            }
-            SetCommandExitStatus(error);
-        }];
-        return CHIP_NO_ERROR;
-    }
-};
-
-class SubscribeAttributeRvcOperationalStateOperationalError : public SubscribeAttribute {
-public:
-    SubscribeAttributeRvcOperationalStateOperationalError()
-        : SubscribeAttribute("operational-error")
-    {
-    }
-
-    ~SubscribeAttributeRvcOperationalStateOperationalError() {}
-
-    CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override
-    {
-        ChipLogProgress(chipTool, "Sending cluster (0x00000061) ReportAttribute (0x00000005) on endpoint %u", endpointId);
-        dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL);
-        __auto_type * cluster = [[MTRBaseClusterRVCOperationalState alloc] initWithDevice:device
-                                                                               endpointID:@(endpointId)
-                                                                                    queue:callbackQueue];
-        __auto_type * params = [[MTRSubscribeParams alloc] initWithMinInterval:@(mMinInterval) maxInterval:@(mMaxInterval)];
-        if (mKeepSubscriptions.HasValue()) {
-            params.replaceExistingSubscriptions = !mKeepSubscriptions.Value();
-        }
-        if (mFabricFiltered.HasValue()) {
-            params.filterByFabric = mFabricFiltered.Value();
-        }
-        if (mAutoResubscribe.HasValue()) {
-            params.resubscribeAutomatically = mAutoResubscribe.Value();
-        }
-        [cluster subscribeAttributeOperationalErrorWithParams:params
-            subscriptionEstablished:^() {
-                mSubscriptionEstablished = YES;
-            }
-            reportHandler:^(MTRRVCOperationalStateClusterErrorStateStruct * _Nullable value, NSError * _Nullable error) {
-                NSLog(@"RVCOperationalState.OperationalError response %@", [value description]);
-                SetCommandExitStatus(error);
-            }];
-
-        return CHIP_NO_ERROR;
-    }
-};
-
-/*
- * Attribute GeneratedCommandList
- */
-class ReadRvcOperationalStateGeneratedCommandList : public ReadAttribute {
-public:
-    ReadRvcOperationalStateGeneratedCommandList()
-        : ReadAttribute("generated-command-list")
-    {
-    }
-
-    ~ReadRvcOperationalStateGeneratedCommandList() {}
-
-    CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override
-    {
-        ChipLogProgress(chipTool, "Sending cluster (0x00000061) ReadAttribute (0x0000FFF8) on endpoint %u", endpointId);
-
-        dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL);
-        __auto_type * cluster = [[MTRBaseClusterRVCOperationalState alloc] initWithDevice:device
-                                                                               endpointID:@(endpointId)
-                                                                                    queue:callbackQueue];
-        [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable error) {
-            NSLog(@"RVCOperationalState.GeneratedCommandList response %@", [value description]);
-            if (error != nil) {
-                LogNSError("RVCOperationalState GeneratedCommandList read Error", error);
-            }
-            SetCommandExitStatus(error);
-        }];
-        return CHIP_NO_ERROR;
-    }
-};
-
-class SubscribeAttributeRvcOperationalStateGeneratedCommandList : public SubscribeAttribute {
-public:
-    SubscribeAttributeRvcOperationalStateGeneratedCommandList()
-        : SubscribeAttribute("generated-command-list")
-    {
-    }
-
-    ~SubscribeAttributeRvcOperationalStateGeneratedCommandList() {}
-
-    CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override
-    {
-        ChipLogProgress(chipTool, "Sending cluster (0x00000061) ReportAttribute (0x0000FFF8) on endpoint %u", endpointId);
-        dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL);
-        __auto_type * cluster = [[MTRBaseClusterRVCOperationalState alloc] initWithDevice:device
-                                                                               endpointID:@(endpointId)
-                                                                                    queue:callbackQueue];
-        __auto_type * params = [[MTRSubscribeParams alloc] initWithMinInterval:@(mMinInterval) maxInterval:@(mMaxInterval)];
-        if (mKeepSubscriptions.HasValue()) {
-            params.replaceExistingSubscriptions = !mKeepSubscriptions.Value();
-        }
-        if (mFabricFiltered.HasValue()) {
-            params.filterByFabric = mFabricFiltered.Value();
-        }
-        if (mAutoResubscribe.HasValue()) {
-            params.resubscribeAutomatically = mAutoResubscribe.Value();
-        }
-        [cluster subscribeAttributeGeneratedCommandListWithParams:params
-            subscriptionEstablished:^() {
-                mSubscriptionEstablished = YES;
-            }
-            reportHandler:^(NSArray * _Nullable value, NSError * _Nullable error) {
-                NSLog(@"RVCOperationalState.GeneratedCommandList response %@", [value description]);
-                SetCommandExitStatus(error);
-            }];
-
-        return CHIP_NO_ERROR;
-    }
-};
-
-/*
- * Attribute AcceptedCommandList
- */
-class ReadRvcOperationalStateAcceptedCommandList : public ReadAttribute {
-public:
-    ReadRvcOperationalStateAcceptedCommandList()
-        : ReadAttribute("accepted-command-list")
-    {
-    }
-
-    ~ReadRvcOperationalStateAcceptedCommandList() {}
-
-    CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override
-    {
-        ChipLogProgress(chipTool, "Sending cluster (0x00000061) ReadAttribute (0x0000FFF9) on endpoint %u", endpointId);
-
-        dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL);
-        __auto_type * cluster = [[MTRBaseClusterRVCOperationalState alloc] initWithDevice:device
-                                                                               endpointID:@(endpointId)
-                                                                                    queue:callbackQueue];
-        [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable error) {
-            NSLog(@"RVCOperationalState.AcceptedCommandList response %@", [value description]);
-            if (error != nil) {
-                LogNSError("RVCOperationalState AcceptedCommandList read Error", error);
-            }
-            SetCommandExitStatus(error);
-        }];
-        return CHIP_NO_ERROR;
-    }
-};
-
-class SubscribeAttributeRvcOperationalStateAcceptedCommandList : public SubscribeAttribute {
-public:
-    SubscribeAttributeRvcOperationalStateAcceptedCommandList()
-        : SubscribeAttribute("accepted-command-list")
-    {
-    }
-
-    ~SubscribeAttributeRvcOperationalStateAcceptedCommandList() {}
-
-    CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override
-    {
-        ChipLogProgress(chipTool, "Sending cluster (0x00000061) ReportAttribute (0x0000FFF9) on endpoint %u", endpointId);
-        dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL);
-        __auto_type * cluster = [[MTRBaseClusterRVCOperationalState alloc] initWithDevice:device
-                                                                               endpointID:@(endpointId)
-                                                                                    queue:callbackQueue];
-        __auto_type * params = [[MTRSubscribeParams alloc] initWithMinInterval:@(mMinInterval) maxInterval:@(mMaxInterval)];
-        if (mKeepSubscriptions.HasValue()) {
-            params.replaceExistingSubscriptions = !mKeepSubscriptions.Value();
-        }
-        if (mFabricFiltered.HasValue()) {
-            params.filterByFabric = mFabricFiltered.Value();
-        }
-        if (mAutoResubscribe.HasValue()) {
-            params.resubscribeAutomatically = mAutoResubscribe.Value();
-        }
-        [cluster subscribeAttributeAcceptedCommandListWithParams:params
-            subscriptionEstablished:^() {
-                mSubscriptionEstablished = YES;
-            }
-            reportHandler:^(NSArray * _Nullable value, NSError * _Nullable error) {
-                NSLog(@"RVCOperationalState.AcceptedCommandList response %@", [value description]);
-                SetCommandExitStatus(error);
-            }];
-
-        return CHIP_NO_ERROR;
-    }
-};
-
-/*
- * Attribute EventList
- */
-class ReadRvcOperationalStateEventList : public ReadAttribute {
-public:
-    ReadRvcOperationalStateEventList()
-        : ReadAttribute("event-list")
-    {
-    }
-
-    ~ReadRvcOperationalStateEventList() {}
-
-    CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override
-    {
-        ChipLogProgress(chipTool, "Sending cluster (0x00000061) ReadAttribute (0x0000FFFA) on endpoint %u", endpointId);
-
-        dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL);
-        __auto_type * cluster = [[MTRBaseClusterRVCOperationalState alloc] initWithDevice:device
-                                                                               endpointID:@(endpointId)
-                                                                                    queue:callbackQueue];
-        [cluster readAttributeEventListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable error) {
-            NSLog(@"RVCOperationalState.EventList response %@", [value description]);
-            if (error != nil) {
-                LogNSError("RVCOperationalState EventList read Error", error);
-            }
-            SetCommandExitStatus(error);
-        }];
-        return CHIP_NO_ERROR;
-    }
-};
-
-class SubscribeAttributeRvcOperationalStateEventList : public SubscribeAttribute {
-public:
-    SubscribeAttributeRvcOperationalStateEventList()
-        : SubscribeAttribute("event-list")
-    {
-    }
-
-    ~SubscribeAttributeRvcOperationalStateEventList() {}
-
-    CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override
-    {
-        ChipLogProgress(chipTool, "Sending cluster (0x00000061) ReportAttribute (0x0000FFFA) on endpoint %u", endpointId);
-        dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL);
-        __auto_type * cluster = [[MTRBaseClusterRVCOperationalState alloc] initWithDevice:device
-                                                                               endpointID:@(endpointId)
-                                                                                    queue:callbackQueue];
-        __auto_type * params = [[MTRSubscribeParams alloc] initWithMinInterval:@(mMinInterval) maxInterval:@(mMaxInterval)];
-        if (mKeepSubscriptions.HasValue()) {
-            params.replaceExistingSubscriptions = !mKeepSubscriptions.Value();
-        }
-        if (mFabricFiltered.HasValue()) {
-            params.filterByFabric = mFabricFiltered.Value();
-        }
-        if (mAutoResubscribe.HasValue()) {
-            params.resubscribeAutomatically = mAutoResubscribe.Value();
-        }
-        [cluster subscribeAttributeEventListWithParams:params
-            subscriptionEstablished:^() {
-                mSubscriptionEstablished = YES;
-            }
-            reportHandler:^(NSArray * _Nullable value, NSError * _Nullable error) {
-                NSLog(@"RVCOperationalState.EventList response %@", [value description]);
-                SetCommandExitStatus(error);
-            }];
-
-        return CHIP_NO_ERROR;
-    }
-};
-
-/*
- * Attribute AttributeList
- */
-class ReadRvcOperationalStateAttributeList : public ReadAttribute {
-public:
-    ReadRvcOperationalStateAttributeList()
-        : ReadAttribute("attribute-list")
-    {
-    }
-
-    ~ReadRvcOperationalStateAttributeList() {}
-
-    CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override
-    {
-        ChipLogProgress(chipTool, "Sending cluster (0x00000061) ReadAttribute (0x0000FFFB) on endpoint %u", endpointId);
-
-        dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL);
-        __auto_type * cluster = [[MTRBaseClusterRVCOperationalState alloc] initWithDevice:device
-                                                                               endpointID:@(endpointId)
-                                                                                    queue:callbackQueue];
-        [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable error) {
-            NSLog(@"RVCOperationalState.AttributeList response %@", [value description]);
-            if (error != nil) {
-                LogNSError("RVCOperationalState AttributeList read Error", error);
-            }
-            SetCommandExitStatus(error);
-        }];
-        return CHIP_NO_ERROR;
-    }
-};
-
-class SubscribeAttributeRvcOperationalStateAttributeList : public SubscribeAttribute {
-public:
-    SubscribeAttributeRvcOperationalStateAttributeList()
-        : SubscribeAttribute("attribute-list")
-    {
-    }
-
-    ~SubscribeAttributeRvcOperationalStateAttributeList() {}
-
-    CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override
-    {
-        ChipLogProgress(chipTool, "Sending cluster (0x00000061) ReportAttribute (0x0000FFFB) on endpoint %u", endpointId);
-        dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL);
-        __auto_type * cluster = [[MTRBaseClusterRVCOperationalState alloc] initWithDevice:device
-                                                                               endpointID:@(endpointId)
-                                                                                    queue:callbackQueue];
-        __auto_type * params = [[MTRSubscribeParams alloc] initWithMinInterval:@(mMinInterval) maxInterval:@(mMaxInterval)];
-        if (mKeepSubscriptions.HasValue()) {
-            params.replaceExistingSubscriptions = !mKeepSubscriptions.Value();
-        }
-        if (mFabricFiltered.HasValue()) {
-            params.filterByFabric = mFabricFiltered.Value();
-        }
-        if (mAutoResubscribe.HasValue()) {
-            params.resubscribeAutomatically = mAutoResubscribe.Value();
-        }
-        [cluster subscribeAttributeAttributeListWithParams:params
-            subscriptionEstablished:^() {
-                mSubscriptionEstablished = YES;
-            }
-            reportHandler:^(NSArray * _Nullable value, NSError * _Nullable error) {
-                NSLog(@"RVCOperationalState.AttributeList response %@", [value description]);
-                SetCommandExitStatus(error);
-            }];
-
-        return CHIP_NO_ERROR;
-    }
-};
-
-/*
- * Attribute FeatureMap
- */
-class ReadRvcOperationalStateFeatureMap : public ReadAttribute {
-public:
-    ReadRvcOperationalStateFeatureMap()
-        : ReadAttribute("feature-map")
-    {
-    }
-
-    ~ReadRvcOperationalStateFeatureMap() {}
-
-    CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override
-    {
-        ChipLogProgress(chipTool, "Sending cluster (0x00000061) ReadAttribute (0x0000FFFC) on endpoint %u", endpointId);
-
-        dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL);
-        __auto_type * cluster = [[MTRBaseClusterRVCOperationalState alloc] initWithDevice:device
-                                                                               endpointID:@(endpointId)
-                                                                                    queue:callbackQueue];
-        [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable error) {
-            NSLog(@"RVCOperationalState.FeatureMap response %@", [value description]);
-            if (error != nil) {
-                LogNSError("RVCOperationalState FeatureMap read Error", error);
-            }
-            SetCommandExitStatus(error);
-        }];
-        return CHIP_NO_ERROR;
-    }
-};
-
-class SubscribeAttributeRvcOperationalStateFeatureMap : public SubscribeAttribute {
-public:
-    SubscribeAttributeRvcOperationalStateFeatureMap()
-        : SubscribeAttribute("feature-map")
-    {
-    }
-
-    ~SubscribeAttributeRvcOperationalStateFeatureMap() {}
-
-    CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override
-    {
-        ChipLogProgress(chipTool, "Sending cluster (0x00000061) ReportAttribute (0x0000FFFC) on endpoint %u", endpointId);
-        dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL);
-        __auto_type * cluster = [[MTRBaseClusterRVCOperationalState alloc] initWithDevice:device
-                                                                               endpointID:@(endpointId)
-                                                                                    queue:callbackQueue];
-        __auto_type * params = [[MTRSubscribeParams alloc] initWithMinInterval:@(mMinInterval) maxInterval:@(mMaxInterval)];
-        if (mKeepSubscriptions.HasValue()) {
-            params.replaceExistingSubscriptions = !mKeepSubscriptions.Value();
-        }
-        if (mFabricFiltered.HasValue()) {
-            params.filterByFabric = mFabricFiltered.Value();
-        }
-        if (mAutoResubscribe.HasValue()) {
-            params.resubscribeAutomatically = mAutoResubscribe.Value();
-        }
-        [cluster subscribeAttributeFeatureMapWithParams:params
-            subscriptionEstablished:^() {
-                mSubscriptionEstablished = YES;
-            }
-            reportHandler:^(NSNumber * _Nullable value, NSError * _Nullable error) {
-                NSLog(@"RVCOperationalState.FeatureMap response %@", [value description]);
-                SetCommandExitStatus(error);
-            }];
-
-        return CHIP_NO_ERROR;
-    }
-};
-
-/*
- * Attribute ClusterRevision
- */
-class ReadRvcOperationalStateClusterRevision : public ReadAttribute {
-public:
-    ReadRvcOperationalStateClusterRevision()
-        : ReadAttribute("cluster-revision")
-    {
-    }
-
-    ~ReadRvcOperationalStateClusterRevision() {}
-
-    CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override
-    {
-        ChipLogProgress(chipTool, "Sending cluster (0x00000061) ReadAttribute (0x0000FFFD) on endpoint %u", endpointId);
-
-        dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL);
-        __auto_type * cluster = [[MTRBaseClusterRVCOperationalState alloc] initWithDevice:device
-                                                                               endpointID:@(endpointId)
-                                                                                    queue:callbackQueue];
-        [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable error) {
-            NSLog(@"RVCOperationalState.ClusterRevision response %@", [value description]);
-            if (error != nil) {
-                LogNSError("RVCOperationalState ClusterRevision read Error", error);
-            }
-            SetCommandExitStatus(error);
-        }];
-        return CHIP_NO_ERROR;
-    }
-};
-
-class SubscribeAttributeRvcOperationalStateClusterRevision : public SubscribeAttribute {
-public:
-    SubscribeAttributeRvcOperationalStateClusterRevision()
-        : SubscribeAttribute("cluster-revision")
-    {
-    }
-
-    ~SubscribeAttributeRvcOperationalStateClusterRevision() {}
-
-    CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override
-    {
-        ChipLogProgress(chipTool, "Sending cluster (0x00000061) ReportAttribute (0x0000FFFD) on endpoint %u", endpointId);
-        dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL);
-        __auto_type * cluster = [[MTRBaseClusterRVCOperationalState alloc] initWithDevice:device
-                                                                               endpointID:@(endpointId)
-                                                                                    queue:callbackQueue];
-        __auto_type * params = [[MTRSubscribeParams alloc] initWithMinInterval:@(mMinInterval) maxInterval:@(mMaxInterval)];
-        if (mKeepSubscriptions.HasValue()) {
-            params.replaceExistingSubscriptions = !mKeepSubscriptions.Value();
-        }
-        if (mFabricFiltered.HasValue()) {
-            params.filterByFabric = mFabricFiltered.Value();
-        }
-        if (mAutoResubscribe.HasValue()) {
-            params.resubscribeAutomatically = mAutoResubscribe.Value();
-        }
-        [cluster subscribeAttributeClusterRevisionWithParams:params
-            subscriptionEstablished:^() {
-                mSubscriptionEstablished = YES;
-            }
-            reportHandler:^(NSNumber * _Nullable value, NSError * _Nullable error) {
-                NSLog(@"RVCOperationalState.ClusterRevision response %@", [value description]);
-                SetCommandExitStatus(error);
-            }];
-
-        return CHIP_NO_ERROR;
-    }
-};
-
-/*----------------------------------------------------------------------------*\
 | Cluster HepaFilterMonitoring                                        | 0x0071 |
 |------------------------------------------------------------------------------|
 | Commands:                                                           |        |
@@ -123645,51 +122595,6 @@
 
     commands.Register(clusterName, clusterCommands);
 }
-void registerClusterRvcOperationalState(Commands & commands)
-{
-    using namespace chip::app::Clusters::RvcOperationalState;
-
-    const char * clusterName = "RvcOperationalState";
-
-    commands_list clusterCommands = {
-        make_unique<ClusterCommand>(Id), //
-        make_unique<RvcOperationalStatePause>(), //
-        make_unique<RvcOperationalStateStop>(), //
-        make_unique<RvcOperationalStateStart>(), //
-        make_unique<RvcOperationalStateResume>(), //
-        make_unique<ReadAttribute>(Id), //
-        make_unique<ReadRvcOperationalStatePhaseList>(), //
-        make_unique<WriteAttribute>(Id), //
-        make_unique<SubscribeAttribute>(Id), //
-        make_unique<SubscribeAttributeRvcOperationalStatePhaseList>(), //
-        make_unique<ReadRvcOperationalStateCurrentPhase>(), //
-        make_unique<SubscribeAttributeRvcOperationalStateCurrentPhase>(), //
-        make_unique<ReadRvcOperationalStateCountdownTime>(), //
-        make_unique<SubscribeAttributeRvcOperationalStateCountdownTime>(), //
-        make_unique<ReadRvcOperationalStateOperationalStateList>(), //
-        make_unique<SubscribeAttributeRvcOperationalStateOperationalStateList>(), //
-        make_unique<ReadRvcOperationalStateOperationalState>(), //
-        make_unique<SubscribeAttributeRvcOperationalStateOperationalState>(), //
-        make_unique<ReadRvcOperationalStateOperationalError>(), //
-        make_unique<SubscribeAttributeRvcOperationalStateOperationalError>(), //
-        make_unique<ReadRvcOperationalStateGeneratedCommandList>(), //
-        make_unique<SubscribeAttributeRvcOperationalStateGeneratedCommandList>(), //
-        make_unique<ReadRvcOperationalStateAcceptedCommandList>(), //
-        make_unique<SubscribeAttributeRvcOperationalStateAcceptedCommandList>(), //
-        make_unique<ReadRvcOperationalStateEventList>(), //
-        make_unique<SubscribeAttributeRvcOperationalStateEventList>(), //
-        make_unique<ReadRvcOperationalStateAttributeList>(), //
-        make_unique<SubscribeAttributeRvcOperationalStateAttributeList>(), //
-        make_unique<ReadRvcOperationalStateFeatureMap>(), //
-        make_unique<SubscribeAttributeRvcOperationalStateFeatureMap>(), //
-        make_unique<ReadRvcOperationalStateClusterRevision>(), //
-        make_unique<SubscribeAttributeRvcOperationalStateClusterRevision>(), //
-        make_unique<ReadEvent>(Id), //
-        make_unique<SubscribeEvent>(Id), //
-    };
-
-    commands.Register(clusterName, clusterCommands);
-}
 void registerClusterHepaFilterMonitoring(Commands & commands)
 {
     using namespace chip::app::Clusters::HepaFilterMonitoring;
@@ -126396,7 +125301,6 @@
     registerClusterAirQuality(commands);
     registerClusterSmokeCoAlarm(commands);
     registerClusterOperationalState(commands);
-    registerClusterRvcOperationalState(commands);
     registerClusterHepaFilterMonitoring(commands);
     registerClusterActivatedCarbonFilterMonitoring(commands);
     registerClusterDoorLock(commands);
