Particle call settings

Hi there !
I’m using in my workflow a “particle call function” in order to send commands to a registered function in particle code.
I verified that the function is operative using particle console.
Apparently I am loosing the link to call it from the dashboard.
I do not realize what I’m doing wrong with the particle call node in the workflow.

I just want to send the values RF1, RF2, RF3, RF4, RF5, RF6,RF7 as command arguments when the function get called .
In order to do that I am using a drop-down selector called " SELECT" and a Button called " SET SELECTION"
I am attaching the corresponding particle function and pics to show the settings.

Thank you in advance.

Particle.function("refSel",selection);

int selection (String command)

{
if(command =="RF1"){
ref=10;
}

 else if(command =="RF2"){
ref=20;
}

else if(command =="RF3"){
ref=30;
}

// And so on

else { Serial1.println(No data);}

Serial1.println("ref:");

Serial1.println(ref);

Hello @Tron7!

I see a couple of possible problems and I will detail each so we can debug :grinning:

The first thing I see that could cause some problems is the configuration of your Input Control block. For Set Selection you have a space before label and a space inside of the quotes for Select-0, like so: "_label": "{{ Select-0}}_". This will cause the value to have an extra whitespace character at the end, and look like this on the payload:
19%20PM
This can cause some problems if you are doing conditionals, as label="10" will return true, but label="10 " will return false. The whitespace character could cause a problem with your Particle code as it would be coming through as "RF3 " instead of “RF3”, for example.

The second change you will need to make is in your REF workflow with the Particle Call. The configuration as it stands currently is sending only “REF” through the function. I believe you are trying to send the label value that was selected on the dashboard, such as “RF2” and “RF3,” but the only thing being sent is “REF,” so you may be printing that you have no data as “REF” is not a conditional in your Particle function.

Applied Changes Examples

You are currently getting two values from your dashboard, “REF” and the value selected by the dashboard user. These are some changes I would recommend to make this easier on yourself!


The first is to remove “value” and replace “label” with “REF”, so your payload will look like this with only one value:

The second change is in the Particle Call configuration:

These steps should clear up some confusion and hopefully fix your Particle node!
Let me know if I can help further,
Julia

Hi Julia
I made the suggested changes but we’re still the same.:sweat_smile:
What another point can consider?
Thank you.

Hi @Tron7,

I recommend setting up your Particle Call Node with a Result Path so we can see what is returned by the function call, like so:

Then we will be able to debug further. :smile:

Thanks,
Julia

Hi Julia !
Please see attached pic.
I applied the modification adding Result Path.
The following picture is the result for some instant after I click on SET SELECT key on the Dashboard. It show error 403.
At the very right you can see at Real Term terminal where I am sending the result of the function call from Losant. " Hello" is sent always but if the function call would work you would see like : ref = “10” or ref =“20”.
Very much for your help.

Hi @Tron7,

I see a couple more things that could be causing some problems, let’s dive in:

The first is in your Particle Call Node configuration. The Device ID is set to your Losant Device ID, but should be set to your Particle Device ID. If the selected Particle integration is configured for a single device, this field is optional - otherwise it is required. This blog post has a helpful section titled “How To Call a Function on the Particle Board” that details the configuration of this node. The documentation can also be found here.

The other problem you might run into is with your Particle function code. The first line of your code is Particle.function("refSel",selection), but in your Particle Call Node configuration, you have the name set to “selection.” I would recommend changing this line to Particle.function("selection",selection) so the function can be correctly called with your current node configuration.

Let me know if your problem continues and I will look again! :grinning:

Thanks,
Julia

Hi Julia thanks so much for your help. !!!
I does work.:joy:
Really, I interpreted Device Id like Losant Device ID and also did the difference to
register the function like "Particle.function(“selection”,selection); "
Thanks so much again.
Best regards,

Hi Julia

May be you can help me with this.
As you know my dashboard is using Gauge block and Indicator block.
I can manage the decimal places for the gauge block.
I trying to do the same with the indicator block and I don’t find the way to reduce to 2 decimal places on it, always display at least 4 decimal places.
Thank you for your help.

Hi @Tron7,

Indicator Block labels are templatable. This means you can use all the helpers we have here:

There is one helper in particular called the format helper. You can see it in use in the Indicator Block documentation: https://docs.losant.com/dashboards/indicator/#conditions

Behind the scenes it’s using D3 Format to format numbers. Here is a really good blog post explaining it: http://koaning.s3-website-us-west-2.amazonaws.com/html/d3format.html

Here is an example:

If given the number 10101 at value-1 and the helper {{format value-1 '.2f'}}. You will get: 10,101.00.

Let me know if you have any questions.

@anaptfox OK thanks and congrats for your Losant University Training !

2 Likes