Retrieve value from slider

particle
dashboard
#21

Hi,

I took a look at your workflow and it looks as though the implementation of the Device: Update node is not correct. Within your node, you are trying to set a new device attribute, but the value you put into “Data Type Template” will not render, as it is expecting a data type, this is your Set Device Attribute:

And this is what is expected:
27%20AM

For your use case, I would set limit0 as an attribute within your device, like so:

Then replace your Device: Update node with a Device State node that will update the state when triggered by the dashboard slider.

Using a Device: Get node within your Particle workflow, you can get the last composite state for the attributes on the device. In checking the box, you can see on my payload that the last composite state of limit0 was 40, and can then use this number to compare to your value0, value1, etc.

Hopefully this helps!
Julia

#22

Hi Julia
Thanks, it does work. Later on I will ask some question about this new approach:grinning:

1 Like
#23

Hi there !

I already got a great advance with my workflow.
I tried to implement a drop down selector which values an labels should appear on the payload.

{
  "device_to_update": {
    "compositeState": {
      "limit5": {
        "value": 100,
        "relayType": "flow",
        "relayId": "5c60c54b0b719400072d2513",
        "time": "2019-02-16T04:42:30.099Z"
      },
      "limit4": {
        "value": 90,
        "relayType": "flow",
        "relayId": "5c60c54b0b719400072d2513",
        "time": "2019-02-16T04:42:28.438Z"
      },
      "limit3": {
        "value": 90,
        "relayType": "flow",
        "relayId": "5c60c54b0b719400072d2513",
        "time": "2019-02-16T04:42:26.598Z"
      },
      "limit2": {
        "value": 83,
        "relayType": "flow",
        "relayId": "5c60c54b0b719400072d2513",
        "time": "2019-02-16T04:42:24.991Z"
      },
      "limit1": {
        "value": 78,
        "relayType": "flow",
        "relayId": "5c60c54b0b719400072d2513",
        "time": "2019-02-16T04:42:24.048Z"
      },
      "limit0": {
        "value": 63,
        "relayType": "flow",
        "relayId": "5c60c54b0b719400072d2513",
        "time": "2019-02-16T04:42:22.783Z"
      },
      "value8": {
        "value": 372,
        "relayType": "flow",
        "relayId": "5c60c54b0b719400072d2513",
        "time": "2019-02-16T04:50:35.088Z"
      },
      "value7": {
        "value": 352,
        "relayType": "flow",
        "relayId": "5c60c54b0b719400072d2513",
        "time": "2019-02-16T04:50:35.088Z"
      },
      "value6": {
        "value": 352,
        "relayType": "flow",
        "relayId": "5c60c54b0b719400072d2513",
        "time": "2019-02-16T04:50:35.088Z"
      },
      "value5": {
        "value": 352,
        "relayType": "flow",
        "relayId": "5c60c54b0b719400072d2513",
        "time": "2019-02-16T04:50:35.088Z"
      },
      "value4": {
        "value": 57,
        "relayType": "flow",
        "relayId": "5c60c54b0b719400072d2513",
        "time": "2019-02-16T04:50:35.088Z"
      },
      "value3": {
        "value": 56,
        "relayType": "flow",
        "relayId": "5c60c54b0b719400072d2513",
        "time": "2019-02-16T04:50:35.088Z"
      },
      "value2": {
        "value": 49,
        "relayType": "flow",
        "relayId": "5c60c54b0b719400072d2513",
        "time": "2019-02-16T04:50:35.088Z"
      },
      "value1": {
        "value": 44,
        "relayType": "flow",
        "relayId": "5c60c54b0b719400072d2513",
        "time": "2019-02-16T04:50:35.088Z"
      },
      "value0": {
        "value": 29,
        "relayType": "flow",
        "relayId": "5c60c54b0b719400072d2513",
        "time": "2019-02-16T04:50:35.088Z"
      }
    },
    "connectionInfo": {
      "connected": null
    },
    "id": "5c639a329833d9000881131f",
    "deviceId": "5c639a329833d9000881131f",
    "lastUpdated": "2019-02-16T04:36:49.308Z",
    "creationDate": "2019-02-13T04:16:50.060Z",
    "applicationId": "5c60c3aa0b719400072d2510",
    "deviceClass": "standalone",
    "tags": [
      {
        "value": "3e0039000247363339343638",
        "key": "particle_device_id"
      }
    ],
    "attributes": [
      {
        "dataType": "number",
        "name": "value0"
      },
      {
        "dataType": "number",
        "name": "value1"
      },
      {
        "dataType": "number",
        "name": "value2"
      },
      {
        "dataType": "number",
        "name": "value3"
      },
      {
        "dataType": "number",
        "name": "value4"
      },
      {
        "dataType": "number",
        "name": "value5"
      },
      {
        "dataType": "number",
        "name": "value6"
      },
      {
        "dataType": "number",
        "name": "value7"
      },
      {
        "dataType": "number",
        "name": "value8"
      },
      {
        "dataType": "number",
        "name": "limit0"
      },
      {
        "dataType": "number",
        "name": "limit1"
      },
      {
        "dataType": "number",
        "name": "limit2"
      },
      {
        "dataType": "number",
        "name": "limit3"
      },
      {
        "dataType": "number",
        "name": "limit4"
      },
      {
        "dataType": "number",
        "name": "limit5"
      },
      {
        "dataType": "number",
        "name": "limit6"
      },
      {
        "dataType": "number",
        "name": "limit7"
      },
      {
        "dataType": "number",
        "name": "limit8"
      }
    ],
    "description": "",
    "name": "Photon_Star"
  },
  "globals": {},
  "applicationName": "Sensor_Star",
  "flowName": "Photon_Star_Wfw",
  "flowId": "5c60c54b0b719400072d2513",
  "flowVersion": "develop",
  "relayType": "integration",
  "relayId": "5c60c427dbea67000758af22",
  "triggerType": "integration",
  "triggerId": "5c60c427dbea67000758af22",
  "applicationId": "5c60c3aa0b719400072d2510",
  "data": {
    "value8": "373",
    "value7": "353",
    "value6": "353",
    "value5": "353",
    "value4": "58",
    "value3": "57",
    "value2": "50",
    "value1": "45",
    "value0": "30",
    "name": "Photon_test1",
    "coreid": "xxxxx00024736333xxxxxxx",
    "published_at": "2019-02-16T04:50:45.070Z",
    "ttl": 60,
    "data": "30:45:50:57:58:353:353:353:373"
  },
  "time": "2019-02-16T04:50:45.085Z"
}

This is the drop down selector:



The name is : REF
I set the labels RA, RB and RC with values 10,20,30. respectively.
I would like to include those labels and values in the payload and be able to access them later.
I do not understand how establish the connection between the drop down selector and the payload.
Can I get some assistance on that?
Thanks in advance.

#24

Hello,

Happy to hear you’ve made great progress! :grinning:

The dropdown selector you have is inside of an Input Control block, which is the same block as the ones holding your set0, set1, etc., triggers. There are two different paths you can take here, based on your use case. I will outline them both and you can choose which works best for you.

1. Values as Tags
This approach is the same as Erin’s suggestion above. If your values will always be the same, in this case 10, 20, and 30, it would be most valuable to add these to your device as Device Tags. Like so:

Then when you use the Device: Get node, your tag values will be available in your payload:

Again, this approach is ideal for values that won’t change, since tag values as context variables do not live update on the dashboards.

2. Values as Attributes

The next approach is ideal for values that can change, and is the same approach as this suggestion above.

You will need to add a Button Trigger for these values to come into a workflow and be visible on the payload. I recreated your dropdown, and added a Button Trigger that sends the value of the selected dropdown to my “REC” Virtual Button in the workflow:

When I select “RA” on the dropdown and push the button, this is the payload for my workflow:

Again, if this value will change, it is best to save it as an attribute. I create a new attribute on the device for this value and set it in my workflow.


You will then be able to use a Data: Time Series or Data: Gauge Query node to retrieve this value.

Hopefully this helps!
Julia

#25

Well, thanks for you wide explanation.
My use case is in the middle of your two alternatives.
The RA, RB,RC, etc. are constant values that I need with the only goal of be able to know what type measurements unit is selected for the user. Once I got what unit was selected I would need to convert
the values value1, value2, value3 , etc. to such unit.
Now, as I was saying the tag option is good because those are constant values and even can be strings. But the downside of it is that those values 10,20,30 … appear all of them in the payload and I cannot identify which value was selected by the user.

So I tried the attributes option:
I set RA,RB,RC…RF as attributes in the device with no results.
What I do not realize is if need just one buttontrigger for each of the Dropdown Selector options or each option need its own buttontrigger.
Thank you again:slightly_smiling_face:

#26

Hello!

To have a label appear with your dropdown value, you can use a conditional with Markdown within your Button Trigger Payload.

Here I again have my dropdown values:

Within my Button Trigger Payload, I use this conditional to put the correct label on my payload:

So when I trigger this button with the label “RA” and corresponding value of 10, this is what comes through my payload:

Thanks,
Julia

#27

Hello, I configured just one button trigger as you suggested.
Positively, the button trigger triggers the workflow, I can see it in the debug node attached to the virtual button. It only shows the tags

"value" and "label " but empty quotes " " .

Also I should changed the button trigger payload like that:

{
 "label": "{{#eq select-0 '10'}}RA{{else}}{{#eq select-0 '20'}}RB{{else}}{{#eq select-0 '30'}}RC{{/eq}}{{/eq}}{{/eq}}",
  "value": "{{select-0}}"
}

I should quoted {{ select-0}} because if not a I got a message regarding invalid JSON payload.

Other test I done was trigger the virtual button in the workflow, loading a payload like that:

{
"label" : "Ra",
"value" : "{{select-0}}"
}
That way I got the same : "label" : "Ra" and  "value" : "{{select-0}}"

I am not realize what I am missing.

Remember that my Get:Device node is configured as :
Return tags as an object map instead of an array

The rest of the workflow works as expected.

#28

Hi,

I took a look at your dashboard, and it looks like the reason you are not getting any data is because you have your dropdown selector in one Input Control block, and your button trigger in another. Dashboard blocks do not have access to data in other blocks, so your {{select-0}} value will not be available unless it is referenced from inside the same block.

I would recommend moving your “RGT” button into the same block as your dropdown, then you will be able to use {{select-0}}.
33%20AM

Hopefully this helps,
Julia

#29

I’ve done those changes but data does not appear yet.
Thanks.

#30

Hi,

I took a look at your dashboard and the reason you are having this problem is because you’re query is named “Select-0” but you are calling “select-0.” The template IDs are case sensitive.

Thanks!
Julia

#31

Hi Julia I’m so sorry .
Thanks again.

1 Like
#32

Hi Julia

I am doing awesome with my code thanks to your help. Regarding de Drop Down Selector( DDS), I been doing some modification regarding your suggested payload in the button settings.

Now the payload is just

{
"value": "REF",
 "label": "{{ Select-0}} "
 }

And the options for DDS are RF1, RF2…RF7.

That way I am able to get for the value REF as RF1, RF2…RF7. when some of those string are selected with the DDS.

Now I tried to call a Particle function to transfer those values (RF1, RF2…RF7 ) to the Particle board.

On Losant workflow I used a button trigger called SET, a Device State node , a Data gauge query node and a Particle call node.

On Photon code I registered a function like this:

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 verified that this function does work using Particle Console and there is reason why this function is not called from particle call node, which I do not know .

I am assuming that the issue is the way I set up those nodes; Particle Call and Data Query.

Would you help me with that ?

Thank you in advance.

#33

Hi Julia

I’m wondering if there is some kind of impediment to implement this type of action.

Regards,

#34

Hi @Tron7,

The reason you might not be seeing this data come to Losant is because you are printing the ref value and never returning it. If the correct ref value is successfully printing to your console, the only change you will need to make would be to add return ref.

Hopefully this helps!
Julia

#35

Hi There!

After a few days I have left this project and now I have taken it back.

"The reason you might not be seeing this data come to Losant is because you are printing the ref value and never returning it."

I think that I expressed myself incorrectly.
I do not want to see any value on Losant platform.
I only need to call the following Particle function from Losant dashboard using commands from Drop down selector and confirm the command with SET SELECTION button.
Again, I verified the function is operative using particle console.
Aparently I am loosing the link (settings) to call it from the workflow.

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);

It is something similar to this post :


But the answer doesn’t work for my case.

I just want to send the values RF1, RF2, RF3, RF4, RF5, RF6, RF7 as command arguments to call that function.
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 pics to show the settings.



Thank for your help.