Skip to content

Commit

Permalink
Made onoff and scenes behaviors independant in scenes interaction
Browse files Browse the repository at this point in the history
  • Loading branch information
lpbeliveau-silabs committed Jul 23, 2024
1 parent b68a5d3 commit 8b508ba
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 99 deletions.
5 changes: 1 addition & 4 deletions src/app/clusters/level-control/level-control.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,10 +250,7 @@ class DefaultLevelControlSceneHandler : public scenes::DefaultSceneHandlerImpl

if (!app::NumericAttributeTraits<uint8_t>::IsNullValue(level))
{
CommandId command = LevelControlHasFeature(endpoint, LevelControl::Feature::kOnOff) ? Commands::MoveToLevelWithOnOff::Id
: Commands::MoveToLevel::Id;

moveToLevelHandler(endpoint, command, level, app::DataModel::MakeNullable(static_cast<uint16_t>(timeMs / 100)),
moveToLevelHandler(endpoint, Commands::MoveToLevel::Id, level, app::DataModel::MakeNullable(static_cast<uint16_t>(timeMs / 100)),
chip::Optional<BitMask<OptionsBitmap>>(), chip::Optional<BitMask<OptionsBitmap>>(),
INVALID_STORED_LEVEL);
}
Expand Down
15 changes: 2 additions & 13 deletions src/app/clusters/on-off-server/on-off-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,19 +207,8 @@ class DefaultOnOffSceneHandler : public scenes::DefaultSceneHandlerImpl
return err;
}

// This handler assumes it is being used with the default handler for the level control. Therefore if the level control
// cluster with on off feature is present on the endpoint and the level control handler is registered, it assumes this
// handler will take action on the on-off state. This assumes the level control attributes were also saved in the scene.
// This is to prevent a behavior where the on off state is set by this handler, and then the level control handler or vice
// versa.
#ifdef MATTER_DM_PLUGIN_LEVEL_CONTROL
if (!(LevelControlWithOnOffFeaturePresent(endpoint) &&
ScenesManagement::ScenesServer::Instance().IsHandlerRegistered(endpoint, LevelControlServer::GetSceneHandler())))
#endif
{
VerifyOrReturnError(mTransitionTimeInterface.sceneEventControl(endpoint) != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
OnOffServer::Instance().scheduleTimerCallbackMs(mTransitionTimeInterface.sceneEventControl(endpoint), timeMs);
}
VerifyOrReturnError(mTransitionTimeInterface.sceneEventControl(endpoint) != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
OnOffServer::Instance().scheduleTimerCallbackMs(mTransitionTimeInterface.sceneEventControl(endpoint), timeMs);

return CHIP_NO_ERROR;
}
Expand Down
99 changes: 17 additions & 82 deletions src/app/tests/suites/certification/Test_TC_OO_2_7.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -123,26 +123,23 @@ tests:
value: []

- label: "Step 2a: TH sends Off command to DUT"
PICS: "!LVL.S.C04.Rsp"
cluster: "On/Off"
command: "Off"

- label:
"Step 2a: TH sends a MoveToLevelWithOnOff command to DUT, with Level
=0 and TransitionTime =0 (immediate)"
PICS: LVL.S.C04.Rsp
cluster: "Level Control"
command: "MoveToLevelWithOnOff"
- label: "Wait 1000ms"
cluster: "DelayCommands"
command: "WaitForMs"
arguments:
values:
- name: "Level"
value: 0
- name: "TransitionTime"
value: 0
- name: "OptionsMask"
value: 0
- name: "OptionsOverride"
value: 0
- name: "ms"
value: 1000

- label: "Step 2b: after a few seconds, TH reads OnOff attribute from DUT"
cluster: "On/Off"
command: "readAttribute"
attribute: "OnOff"
response:
value: 0

- label:
"Step 2b: TH sends a StoreScene command to DUT with the GroupID field
Expand All @@ -169,9 +166,6 @@ tests:
AttributeValueList: [{ AttributeID: 0x0000, ValueUnsigned8: 0x01 }]}]'
"
command: "AddScene"
## The default handlers for level control and on/off assume that if both clusters are in the same endpoint,
## the level control cluster will use the onoff with level command and thus onoff will be turned on.
PICS: LVL.S.C04.Rsp
arguments:
values:
- name: "GroupID"
Expand All @@ -189,12 +183,7 @@ tests:
ClusterID: 0x0006,
AttributeValueList:
[{ AttributeID: 0x0000, ValueUnsigned8: 0x01 }],
},
{
ClusterID: 0x0008,
AttributeValueList:
[{ AttributeID: 0x0000, ValueUnsigned8: 0xFE }],
},
}
]
response:
values:
Expand All @@ -205,62 +194,8 @@ tests:
- name: "SceneID"
value: 0x02

- label: "Step 3: TH sends a AddScene command to DUT with the GroupID field
set to G1, the SceneID field set to 0x02, the TransitionTime field set
to 1000 (1s) and the ExtensionFieldSets set to: '[{ ClusterID: 0x0006,
AttributeValueList: [{ AttributeID: 0x0000, ValueUnsigned8: 0x01 }]}]'
"
command: "AddScene"
PICS: "!LVL.S.C04.Rsp"
arguments:
values:
- name: "GroupID"
value: G1
- name: "SceneID"
value: 0x02
- name: "TransitionTime"
value: 1000
- name: "SceneName"
value: "Scene1"
- name: "ExtensionFieldSets"
value:
[
{
ClusterID: 0x0006,
AttributeValueList:
[{ AttributeID: 0x0000, ValueUnsigned8: 0x01 }],
},
]
response:
values:
- name: "Status"
value: 0x00
- name: "GroupID"
value: G1
- name: "SceneID"
value: 0x02

- label: "Step 4a: TH sends Off command to DUT"
cluster: "On/Off"
command: "Off"

- label: "Wait 1000ms"
cluster: "DelayCommands"
command: "WaitForMs"
arguments:
values:
- name: "ms"
value: 1000

- label: "Step 4b: after a few seconds, TH reads OnOff attribute from DUT"
cluster: "On/Off"
command: "readAttribute"
attribute: "OnOff"
response:
value: 0

- label:
"Step 5a: TH sends a RecallScene command to DUT with the GroupID field
"Step 4a: TH sends a RecallScene command to DUT with the GroupID field
set to G1 and the SceneID field set to 0x02."
PICS: S.S.C05.Rsp
command: "RecallScene"
Expand All @@ -279,15 +214,15 @@ tests:
- name: "ms"
value: 2000

- label: "Step 5b: after a few seconds, TH reads OnOff attribute from DUT"
- label: "Step 4b: after a few seconds, TH reads OnOff attribute from DUT"
cluster: "On/Off"
command: "readAttribute"
attribute: "OnOff"
response:
value: 1

- label:
"Step 6a: TH sends a RecallScene command to DUT with the GroupID field
"Step 5a: TH sends a RecallScene command to DUT with the GroupID field
set to G1 and the SceneID field set to 0x01."
PICS: S.S.C05.Rsp
command: "RecallScene"
Expand All @@ -306,7 +241,7 @@ tests:
- name: "ms"
value: 1000

- label: "Step 6b: after a few seconds, TH reads OnOff attribute from DUT"
- label: "Step 5b: after a few seconds, TH reads OnOff attribute from DUT"
cluster: "On/Off"
command: "readAttribute"
attribute: "OnOff"
Expand Down

0 comments on commit 8b508ba

Please sign in to comment.