If color, else color_temp

Hi, I’m stuck getting this automation to work.

essentially, if “color” is a color (eg, the word red, or orange, etc), then use the color_name field, but if “color” is “white”, then use the color_temp filed with an integer, ie 256. how can I vary the data field in use, based on the color?

action:
- service: light.turn_on
  data: 
    area_id: "{{name}}"
    color_name: "{{color}}"

thanks so much

action:
  - if: "{{ color == 'white' }}"
    then:
      - service: light.turn_on
        data: 
          color_temp: 256
        target:
          area_id: "{{name}}"
    else:
      - service: light.turn_on
        data: 
          color_name: "{{color}}"
        target:
          area_id: "{{name}}"
1 Like

Thank you so much!

1 Like

You’re welcome!

Please consider marking my post above with the Solution tag. It will automatically place a check-mark next to the topic’s title which signals to other users that this topic has been resolved. This helps users find answers to similar questions.

For more information about the Solution tag, refer to guideline 21 in the FAQ.

Done, thanks again