Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 9 additions & 14 deletions src/app/clusters/on-off-server/on-off-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,6 @@ EmberAfStatus OnOffServer::setOnOffValue(chip::EndpointId endpoint, chip::Comman
EmberAfStatus status;
bool currentValue, newValue;

emberAfOnOffClusterPrintln("On/Off set value: %x %x", endpoint, static_cast<uint8_t>(command));

// read current on/off value
status = Attributes::OnOff::Get(endpoint, &currentValue);
if (status != EMBER_ZCL_STATUS_SUCCESS)
Expand All @@ -122,14 +120,14 @@ EmberAfStatus OnOffServer::setOnOffValue(chip::EndpointId endpoint, chip::Comman
// if the value is already what we want to set it to then do nothing
if ((!currentValue && command == Commands::Off::Id) || (currentValue && command == Commands::On::Id))
{
emberAfOnOffClusterPrintln("On/off already set to new value");
emberAfOnOffClusterPrintln("Endpoint %x On/off already set to new value", endpoint);
return EMBER_ZCL_STATUS_SUCCESS;
}

// we either got a toggle, or an on when off, or an off when on,
// so we need to swap the value
newValue = !currentValue;
emberAfOnOffClusterPrintln("Toggle on/off from %x to %x", currentValue, newValue);
emberAfOnOffClusterPrintln("Toggle ep%x on/off from state %x to %x", endpoint, currentValue, newValue);

// the sequence of updating on/off attribute and kick off level change effect should
// be depend on whether we are turning on or off. If we are turning on the light, we
Expand Down Expand Up @@ -192,12 +190,6 @@ EmberAfStatus OnOffServer::setOnOffValue(chip::EndpointId endpoint, chip::Comman
}
else // Set Off
{
if (SupportsLightingApplications(endpoint))
{
emberAfOnOffClusterPrintln("Off Command - OnTime : 0");
Attributes::OnTime::Set(endpoint, 0); // Reset onTime
}

#ifdef EMBER_AF_PLUGIN_LEVEL_CONTROL
// If initiatedByLevelChange is false, then we assume that the level change
// ZCL stuff has not happened and we do it here
Expand All @@ -206,18 +198,22 @@ EmberAfStatus OnOffServer::setOnOffValue(chip::EndpointId endpoint, chip::Comman
emberAfOnOffClusterLevelControlEffectCallback(endpoint, newValue);
}
else
{
#endif
{
// write the new on/off value
status = Attributes::OnOff::Set(endpoint, newValue);
if (status != EMBER_ZCL_STATUS_SUCCESS)
{
emberAfOnOffClusterPrintln("ERR: writing on/off %x", status);
return status;
}
#ifdef EMBER_AF_PLUGIN_LEVEL_CONTROL

if (SupportsLightingApplications(endpoint))
{
emberAfOnOffClusterPrintln("Off completed. reset OnTime to 0");
Attributes::OnTime::Set(endpoint, 0); // Reset onTime
}
}
#endif
}

#ifdef EMBER_AF_PLUGIN_SCENES
Expand Down Expand Up @@ -382,7 +378,6 @@ bool OnOffServer::offWithEffectCommand(app::CommandHandler * commandObj, const a
#endif // EMBER_AF_PLUGIN_SCENES

OnOff::Attributes::GlobalSceneControl::Set(endpoint, false);
Attributes::OnTime::Set(endpoint, 0);
}

// Only apply effect if OnOff is on
Expand Down
4 changes: 2 additions & 2 deletions src/test_driver/linux-cirque/MobileDeviceTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,9 @@ def run_controller_test(self):
self.get_device_pretty_id(device_id)))
self.assertTrue(self.sequenceMatch(self.get_device_log(device_id).decode('utf-8'), [
"Received command for Endpoint=1 Cluster=0x0000_0006 Command=0x0000_0001",
"Toggle on/off from 0 to 1",
"Toggle ep1 on/off from state 0 to 1",
"Received command for Endpoint=1 Cluster=0x0000_0006 Command=0x0000_0000",
"Toggle on/off from 1 to 0",
"Toggle ep1 on/off from state 1 to 0",
"No command 0x0000_0001 in Cluster 0x0000_0006 on Endpoint 0xe9"]),
"Datamodel test failed: cannot find matching string from device {}".format(device_id))

Expand Down