From b05e43fcfb3e6ded842fcbeec60d6c479f76d2b8 Mon Sep 17 00:00:00 2001 From: peter Date: Sun, 24 Dec 2023 11:47:26 +0100 Subject: [PATCH] Silvercrest smart led string: make sure hue value is rounded to prevent color glitches --- src/lib/legacy.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/lib/legacy.ts b/src/lib/legacy.ts index cbd6bf4bf9c83..1109b84a4ee85 100644 --- a/src/lib/legacy.ts +++ b/src/lib/legacy.ts @@ -7998,12 +7998,10 @@ const toZigbee2 = { if (h) { // The device expects 0-359 - if (h >= 360) { - h = 359; - } - hsb.h = make4sizedString(h.toString(16)); + // The device expects a round number, otherwise everything breaks + hsb.h = make4sizedString(utils.numberWithinRange(utils.precisionRound(h, 0), 0, 359).toString(16)); } else if (state.color && state.color.h) { - hsb.h = make4sizedString(state.color.h.toString(16)); + hsb.h = make4sizedString(utils.numberWithinRange(utils.precisionRound(state.color.h, 0), 0, 359).toString(16)); } // Device expects 0-1000, saturation normally is 0-100 so we expect that from the user