[Solved] Send device command tot Particle.function from dashboard

particle

#1

I want to call a function on my Particle. I have verified that the function works via the Particle console. However, if i call the function from my Losant dashboard nothing happens. Anybody got an idea what i’m doing wrong?

This is my code on the Particle

int setTemp (String paramValue) {
tempSet = paramValue.toInt();
return 1;

This is my dashboard setup.


#2

Hey @justvervaart,

The “Send Device Command” option in the block will send an MQTT message to devices connected to Losant’s MQTT broker.

If you want to call a Particle Function within Losant, all you need to do is set up the Particle Integration and call the function within a workflow. In your case, you would choose the “Trigger Workflow” option instead.

For more background, here is a blog post about this topic: https://www.losant.com/blog/how-to-integrate-particle-with-losant

I hope this helps :smile:


#3

Thx. I will look into it.


#4

The blog was a big help. I think i’m almost there. I now have created a button and can trigger it, but it sends an empty result or so because the variable on the particle set by the function becomes 0.

I think i have to put something in the Argument Template, but i don’t know what… I want to transmit the value set on the dashboard by the slider temp-0.


#5

Sweet! Glad you’re making progress.

In the Input Control Block, when you select “Trigger Workflow” you can optionally give it a payload.

When you press the button from the dashboard, the information you put here will be in the payload when the workflow is triggered. It will live under the property called data.

For example, if you put this in the Input Control Settings:

{
  "temp": {{temp-0}}
}

You will be able to access this data under data.temp within the Workflow Engine.


#6

That was it! Thx for the help. I have got one more question if i may. Do you know how i can send multiple value’s in one payload, and more import, how to handle them in the particle code so i can call multiple functions or set multiple value’s in one go?