@@ -89,6 +89,12 @@ void UpdateModeBaseCurrentModeToOnMode(EndpointId endpoint)
89
89
90
90
#endif // MATTER_DM_PLUGIN_MODE_BASE
91
91
92
+ template <typename EnumType>
93
+ bool IsKnownEnumValue (EnumType value)
94
+ {
95
+ return (EnsureKnownEnumValue (value) != EnumType::kUnknownEnumValue );
96
+ }
97
+
92
98
} // namespace
93
99
94
100
#ifdef MATTER_DM_PLUGIN_LEVEL_CONTROL
@@ -609,6 +615,35 @@ bool OnOffServer::offWithEffectCommand(app::CommandHandler * commandObj, const a
609
615
chip::EndpointId endpoint = commandPath.mEndpointId ;
610
616
Status status = Status::Success;
611
617
618
+ if (effectId != EffectIdentifierEnum::kUnknownEnumValue )
619
+ {
620
+ // Depending on effectId value, effectVariant enum type varies.
621
+ // The following check validates that effectVariant value is valid in relation to the applicable enum type.
622
+ // DelayedAllOffEffectVariantEnum or DyingLightEffectVariantEnum
623
+ if (effectId == EffectIdentifierEnum::kDelayedAllOff &&
624
+ !IsKnownEnumValue (static_cast <DelayedAllOffEffectVariantEnum>(effectVariant)))
625
+ {
626
+ // The server does not support the given variant, it SHALL use the default variant.
627
+ effectVariant = to_underlying (DelayedAllOffEffectVariantEnum::kDelayedOffFastFade );
628
+ }
629
+ else if (effectId == EffectIdentifierEnum::kDyingLight &&
630
+ !IsKnownEnumValue (static_cast <DyingLightEffectVariantEnum>(effectVariant)))
631
+ {
632
+ // The server does not support the given variant, it SHALL use the default variant.
633
+ effectVariant = to_underlying (DyingLightEffectVariantEnum::kDyingLightFadeOff );
634
+ }
635
+ }
636
+ else
637
+ {
638
+ status = Status::ConstraintError;
639
+ }
640
+
641
+ if (status != Status::Success)
642
+ {
643
+ commandObj->AddStatus (commandPath, status);
644
+ return true ;
645
+ }
646
+
612
647
if (SupportsLightingApplications (endpoint))
613
648
{
614
649
#ifdef MATTER_DM_PLUGIN_SCENES_MANAGEMENT
0 commit comments