cgiesche/streamdeck-homeassistant

Change color temp of bulbs with rotation?

Closed this issue · 2 comments

I am trying to adjust the color temp of my Hue bulbs with rotation but cannot get it working correctly. Is it possible? I may be interpreting how this plugin works but if I use "Kelvin", rotationAbsolute is only a number between 0 and 255 and rotationPercent is 0-100%, does it not work because Kelvin is a range of numbers that do not fit for these categories?

With a bit of Math-Foo it works (for me with my hue lights):
Service Data for "Turn On" Service:

{% set min = 2200 %}
{% set max = 6535 %}
{
"kelvin": {{ min + rotationAbsolute * ((max - min) / 255) }}
}

min = Minimum color temp supported by bulb
max = Maximum color temp supported by bulb

You can validate all values and the outcome with custom labels:



{{min_color_temp_kelvin}}-{{max_color_temp_kelvin}}
{{color_temp_kelvin}}

grafik


Bonus:
You can create nice "bright cold to dim warm" effects, too:

{% set min = 2200 %}
{% set max = 4000 %}
{
"kelvin": {{ min + rotationAbsolute * ((max - min) / 255) }},
"brightness": {{ rotationAbsolute }}
}

With a bit of Math-Foo it works (for me with my hue lights): Service Data for "Turn On" Service:

{% set min = 2200 %}
{% set max = 6535 %}
{
"kelvin": {{ min + rotationAbsolute * ((max - min) / 255) }}
}

min = Minimum color temp supported by bulb max = Maximum color temp supported by bulb

You can validate all values and the outcome with custom labels:



{{min_color_temp_kelvin}}-{{max_color_temp_kelvin}}
{{color_temp_kelvin}}

grafik

Bonus: You can create nice "bright cold to dim warm" effects, too:

{% set min = 2200 %}
{% set max = 4000 %}
{
"kelvin": {{ min + rotationAbsolute * ((max - min) / 255) }},
"brightness": {{ rotationAbsolute }}
}

WOW! Thank you! Works great! That's way above my Math-Foo level...