Setting color_temp in automations

Heya! I’m new to HASS. I am banging my head against the wall here.

What I want:
To set my tuya integrated LED lightstrip on in the morning with a specific brightness and color temp.

I have tried using both service and device, but home assistant complains that “color_temp” is not available in automations. Why!?! I also attempted kelvin, rgb color, all same complaint. I used dev. tools to call the service, and I can change the temp using color_temp no problem. Why does HASS not allow color temp in automations, but works fine in scenes? This is very confusing to a newbie.

Thanks for any insights. Spencer

Hi there… It would be helpful if you could share the automation yaml so that we can make modifications for you. For this just copy the automation yaml and then paste it here between ``` symbol.

Of course, my bad:

- id: '1610722727893'
  alias: Under Cabinet lights - workout days - On
  description: ''
  trigger:
  - platform: time
    at: 05:40
  condition:
  - condition: time
    weekday:
    - mon
    - wed
    - fri
  action:
  - type: turn_on
    device_id: f335f8eab5298ad113dab669327403bd
    entity_id: light.21700715d8bfc00aeb3c
    domain: light
    brightness_pct: 25
  mode: single

Try this with your value for color_temp

- id: '1610722727893'
  alias: Under Cabinet lights - workout days - On
  description: ''
  trigger:
  - platform: time
    at: 05:40
  condition:
  - condition: time
    weekday:
    - mon
    - wed
    - fri
  action:
  - service: light.turn_on
    data:
      brightness_pct: 25
      color_temp: 250
    entity_id: light.21700715d8bfc00aeb3c
  mode: single
3 Likes

That’s totally done it, thank you a million times over. Can you give me the reason why? I see you switched it to a service, but I see entity_id at the end? This is a bit confusing… like in normal human language you would call what device, then action, the attributes, I don’t get why order is so specific here.

From my experience I have seen that calling services have been easy than assigning devices. Its similar to devices action but in devices we have to select domains and the type and all which again calls the service under that domain. In the method we are clearly defining the service which we want to use i,e light.turn_on. Then instead of device_id we have to define the entity_id i,e light.21700715d8bfc00aeb3c and later the parameters to use with this service. You can get a better understanding of this in the service tab in the developer console

1 Like

Thanks a bunch. Next issue: The tuya (smart life) app has scenes/effects in the app. I can’t seem to pull them into hass. I manually defined the effects in customize.yaml as such:

customize.yaml

light.21700715d8bfc00aeb3c:
  supported_features: 63
  name: "Under Cabinet Light"
  effect: true
  effect_list:
  - Dazzling
  - Soft
  - Colorful
  - Gorgeous
  - Night
  - Read
  - Working
  - Leisure

Did you use the tuya integration or any other method to integrate light?

Yes to tuya integration (official one)

In that case ,the above configuration wont work. Can you share the state_attributes of the entity in the device console.

min_mireds: 153
max_mireds: 370
brightness: 330
color_temp: 370
hs_color:
  - 0
  - 0
rgb_color:
  - 255
  - 255
  - 255
xy_color:
  - 0.323
  - 0.329
friendly_name: Under Cabinet Lights
supported_features: 63
name: Under Cabinet Light
effect: true
effect_list:
  - Dazzling
  - Soft
  - Colorful
  - Gorgeous
  - Night
  - Read
  - Working
  - Leisure
1 Like

You can call effects like this in automation.

- id: '1610722727893'
  alias: Under Cabinet lights - workout days - On
  description: ''
  trigger:
  - platform: time
    at: 05:40
  condition:
  - condition: time
    weekday:
    - mon
    - wed
    - fri
  action:
  - service: light.turn_on
    data:
      effect: Gorgeous
    entity_id: light.21700715d8bfc00aeb3c
  mode: single

I have tried to do the same thing. I choose to edit YAML in the automations screen and add the following:

alias: Patio LED On
description: ''
trigger:
  - platform: sun
    event: sunset
    offset: '-10'
condition: []
action:
  - service: light.turn_on
    data:
      brightness_pct: 50
      color_temp: 250
    entity_id: light.patio_led_0
  mode: single

It allows me to save but it I go back in it changes back to:

alias: Patio LED On
description: ''
trigger:
  - platform: sun
    event: sunset
    offset: '-10'
condition: []
action:
  - type: turn_on
    device_id: 91a2484f2efb61967840b6ce5466b36f
    entity_id: light.patio_led_0
    domain: light
    brightness_pct: 50
mode: single

I am trying to set a colour temperature value for the light when it is turned on at sunset.

This worked:

alias: Patio LED On
description: 'Turn on patio downlight  at sunset'
trigger:
  - platform: sun
    event: sunset
    offset: '-5'
condition: []
action:
  - service: light.turn_on
    entity_id: light.patio_led_0
    data_template:
      color_temp: 255
      brightness_pct: 75
mode: single

Hi,

I’m trying to send color_temp value to TUYA RGB led which based on MQTT payload. what am I doing wrong here

- id: '1664550250537'
  alias: White
  description: Sending RGB code
  trigger:
  - platform: mqtt
    topic: house/rgb_balcony_projector_color
    value_template: '{{ ((153 + trigger.payload | int * 347 / 100 }}'
  condition: []
  action:
  - service: light.turn_on
    data:
      rgb_color: 'value_template'
    entity_id: light.smart_bulb_600hz
    metadata: {}
  mode: single```
1 Like