Mqtt light and json

Hi!
still pretty new to HA, I hope, this question is not already answered (I could not find anything tough).
After successfully setting up some milights using mqtt, I am now trying to setup a more comlpex light (esp-rgbww from fhem) in HA.
But I am a little bit lost.
This controller wants to get a json message like this:

{
    "jsonrpc": "2.0",
    "method": "color",
    "params": {
        "t": 700,
        "d": "1",
        "cmd": "fade",
        "hsv": {
            "s": 55,
            "h": 0,
            "v": 0
        },
        "q": "single"
    }
}

where h, s and v are the most interesting parts of the story.
(To turn it off, v has to be 0, as there seems to be no off command).
Could please anyone give me a hint how to tell HA to send a json message like that while setting H, S and V correctly?
Best regards and thanks in advance,
Otto

I don’t know how you’ll be sending this (e.g. publishing the message yourself to your broker), but this would be the general pattern in a template:

{% set d = {"foo": "bar", "bas": -1} %}
{{ d | to_json }}

Depending how you’ll be using this, e.g. if you will have the same basic structure for different commands, and need to parameterise some keys, a Jinja macro would be useful.

thanks, but I do not understand a word :frowning:

First elaborate on this. Did you install an HA integration?

Damn. it was not milight, but homematic which is connected to fhem and communicating with HA using mqtt.
definition in HA:

  - name: "wz_panel_ofen"
    unique_id: wz_panel_ofen
    state_topic: "fhem/wz_panel_ofen/state"
    command_topic: "fhem/wz_panel_ofen/set/state"
    brightness_state_topic: "fhem/wz_panel_ofen/pct"
    brightness_command_topic: "fhem/wz_panel_ofen/set/pct"
    brightness_scale: 100
    on_command_type: "brightness"
    qos: 0
    payload_on: "on"
    payload_off: "off"
    optimistic: false

These are pretty simple commands, now I would like to integrate those more complicated LED controllers…
Best regards and thanks in advance,
Otto

Publish your JSON payload using the mqtt.publish service.

thanks, but I do not only want to publish - HA should recognize this as a light with RGB?

no one? :frowning: