From 0d0de08e197ea82c42a4cb151eb6bc4abe692383 Mon Sep 17 00:00:00 2001 From: Edward Firmo <94725493+edwardtfn@users.noreply.github.com> Date: Wed, 6 Aug 2025 19:21:32 +0200 Subject: [PATCH] Ensure brightness is limited to 100 As suggested by coderabbitai. --- components/tx_ultimate_easy/tx_ultimate_easy_light.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/tx_ultimate_easy/tx_ultimate_easy_light.cpp b/components/tx_ultimate_easy/tx_ultimate_easy_light.cpp index ea1e61a..c6e0123 100644 --- a/components/tx_ultimate_easy/tx_ultimate_easy_light.cpp +++ b/components/tx_ultimate_easy/tx_ultimate_easy_light.cpp @@ -20,7 +20,7 @@ namespace esphome { // Function implementations uint32_t pack_light_attributes(const LightAttributes& attr) { - return (uint32_t(attr.brightness) << 24) | + return (uint32_t(std::min(attr.brightness, uint8_t(100))) << 24) | (uint32_t(attr.red) << 16) | (uint32_t(attr.green) << 8) | (uint32_t(attr.blue)); @@ -28,7 +28,7 @@ namespace esphome { LightAttributes unpack_light_attributes(uint32_t packed) { return { - .brightness = uint8_t((packed >> 24) & 0xFF), + .brightness = std::min(uint8_t((packed >> 24) & 0xFF), uint8_t(100)), .red = uint8_t((packed >> 16) & 0xFF), .green = uint8_t((packed >> 8) & 0xFF), .blue = uint8_t(packed & 0xFF)