MQTT send json payload from dev panel

Hi

I’m trying to make some debug with my mqtt stuff, I can’t send basic commands/packets, but I want to send a json payload from mqtt dev panel.
Any thoughts?

image

I know how to send it from the service call, but I need to make some tests before:

image

not sure I understand your question. Are you struggling to send MQTT commands via the UI or via a service call in an automation/script?
In addition you’re giving 2 separate examples of commands. If you could confirm which one works and which one doesn’t, using the same command on both, then we could help you further?

I will clarify a bit: I want to publish MQTT packet with JSON payload from MQTT Dev Panel.

Thanks, can you share what you want to send?
Also have you tried another tool like mqtt.fx to see if you receive the packet?
From your screenshot I can’t see any issues, the payload is formatted correctly
The more details you provide, the easier it’ll be to help :slight_smile:

for example: {“Fade”: 1, “Speed”: 15}

My screenshots show correct payload, but nothing happening.

If I send it like this (not json formatted at all it does work)
image

not 100% how that would work, but the topic appears to be correct.
Have you tried a payload like {"ON", "Fade":"1", "Speed":"15"}?
Not sure if you need to add something in front of "ON" though,but I would defo add the quotes around the numbers for Fade and Speed

You suggested not json formatted payload and it’s - No, it doesn’t work.

Anyway, tried as you suggested - not working. Did some additional tests:

Worked:

Not worked:

Not worked:

Not worked:

You referred to light earlier on. Maybe you need the power command first to turn it on then the light command with the json load? Sorry I don’t use these devices so not sure what they expect to receive.
If you can send the message via an action, used something like mqtt.fx to see what is being sent

Yes, where is the documentation for the device you wish to control? I can review it and learn the expected format of the payload. Without that information, we’re just throwing stuff at the wall and hoping something sticks …

Is the device flashed with Tasmota?

yes, tasmota flashed tuya dimmer:

and here’s related commands:

Then it explains why publishing on to cmnd/salon/power works because, by default, Tasmota expects to receive a simple text-only command like on, off, or toggle and not a JSON-formatted dictionary like {"power":"on"}. In contrast, upon receiving a simple-text command, it will reply with a JSON dictionary.

where did you find this?

is there any way to send a json?
i want to add transitions to the states…

In the documentation link you posted.

can you please point on this, I can’t find it…

???

It’s listed in the first section (Commands) of How to Use Commands.

Hi Taras,

I believe @radinsky figured out how to turn his lights on/off and is looking to dim his lights on (using the Fade, Speed options):

I’ve not figured out how to send these parameters.

Apparently through trial and error, yet the Power command is documented (as are Fade and Speed). Each command has its own topic.

There’s nothing in the documentation to suggest it supports a ‘multi-command’ topic that can receive a payload containing a JSON dictionary.


EDIT
… and if it is in the documentation, then I am not seeing it. :man_shrugging:

Thanks. It’s not just me then. Still sounds odd that one would need to send 3 commands to achieve something as simple as a fade on, especially if there are delays on the network you could easily end up with a light fully on before it fades on?

I don’t use anything flashed with Tasmota, so I’m basing my answer on how other people configure their lights. Each one of the light’s properties is controlled by a unique command topic. Here’s an example from this thread where brightness, color and rgb are separate command topics:

ight:
  - platform: mqtt
    name: bookcase_light
    retain: true
    availability_topic: "tele/bookcase_light/LWT"
    payload_available: "Online"
    payload_not_available: "Offline"
    state_topic: "tele/bookcase_light/STATE"
    state_value_template: "{{ value_json.POWER }}"
    command_topic: "cmnd/bookcase_light/POWER"
    brightness_state_topic: "tele/bookcase_light/STATE"
    brightness_command_topic: "cmnd/bookcase_light/DIMMER"
    brightness_scale: 100
    brightness_value_template: "{{ value_json.Dimmer }}"
    color_temp_command_topic: "cmnd/bookcase_light/CT"
    color_temp_state_topic: "tele/bookcase_light/STATE"
    color_temp_value_template: "{{ value_json.CT }}"
    rgb_state_topic: "tele/bookcase_light/STATE"
    rgb_command_topic: "cmnd/bookcase_light/Color"
    rgb_command_template: "{{ '%02x%02x%02x' | format(red, green, blue)}}"
    rgb_value_template: "{{(value_json.Channel[0]*2.55)|int}},{{(value_json.Channel[1]*2.55)|int}},{{(value_json.Channel[2]*2.55)|int}}"
    optimistic: false
1 Like

Ok, I’ve tried to play with commands Fade and Speed, it does something but not the fade transition between states/brightness levels as I was looking for…

Attaching the log:


19:30:08 MQT: stat/salon/RESULT = {"POWER":"OFF"}
19:30:08 MQT: stat/salon/POWER = OFF
19:30:15 MQT: stat/salon/RESULT = {"POWER":"ON"}
19:30:15 MQT: stat/salon/POWER = ON
19:30:34 CMD: cmnd/salon/WakeupDuration 5
19:30:34 MQT: stat/salon/RESULT = {"WakeUpDuration":5}
19:31:09 MQT: stat/salon/RESULT = {"POWER":"OFF"}
19:31:09 MQT: stat/salon/POWER = OFF
19:31:17 MQT: stat/salon/RESULT = {"POWER":"ON"}
19:31:17 MQT: stat/salon/POWER = ON
19:32:18 CMD: cmnd/salon/Speed 10
19:32:18 MQT: stat/salon/RESULT = {"Speed":10}
19:36:25 CMD: cmnd/salon/Dimmer 50
19:36:25 MQT: stat/salon/RESULT = {"POWER":"ON","Dimmer":50}
19:36:39 CMD: cmnd/salon/Fade 1
19:36:39 MQT: stat/salon/RESULT = {"Fade":"ON"}
19:36:48 CMD: cmnd/salon/Dimmer 80
19:36:48 MQT: stat/salon/RESULT = {"POWER":"ON","Dimmer":80}
19:36:48 MQT: stat/salon/RESULT = {"POWER":"ON","Dimmer":50}
19:37:03 CMD: cmnd/salon/Speed 2
19:37:03 MQT: stat/salon/RESULT = {"Speed":2}
19:37:13 CMD: cmnd/salon/Dimmer 80
19:37:13 MQT: stat/salon/RESULT = {"POWER":"ON","Dimmer":80}
19:37:13 MQT: stat/salon/RESULT = {"POWER":"ON","Dimmer":58}
19:37:13 MQT: stat/salon/RESULT = {"POWER":"ON","Dimmer":64}
19:37:13 MQT: stat/salon/RESULT = {"POWER":"ON","Dimmer":62}
19:37:30 CMD: cmnd/salon/Dimmer 80
19:37:30 MQT: stat/salon/RESULT = {"POWER":"ON","Dimmer":80}
19:37:30 MQT: stat/salon/RESULT = {"POWER":"ON","Dimmer":67}
19:38:28 CMD: cmnd/salon/Dimmer -
19:38:28 MQT: stat/salon/RESULT = {"POWER":"ON","Dimmer":57}
19:38:28 MQT: stat/salon/RESULT = {"POWER":"ON","Dimmer":64}
19:38:37 CMD: cmnd/salon/Dimmer -
19:38:37 MQT: stat/salon/RESULT = {"POWER":"ON","Dimmer":54}
19:38:37 MQT: stat/salon/RESULT = {"POWER":"ON","Dimmer":61}
19:38:39 CMD: cmnd/salon/Dimmer -
19:38:39 MQT: stat/salon/RESULT = {"POWER":"ON","Dimmer":51}
19:38:39 MQT: stat/salon/RESULT = {"POWER":"ON","Dimmer":58}
19:38:39 MQT: stat/salon/RESULT = {"POWER":"ON","Dimmer":56}
19:38:40 CMD: cmnd/salon/Dimmer -
19:38:40 MQT: stat/salon/RESULT = {"POWER":"ON","Dimmer":46}
19:38:40 MQT: stat/salon/RESULT = {"POWER":"ON","Dimmer":53}
19:38:40 MQT: stat/salon/RESULT = {"POWER":"ON","Dimmer":51}
19:38:40 CMD: cmnd/salon/Dimmer -
19:38:40 MQT: stat/salon/RESULT = {"POWER":"ON","Dimmer":41}
19:38:40 MQT: stat/salon/RESULT = {"POWER":"ON","Dimmer":48}
19:38:41 MQT: stat/salon/RESULT = {"POWER":"ON","Dimmer":46}
19:38:41 CMD: cmnd/salon/Dimmer -
19:38:41 MQT: stat/salon/RESULT = {"POWER":"ON","Dimmer":36}
19:38:41 MQT: stat/salon/RESULT = {"POWER":"ON","Dimmer":43}
19:38:41 MQT: stat/salon/RESULT = {"POWER":"ON","Dimmer":41}
19:38:45 CMD: cmnd/salon/Dimmer +
19:38:45 MQT: stat/salon/RESULT = {"POWER":"ON","Dimmer":51}
19:38:45 MQT: stat/salon/RESULT = {"POWER":"ON","Dimmer":44}
19:38:52 CMD: cmnd/salon/Dimmer +
19:38:52 MQT: stat/salon/RESULT = {"POWER":"ON","Dimmer":54}
19:38:53 MQT: stat/salon/RESULT = {"POWER":"ON","Dimmer":47}
19:38:54 CMD: cmnd/salon/Dimmer +
19:38:54 MQT: stat/salon/RESULT = {"POWER":"ON","Dimmer":57}
19:38:54 MQT: stat/salon/RESULT = {"POWER":"ON","Dimmer":49}
19:38:54 MQT: stat/salon/RESULT = {"POWER":"ON","Dimmer":51}
19:38:55 CMD: cmnd/salon/Dimmer +
19:38:55 MQT: stat/salon/RESULT = {"POWER":"ON","Dimmer":61}
19:38:55 MQT: stat/salon/RESULT = {"POWER":"ON","Dimmer":54}
19:38:55 CMD: cmnd/salon/Dimmer +
19:38:55 MQT: stat/salon/RESULT = {"POWER":"ON","Dimmer":64}
19:38:56 MQT: stat/salon/RESULT = {"POWER":"ON","Dimmer":56}
19:38:56 CMD: cmnd/salon/Dimmer +
19:38:56 MQT: stat/salon/RESULT = {"POWER":"ON","Dimmer":66}
19:38:56 MQT: stat/salon/RESULT = {"POWER":"ON","Dimmer":58}
19:38:57 CMD: cmnd/salon/Dimmer +
19:38:57 MQT: stat/salon/RESULT = {"POWER":"ON","Dimmer":68}
19:38:57 MQT: stat/salon/RESULT = {"POWER":"ON","Dimmer":60}
19:38:58 CMD: cmnd/salon/Dimmer +
19:38:58 MQT: stat/salon/RESULT = {"POWER":"ON","Dimmer":70}
19:38:58 MQT: stat/salon/RESULT = {"POWER":"ON","Dimmer":63}
19:38:59 CMD: cmnd/salon/Dimmer +
19:38:59 MQT: stat/salon/RESULT = {"POWER":"ON","Dimmer":73}
19:38:59 MQT: stat/salon/RESULT = {"POWER":"ON","Dimmer":65}
19:38:59 CMD: cmnd/salon/Dimmer +
19:38:59 MQT: stat/salon/RESULT = {"POWER":"ON","Dimmer":75}
19:38:59 MQT: stat/salon/RESULT = {"POWER":"ON","Dimmer":67}
19:39:37 CMD: cmnd/salon/Speed 13
19:39:37 MQT: stat/salon/RESULT = {"Speed":13}
19:39:39 CMD: cmnd/salon/Dimmer +
19:39:39 MQT: stat/salon/RESULT = {"POWER":"ON","Dimmer":77}
19:39:39 MQT: stat/salon/RESULT = {"POWER":"ON","Dimmer":67}
19:39:40 CMD: cmnd/salon/Dimmer +
19:39:40 MQT: stat/salon/RESULT = {"POWER":"ON","Dimmer":77}
19:39:40 MQT: stat/salon/RESULT = {"POWER":"ON","Dimmer":67}
19:39:41 CMD: cmnd/salon/Dimmer +
19:39:41 MQT: stat/salon/RESULT = {"POWER":"ON","Dimmer":77}
19:39:41 MQT: stat/salon/RESULT = {"POWER":"ON","Dimmer":67}
19:39:44 CMD: cmnd/salon/Speed 0
19:39:44 MQT: stat/salon/RESULT = {"Speed":13}
19:39:47 CMD: cmnd/salon/Speed 1
19:39:47 MQT: stat/salon/RESULT = {"Speed":1}
19:39:50 CMD: cmnd/salon/Dimmer +
19:39:50 MQT: stat/salon/RESULT = {"POWER":"ON","Dimmer":77}
19:39:50 MQT: stat/salon/RESULT = {"POWER":"ON","Dimmer":72}
19:39:50 MQT: stat/salon/RESULT = {"POWER":"ON","Dimmer":75}
19:39:51 CMD: cmnd/salon/Dimmer +
19:39:51 MQT: stat/salon/RESULT = {"POWER":"ON","Dimmer":85}
19:39:51 MQT: stat/salon/RESULT = {"POWER":"ON","Dimmer":80}
19:39:51 MQT: stat/salon/RESULT = {"POWER":"ON","Dimmer":83}
19:39:52 CMD: cmnd/salon/Dimmer +
19:39:52 MQT: stat/salon/RESULT = {"POWER":"ON","Dimmer":93}
19:39:52 MQT: stat/salon/RESULT = {"POWER":"ON","Dimmer":88}
19:39:58 CMD: cmnd/salon/Fade 0
19:39:58 MQT: stat/salon/RESULT = {"Fade":"OFF"}
19:40:08 MQT: stat/salon/RESULT = {"POWER":"ON","Dimmer":70}
19:40:08 MQT: stat/salon/RESULT = {"POWER":"ON"}
19:40:08 MQT: stat/salon/POWER = ON
19:40:09 MQT: stat/salon/RESULT = {"POWER":"ON","Dimmer":98}
19:40:09 MQT: stat/salon/RESULT = {"POWER":"ON"}