Fix off-by-one in shade/group ID allocation

getNextShadeId() and getNextGroupId() capped usable IDs at
SOMFY_MAX_SHADES-1/SOMFY_MAX_GROUPS-1, so the top 2 shade IDs
(31, 32) and top 2 group IDs (15, 16) could never be allocated
even though the backing arrays support the full range.
This commit is contained in:
Frédéric Metrich 2026-09-05 22:27:33 +02:00
parent c7592162ec
commit db22c16bb3

View file

@ -4548,7 +4548,7 @@ uint8_t SomfyShadeController::getNextShadeId()
{
// There is no shortcut for this since the deletion of
// a shade in the middle makes all of this very difficult.
for (uint8_t i = 1; i < SOMFY_MAX_SHADES - 1; i++)
for (uint8_t i = 1; i <= SOMFY_MAX_SHADES; i++)
{
bool id_exists = false;
for (uint8_t j = 0; j < SOMFY_MAX_SHADES; j++)
@ -4599,7 +4599,7 @@ uint8_t SomfyShadeController::getNextGroupId()
{
// There is no shortcut for this since the deletion of
// a group in the middle makes all of this very difficult.
for (uint8_t i = 1; i < SOMFY_MAX_GROUPS - 1; i++)
for (uint8_t i = 1; i <= SOMFY_MAX_GROUPS; i++)
{
bool id_exists = false;
for (uint8_t j = 0; j < SOMFY_MAX_GROUPS; j++)