Set xy_color with a template value

Hi everyone.
I’m trying to integrate the various functions that the zigbee remote control has, and I’m stuck on some things.
I’ll explain:
The device in question is: https://www.zigbee2mqtt.io/devices/MLI-404011.html integratet with Zigbee2Mqtt, and works correctly.
When i press the color circle, in the log have the x and y value on color based, like:

zigbee2mqtt:info  2020-03-27 20:57:21: MQTT publish: topic 'zigbee2mqtt/Tint', payload '{"linkquality":70,"rate":100,"action_color":{"x":0.118,"y":0.197},"action":"color_wheel","transition_time":0}'

I have created a sensor to extract exactly the x and y values, like this:

sensor:
  - platform: "mqtt"
    name: Tint Remote XY
    state_topic: "zigbee2mqtt/Tint"
    availability_topic: "zigbee2mqtt/bridge/state"
    icon: "mdi:gesture-double-tap"
    value_template: '{{ value_json.action_color.x }},{{ value_json.action_color.y }}'

and everything is ok. I have the sensor.tint_remote_xy with the value 0.118,0.197
Now i want to use this sensor in the automation, like this:

automation:
- alias: Tint Ser Color Led strip TV
  trigger:
  - platform: mqtt
    topic: zigbee2mqtt/Tint
  action:
  - service: light.turn_on
    data_template:
      entity_id: light.led_tv
      brightness: 250
      xy_color: ['{{ states.sensor.tint_remote_xy.state }}']

but something goes wrong. The Automation triggered correctly but does not set the color. It works properly if i put:

xy_color: [0.118,0.197]

How to adjust this problem? thank you :slight_smile:

Try this:

xy_color:
- "{{ states('sensor.tint_remote_xy').split(',')[0] | float }}"
- "{{ states('sensor.tint_remote_xy').split(',')[1] | float }}"

Even though what you have looks like a list, it’s really a string.

2 Likes

Thanks.
As in your example, it works. But some time ago remember i doing differently, all in a row as in my example. It could be? or you don’t know any other solution? Anyway, thank you so much for the solution.

Is this possible to do the same for Color temperature ?