esphome / feature-requests

ESPHome Feature Request Tracker
https://esphome.io/
417 stars 26 forks source link

Enable relative color temperature changing #873

Open Icexist opened 4 years ago

Icexist commented 4 years ago

Describe the problem you have/What new integration you would like

I would like to be able to set color temperature relative to the current color temperature of a light. Currently, you can set relative brightness using light.dim_relative but to do the same with color temperature, you need to use a lambda.

Two possible paths:

  1. Enable something like id(light).color_temperature as a lambda call. This would avoid the use of a global variable to track color temp.
  2. Add a method to light that is light.temp_relative that works the same as light.dim_relative but for color temperature. The color temp would be changed relative to the defined cold and warm temperatures.

Please describe your use case for this integration and alternatives you've tried:

Current method:

light:
  - platform: cwww
    name: "lights"
    id: lightstrip
    cold_white: pwm_cw
    warm_white: pwm_ww
    cold_white_color_temperature: 6500 K
    warm_white_color_temperature: 3000 K

globals:
  - id: current_color_temp
    type: float
    restore_value: yes
    initial_value: '222.2' #'0.4285' #4500K
  - id: color_step_constant
    type: float
    initial_value: '34.8'

binary_sensor:
  - platform: remote_receiver
    id: "ktemp_up"
    nec:
      address: 0x00FF
      command: 0xC23D
    on_press:
      then:
        - light.turn_on:
            id: vlightstrip
            color_temperature: !lambda |-
              id(current_color_temp) = constrain(id(current_color_temp) + id(color_step_constant), 153.85, 333.33);
              return id(current_color_temp);

Desired future method:

light:
  - platform: cwww
    name: "lights"
    id: lightstrip
    cold_white: pwm_cw
    warm_white: pwm_ww
    cold_white_color_temperature: 6500 K
    warm_white_color_temperature: 3000 K

binary_sensor:
  - platform: remote_receiver
    id: "ktemp_up"
    nec:
      address: 0x00FF
      command: 0xC23D
    on_press:
      then:
        - light.temp_relative:
            id: lightstrip
            relative_temperature: 10% #Percent increase based on color temp boundaries

Additional context

Blue-Beaker commented 2 years ago

I would suggest add an light.control_relative function that can change the state of a light relatively, along with the id(light).color_temperature lambda call and hue/saturation controls for RGB lights.
light.control_relative will support exact same option of light.control, but any color/brightness/colortemp/hue/saturation values are added to the existing values instead of overwriting them.

BugerDread commented 5 months ago

Relative control of color temp for white and also for color of the rgb light will be nice, it will be easy to implement remote control of these with + and - buttons.