Using Zigbee2MQTT action data for RGB LED control automation

Firstly, I have to say that I am fairly new to home assistant and especially new to Zigbee2MQTT, so I’m not even sure if I’m using the correct vocabulary here.

I have successfully connected a Paulmann 501.40 RGBW-CCT remote control and a MiBoxer FUT039Z RGBW-CCT LED controller via Zigbee2MQTT in my home assistant instance and I have managed to create automations for some basic functions like turning the LED strip on and off, changing brightness and the color temperature, which was easy enough by just reading the Z2M documentation of both devices; for example, the automation for increasing the color temperature is triggered by the color_temperature_step_up action of the remote and it publishes the color_temp_step payload:

alias: WZ RGBW Remote Temp Up
description: ""
triggers:
  - domain: mqtt
    device_id: 61a4e7a4f6476f8e8b40d03567bcbc1c
    type: action
    subtype: color_temperature_step_up_1
    trigger: device
conditions: []
actions:
  - action: mqtt.publish
    metadata: {}
    data:
      evaluate_payload: false
      qos: "0"
      retain: false
      topic: zigbee2mqtt/WZ RGBW CCT/set
      payload: "{\"color_temp_step\": \"87\"}"
mode: single

So far so good and now my next goal is to create an automation for the “rainbow ring” that would set the color of the LED strip, but I am completely lost here. According to the Z2M documentation of the remote, a click on the “rainbow ring” triggers the move_to_hue_and_saturation action and if I monitor the “State” of the remote in the Z2M integration in home assistant, I can see that after a press on the rainbow ring the action as well as the corresponding hue and saturation values are listed here:

{
    "battery": 100,
    "linkquality": 192,
    "action": "move_to_hue_and_saturation_1",
    "action_hue": 19,
    "action_saturation": 254,
    "action_transition_time": 0
}

Then, according to the Z2M documentation of the controller, I can change the color by sending a message with a payload of either color_xy or color. My problem is now: how can I read the action_hue and action_saturation values in my automation, so I that I can convert them to either XY or RGB color for the payload to be send to the controller? I couldn’t find any useful anything useful in the documentation of the MQTT trigger or the automation actions that would tell me how I can read out those parameters/attributes/variables/data or whatever the correct term is for the action_hue and action_saturation values.

I have created a simple automation that simply dumps the entire trigger entity into a notification in the hope that it would give me some additional insights about the data I have received from the action as follows

alias: WZ RGBW Remote Hue & Sat
description: ""
triggers:
  - domain: mqtt
    device_id: 61a4e7a4f6476f8e8b40d03567bcbc1c
    type: action
    subtype: move_to_hue_and_saturation_1
    trigger: device
conditions: []
actions:
  - action: persistent_notification.create
    metadata: {}
    data:
      message: "\"{{trigger}}\""
mode: single

but all that I get from this is

"{'id': '0', 'idx': '0', 'alias': None, 'platform': 'mqtt', 'topic': 'zigbee2mqtt/WZ RGBW Remote/action', 'payload': 'move_to_hue_and_saturation_1', 'qos': 0, 'description': 'mqtt topic zigbee2mqtt/WZ RGBW Remote/action'}"

which does not contain the action_hue and action_saturation values that I am looking for.

I am at a total loss here and I hope that somebody can help me out here. Thanks in advance.

Hi,

You’re actually very close. The reason you’re not seeing action_hue and action_saturation in your automation is because the device trigger only passes the action name (e.g. move_to_hue_and_saturation_1), not the full JSON payload.

Instead of using a device trigger, switch to a raw MQTT trigger and listen directly to the topic:

zigbee2mqtt/WZ RGBW Remote

That topic publishes the full JSON payload, including:

action_hue
action_saturation
action_transition_time

Then inside your automation, you can access the values like this:

{{ trigger.payload_json.action_hue }}
{{ trigger.payload_json.action_saturation }}

From there, you can either:

  • Send them directly if your controller supports HS color
  • Or convert them to RGB/XY using a template before publishing

Example action:

payload: >
{
“color”: {
“hue”: {{ trigger.payload_json.action_hue }},
“saturation”: {{ trigger.payload_json.action_saturation }}
}
}

That should allow your “rainbow ring” to control the strip properly.

If you’re looking for more detailed template examples and conversion logic, I found some helpful answers that walk through working with MQTT payloads and dynamic variables in automations.

Hope that helps, you’re definitely on the right track!

Ah, thanks, that did the trick. I was expecting to receive the values that I was looking for in the JSON payload, but that one was empty when I used the device trigger, but using the MQTT trigger as you suggested publishes these values. I still have to do some HS to RGB or XY conversion as the controller does not support HS, but that should be a simple problem to solve now.