diff --git a/examples/dishwasher-app/silabs/src/ElectricalSensorManager.cpp b/examples/dishwasher-app/silabs/src/ElectricalSensorManager.cpp index c751c71c268255..cf7e4806a7828a 100644 --- a/examples/dishwasher-app/silabs/src/ElectricalSensorManager.cpp +++ b/examples/dishwasher-app/silabs/src/ElectricalSensorManager.cpp @@ -196,12 +196,12 @@ void ElectricalSensorManager::UpdateEPMAttributes(OperationalStateEnum state) { if (gEPMDelegate) { - uint16_t updateState = to_underlying(state); - uint16_t ERROR_STATE_INDEX = ArraySize(kAttributes) - 1; + uint8_t updateState = to_underlying(state); + // Check state range - if ((updateState < 0) || (updateState > ERROR_STATE_INDEX)) + if (updateState >= ArraySize(kAttributes)) { - updateState = ERROR_STATE_INDEX; + updateState = ArraySize(kAttributes) - 1; } ChipLogDetail(AppServer, "UpdateAllAttributes to Operational State : %d", updateState);