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);
I see a couple of possible problems and I will detail each so we can debug
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:
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!
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.
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!
Hi Julia thanks so much for your help. !!!
I does work.
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,
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.