From db22c16bb33b70ac79831af6e51ef80268c98ef2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Metrich?= Date: Sat, 5 Sep 2026 22:27:33 +0200 Subject: [PATCH] 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. --- Somfy.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Somfy.cpp b/Somfy.cpp index 18f9693..3fdf593 100644 --- a/Somfy.cpp +++ b/Somfy.cpp @@ -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++)