From e03922ef13d4a830ab69ebc732ab1a6ad613dbc8 Mon Sep 17 00:00:00 2001 From: Edward Firmo <94725493+edwardtfn@users.noreply.github.com> Date: Fri, 10 Nov 2023 07:24:40 +0100 Subject: [PATCH] Button - Light - Icon follows the light rgb color - Helps with #1184 - Helps with #935 --- nspanel_blueprint.yaml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/nspanel_blueprint.yaml b/nspanel_blueprint.yaml index 5a3bb2714..6fac5551c 100644 --- a/nspanel_blueprint.yaml +++ b/nspanel_blueprint.yaml @@ -7610,6 +7610,19 @@ action: btn_icon_font: > # Foreground color for icon {% if not current_entity_state_available %} {{ nextion.color.red }} + {% elif item_domain in ["light"] %} + {% set rgb_color = state_attr(repeat.item.entity, "rgb_color") | default(None) %} + {% set brightness = (state_attr(repeat.item.entity, "brightness") | int(255))/255 %} + {% set icon_color_raw = rgb_color | list if rgb_color is sequence else (nextion.color.on if entity_state in enum.states.on else nextion.color.off) %} + {{ + [ + min(255,icon_color_raw[0] * brightness) | round(0), + min(255,icon_color_raw[1] * brightness) | round(0), + min(255,icon_color_raw[2] * brightness) | round(0) + ] + if icon_color_raw is sequence and icon_color_raw | count == 3 + else icon_color_raw + }} {% elif current_entity_state in ["off", "closed", "closing"] or (item_domain == "person" and current_entity_state != "home") %} {{ nextion.color.grey_light }} {% elif item_domain in ["button", "input_button", "scene"] and trigger.id is match "current_state_entity" %}