Sending a Command from an Experience WorkFlow to the device connected by RESTful

Hi Losant Team,

I am looking for the best approach how to send a command to the device from the experience workflow.

The device is connected by RESTful API therefore, using Device Command node does not seem to be an option (or not?). Another option I would consider is triggering an application workflow with a command logic from the experience workflow, but it is not supported.

I would like to avoid having HTTP nodes+supporting logic for a command inside of my experience workflow. Is there a way to implement it nicely in Losant?

Thank you in advance for your reply.

Hi @Alexander_Kondrov,

I believe the Device Command Node should be an option as long as the device is authorized. The documentation for the Device Command Node can be found here, and the Send Command action can be found here. Have you attempted to send a command from a workflow? If so, have you run into any documentable errors or issues, or has nothing been received by your device?

Thanks!
Julia

Hi Julia,

Thank you for your response. I am still confused. I tried to send a command through the Device Send Command. The value was shown on device’s payload in Devices, but my device is not MQTT connected device. Therefore, I don’t see any usage of that values being “sent” using this approach.

The device is connected by RESTful. In other words, the command format is RESTful post request and it has to follow a specific pattern including authentication defined by the device. Can Device Command Node send restful requests of the pre-defined format?

Hi @Alexander_Kondrov,

My apologies, thank you for the clarification. I am interpreting this to mean the command is displaying as sending from Losant, but the device does not handle these commands as expected or hoped.

When utilizing the REST API, you have two options:

  1. If you want Losant-triggered Commands accessible to the device full-time, you could use the Command Stream, as it utilizes server-sent events.
  2. If you are interested in obtaining data periodically, you could use the Get Command REST action.

I am curious, what is the configuration of the “pre-defined command format”? Given that the command payload type is configurable, it should be easy to configure to the correct format.

Thanks!
Julia

1 Like

Julia,

Thank you for your response. Basically, I know how to send command and read Status with HTTP Node, my concern was how to split Experience and Application workflows but keep a channel for device management commands sent (by an user) from the experience to application workflows.

At the same time Losant API Node: Device Command Stream looks as something that I may potentially utilize. In terms of using Device: Command node in the Experience workflow and this API Node in the application workflow to catch a moment when a command sent, the command itself and the device ID. At the same time this Device Command Stream requires specification of a particular device ID. What if I want to organize a control of a set of devices? Is there the same Device Command Stream but based on Device Tags?

So, one thing that you can do to communicate between application and experience workflows is to use MQTT. You can subscribe to an arbitrary MQTT topic using the MQTT Trigger, and publish using the MQTT Output Node. Along with the Workflow Trigger Node, this technique is a great way to facilitate workflow to workflow communication.

Just backing up a bit, I can also clarify a couple of things. One, Julia’s recommendation for the command stream was for your device, not within a workflow. It was in response to here:

Yes, you can use the Device Command Node using REST. Your device would just have to be listening to the Device Comand Streaming Endpoint using HTTP. The other option is polling.

At this time no, this is something that we are thinking about. I’ll add your request in :slight_smile:

I hope this clears up somethings! I’m happy to answer more questions.