Automating Color Temperature with a Sensor: My Experience

Hey everyone, I wanted to share my recent project where I automated the color temperature of all my lights using a sensor. It’s been a fun challenge and I’m really happy with the results!

I started by creating a sensor that calculates color temperature based on an input number ranging from 1 to 255. The sensor uses a value template to convert the input into Kelvin, ensuring it stays within a comfortable range of 2000 to 6500. Here’s a quick look at the setup:

yaml
brightness_kelvin:
friendly_name: Brightness Kelvin
unit_of_measurement: “K”
value_template: “{{ min(6500, max(2000, ((states(‘input_number.brightness’) | int * 20) + 1680))) }}”

The next step was figuring out how to apply this sensor to all my lights. I initially thought about using automations triggered when a light is turned on, but I ran into an issue where the light’s existing color temperature would override my sensor value. After some research and trial and error, I found a solution by modifying the light’s configuration in my YAML file to reference the sensor directly. This way, whenever a light is turned on, it automatically uses the calculated color temperature from the sensor.

This setup has completely transformed my lighting experience. Now, whether I’m relaxing in the evening or need a brighter environment during the day, my lights adjust seamlessly without any manual intervention. It’s been a great way to enhance my home’s comfort and efficiency.

I’m curious to hear if anyone else has tackled a similar project or has tips for improving this setup. Let’s keep the conversation going and share our smart home automation experiences!

Cheers,
[Your Name]