Send Device Command: JSON payload

The send device command box in device debug screen /applications/app-id/devices/device-id/debug is currently only capable of sending string payloads.

Even if I enter a JSON payload,
send device command
it is sent as string:

This leads to difficulty in debugging an Arduino firmware that processes commands, because the MQTT library assumes payload is always a JSON object.

I’d suggest an option in send device command box. Specifically, a row of radio buttons should be added under payload textarea:

Payload type (*) auto detect ( ) JSON ( ) string

The default selection is auto detect, which would send the payload as JSON if it parses as valid JSON, and send the payload as string otherwise. When the payload textarea loses focus, the text “auto detect” becomes either “auto detect (JSON)” or “auto detect (string)” to reflect what’s detected. If user selects “JSON”, the “send command” button should be disabled until the payload is valid JSON. If user selects “string”, JSON syntax highlighting should be deactivated.

This is an interesting issue. Looks like we have mixxed opinions around command format. Our intention is to allow any arbitrary data, but then we assume JSON in all of our mqtt libraries. I’m not sure if the correct fix is within the workflow editor or to add the ability to remove the auto-parsing from the libraries. I’ll think on this a little and discuss with the team.

We used to be stricter in our validation of command payloads here (as well as in the input controls dashboard block) where we only allowed JSON, but we removed that requirement to allow for string payloads.

I’m rolling out a change today that will send the payload as JSON if the input successfully parses into a JSON object; otherwise the payload will be sent as a string. That change should be out in the next couple hours.

Device command box now allows for strings, and the payload is sent as an object if the input parses to JSON successfully.

Input controls blocks only allow JSON payloads for the moment.