Skip to content

Commit

Permalink
Smoke/CO: Update the handling of DeviceMuted
Browse files Browse the repository at this point in the history
Cannot mute when critical alarms exist
  • Loading branch information
hare-siterwell committed Jun 30, 2023
1 parent 50907e1 commit de38446
Showing 1 changed file with 52 additions and 1 deletion.
53 changes: 52 additions & 1 deletion src/app/clusters/smoke-co-alarm-server/smoke-co-alarm-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,58 @@ bool SmokeCoAlarmServer::SetDeviceMuted(EndpointId endpointId, MuteStateEnum new

if (success && (deviceMuted != newDeviceMuted))
{
success = SetAttribute(endpointId, Attributes::DeviceMuted::Id, Attributes::DeviceMuted::Set, newDeviceMuted);
if (newDeviceMuted == MuteStateEnum::kMuted)
{
AlarmStateEnum alarmState;
success = GetAttribute(endpointId, Attributes::SmokeState::Id, Attributes::SmokeState::Get, alarmState);
if (success && (alarmState == AlarmStateEnum::kCritical))
{
success = false;
}

if (success)
{
success = GetAttribute(endpointId, Attributes::COState::Id, Attributes::COState::Get, alarmState);
if (success && (alarmState == AlarmStateEnum::kCritical))
{
success = false;
}
}

if (success)
{
success = GetAttribute(endpointId, Attributes::BatteryAlert::Id, Attributes::BatteryAlert::Get, alarmState);
if (success && (alarmState == AlarmStateEnum::kCritical))
{
success = false;
}
}

if (success)
{
success = GetAttribute(endpointId, Attributes::InterconnectSmokeAlarm::Id, Attributes::InterconnectSmokeAlarm::Get,
alarmState);
if (success && (alarmState == AlarmStateEnum::kCritical))
{
success = false;
}
}

if (success)
{
success =
GetAttribute(endpointId, Attributes::InterconnectCOAlarm::Id, Attributes::InterconnectCOAlarm::Get, alarmState);
if (success && (alarmState == AlarmStateEnum::kCritical))
{
success = false;
}
}
}

if (success)
{
success = SetAttribute(endpointId, Attributes::DeviceMuted::Id, Attributes::DeviceMuted::Set, newDeviceMuted);
}

if (success)
{
Expand Down

0 comments on commit de38446

Please sign in to comment.