[SOLVED] Switch on dashboard calls exposed function on Particle Photon


I have some exposed functions on a Particle Photon, such as:

Particle.function(“relay”, relayControl);

The documentation wants this to be called with a curl command like this:

curl https://api.particle.io/v1/devices/0123456789abcdef/relay
-d access_token=123412341234 -d params=r1,HIGH

Can I have a switch on the ubidots dashboard that calls that function? The documentation talks about doing a GET from the particle side, in the program loop, constantly checking for the state of a variable. However my loop is long, and I don’t want any delay. Is there a method that can call the exposed function directly, without having the photon constantly asking for an update?


Hi @vinistois!

Yes, you can have exactly that.
You can create a variable for the control of the switch, add a new “switch” widget in the dashboard which will change the value of the variable that you created previously. Finally, you add 2 events bound to the control variable, one is gonna activate when the value of the variable is equal to 1, select the option “WebHook” and configure it for calling the particle api request. And the other, event would be when the control variable is equal to 0, with a similar WebHook configuration, except for the parameters sent.

In brief,
1- Add a variable.
2- Create a Switch control widget bound to the variable.
3- Add 2 events, one when the previous variable is equal to 1 and the other when it is 0. These events will call a WebHook which you will configurate in the event wizard.

I hope I was clear enough, please let know how it went.

Good Luck!


awesome answer, that’s great!!


so I am configuring the event here:

and this is the example from the particle documentation:

Could you assist me with which parts go into which box? Is the whole line starting with “curl” the payload? Like this?

Obviously I need to put my correct token in there.


I’m glad it helped.

Now about the WebHook, it should look like this:

URL: https://api.particle.io/v1/devices/0123456789abcdef/relay?access_token=YOUR_ACCESS_TOKEN&params=r1,HIGH
Method: POST
Payload: {}

Please, see next image, it could explain things up.

Please, let me know if it works.


Hello the pictures are no longer visible. Can you please reupload them? I need these :blush:


Dear @keremulcay,

Regrettably, the images were provided by external users, so we can’t re-upload them! :frowning:

If we can help you with another thing, just let us know!

All the best,
Maria C.