-
-
Save HarvsG/cc86381dc99169159d6d4cd870c36e46 to your computer and use it in GitHub Desktop.
| blueprint: | |
| name: Match Outside Colour Temperature Kelvin | |
| description: When a light turns on or the sun elevation changes, match the outside | |
| colour temperature. It will apply to any bulb that supports color temperature. | |
| It triggers; whenever a bulb turns on, on sun elevation changes and every 5 minutes. | |
| domain: automation | |
| input: | |
| target_lights: | |
| name: Lights | |
| description: The primary lights to be controlled | |
| selector: | |
| entity: | |
| domain: light | |
| multiple: true | |
| min_color_temp: | |
| name: Coolest Color Temperature | |
| description: The most blue color your bulbs will be set to | |
| default: 4000 | |
| selector: | |
| color_temp: | |
| min: 1500 | |
| max: 7000 | |
| unit: kelvin | |
| max_color_temp: | |
| name: Warmest Color Temperature | |
| description: The most yellow color your bulbs will be set to | |
| default: 2202 | |
| selector: | |
| color_temp: | |
| min: 1500 | |
| max: 7000 | |
| unit: kelvin | |
| brightness_action: | |
| name: Brightness | |
| description: When a device turns on its color temperature will be set, this | |
| may interfere with the brightness, this action will run half a second later | |
| to set the light's brightness. | |
| selector: | |
| action: {} | |
| default: | |
| - service: light.turn_on | |
| data: | |
| brightness: '{{max(trigger.to_state.attributes.brightness,2)}}' | |
| target: | |
| entity_id: '{{trigger.entity_id}}' | |
| alias: Default - Set light to its original brightness, don't use brightness | |
| 1 as it causes issues with some bulbs | |
| source_url: https://gist.github.com/HarvsG/cc86381dc99169159d6d4cd870c36e46 | |
| variables: | |
| target_lights: !input target_lights | |
| target_on_lights: '{{states.light | selectattr(''state'',''eq'',''on'') | selectattr(''attributes.supported_color_modes'',''match'',".*color_temp.*") | |
| | map(attribute=''entity_id'') | select("in",target_lights) | list }}' | |
| min_color_temp: !input min_color_temp | |
| max_color_temp: !input max_color_temp | |
| color_temp: '{{ [([(((4791.67 - 3290.66/(1 + 0.222 * ([([0,state_attr(''sun.sun'', | |
| ''elevation'')]|max),90]|min**0.81))))|int),max_color_temp]|max),min_color_temp]|min}}' | |
| trigger: | |
| - platform: state | |
| entity_id: !input target_lights | |
| to: 'on' | |
| id: single_light_on | |
| - platform: state | |
| entity_id: | |
| - sun.sun | |
| attribute: elevation | |
| id: elevation_change | |
| - platform: time_pattern | |
| minutes: '5' | |
| id: every_5_min | |
| condition: | |
| - condition: template | |
| value_template: '{{ (states.light | selectattr(''state'',''eq'',''on'') | map(attribute=''entity_id'') | |
| | list)!= [] }}' | |
| action: | |
| - choose: | |
| - conditions: | |
| - condition: trigger | |
| id: single_light_on | |
| sequence: | |
| - service: light.turn_on | |
| data: | |
| color_temp_kelvin: '{{color_temp}}' | |
| target: | |
| entity_id: '{{trigger.entity_id}}' | |
| - delay: | |
| milliseconds: 500 | |
| - choose: | |
| default: !input brightness_action | |
| - conditions: | |
| - condition: or | |
| conditions: | |
| - condition: trigger | |
| id: every_5_min | |
| - condition: trigger | |
| id: elevation_change | |
| sequence: | |
| - service: light.turn_on | |
| data: | |
| color_temp_kelvin: '{{color_temp}}' | |
| transition: 5 | |
| target: | |
| entity_id: '{{target_on_lights}}' | |
| mode: parallel |
Yes this is vestigial from when home assistant used Mireds which is the inverse of Kelvin.
It also results for the colour temperature paradox which is that high temperature whites are often described as 'cool' and low Kelvin temperature whites are described as 'warm'.
I'm getting this error with a recent version of home-assistant:
WARNING (MainThread) [homeassistant.components.light] Got `kelvin` argument in `turn_on` service, which is deprecated and will break in Home Assistant 2026.1, please use `color_temp_kelvin` argument
Sounds like the data: kelvin: needs to be changed to color_temp_kelvin?
This is a great and simple. Some of the circadian lighting integrations seem overly complicated to me.
Is there a way to limit the timing of this? For example, don't turn on until 8am and turn off at 5pm. It wouldn't have to adjust the light color to those times at all, just not turn on unless its between those times.
Seems like a simple condition could be added. I'll work on it a little, but I'm pretty new to HA.
I'm not sure what you mean by "not turn on" this automation shouldn't turn on lights - only change the colour temperature of lights already on or that have just turned on.
If you mean you only want the automation to operate between the hours of 8am and 5pm then simply create another automation that disables and enables this automation at those times
Or you can "Take control" of this blueprint and change the logic to your delight https://www.home-assistant.io/docs/automation/using_blueprints/#editing-an-imported-blueprint


Thanks a lot for sharing this work!
min_color_tempandmax_color_tempshould probably be named the other way around, since "the most blue" colour has a higher colour temperature. With the naming as is, this line is hard to digest:color_temp: '{{ [([(((4791.67 - 3290.66/(1 + 0.222 * ([([0,state_attr(''sun.sun'', ''elevation'')]|max),90]|min**0.81))))|int),max_color_temp]|max),min_color_temp]|min}}'[<calculation>, max_color_temp]|maxwould allow setting temperature to higher thanmax_color_temp, which doesn't make sense. The same for min.