Hi There
I’m planing to use Particle Electron as device. In the dashboard I need among others gadgets, a slider
which operate like a temperature thermostat setting.
I mean, I need to retrieve the value of the slider and be able to compare it with a a sensor reading in the photon code.
Also the possibility to detect the event "slider value has changed " from the dashboard user.
Are those features possibles ?
Thanks.
Hello Alejandro. I’m also a Particle/Losant user.
IMO per device configuration-like details such as a TSTAT setpoint etc. are best handled by device tags, which are easily accessed by Math nodes etc for incorporation into your workflow calculations. Though the Device Update node does support changing the value of such a tag when an Input Control’s virtual button trigger is activated, the Input Controls do not currently support initialization via device tag. More here …
Thank for your answer. I did not decide if I gonna use Losant yet.!
I’m just following the University Courses.
Regards,
Hi WoobaGooba
I just started with this platform.
I am able to send data to Losant but yet I am struggling to get the slider value.
I understand that the slider should send the set value to the Broker but I do not find the way to set a variable
for the slider.
Can you expand your explanation about device tag?
Thank you in advance.
Hi Tron,
There are several ways to create and update device tags. The first is on the device’s page at the bottom on either creation or when updating.
Another way to add or update device tags would be in the workflow using the Device Update Node. The tag value and the tag key are both template-able so you can use data off your payload to set or update a tag key or value.
Also if you need to update your device tags outside of the Losant Platform you can always use the Device Patch API endpoint.
Hope that helps,
Erin
@Erin_Thompson Thank you I understood.
@Erin_Thompson
Hi,
In using the Particle trigger I am able to send 3 values to the dashboard indicator.
With the goal to get added the slider value to the workflow payload I assembled
the attached workflow. I’m using a Device:update node to retrieve the slider0 value and add it to the workflow payload. I’m not having success on that.
I do not see what exactly I am doing wrong , I am trying to follow the Brandon suggestions at:
Can you give me some tip on how I should config the device : update node ?
Thank you in advance.
Hi Tron,
I think I see your issue. When trying to access the data sent from the dashboard all the data will be under the path data
. And you are sometimes using data.body
or accessing it from the top level like {{ range-0}}
. To go off of Brandon’s example, you would access limit1 on your payload by data.limit1
.
Hope that helps,
Erin
Hi Erin
I made a good progress with my code regarding to retrieve 3 slider values and get debug nodes
displaying regular values or over limit.
I would like to use a Switch node to simplify the workflow but I do not find the way to do it.
Is there some way to share with you my workflow and the dashboard ?
Thank you.
Hi Tron,
Can you give me the ID of the workflow and dashboard you are referring to? I can have a look and then I’ll give you a recommendation.
Thanks,
Erin
Hi,
After reviewing your workflow I have a few suggestions for you to clean it up. This is your current workflow.
The first thing I noticed is that whenever input from the dashboard comes in (Triggers Slide0, Slide1, and Slide2) you are updating your device and creating the attribute limit0, limit1, or limit2. Those attributes are already set on the device so you don’t need to keep on trying to add them. I would actually suggest you remove those attributes from your device and set them as tags. Then whenever a device comes in update the tags accordingly. Also when using the Device: Update Node you cannot use the name of the device to update you must use the Device ID, which you can get from the device overview page, or you could add the device ID to the payload from the slider on the dashboard. So now for each one of those triggers (Slide0, Slide1, Slide2), you would just need a trigger and a Device Update Node. You do not need to store those limit values on the state because if you put them as Device Tags, you will be able to get the limits from the Device: Get Node. Also by removing the need for storage, these four triggers do not have to exist on the same workflow.
This is an example of how to initialize those tags and attributes
This is how simple the dashboard input could be. I’m not sure why you had those updates connected to the device state since those limits were not being set as part of the device state?
As for your main path coming from Particle, if you use Device tags, then you can remove all the storage get nodes, set your device states then make your comparisons to your current values and their corresponding limits e.g. value0 > limit0. I am assuming this is where you believe you can use a Switch node, but that cannot work here. A switch node would be used if you were comparing a single value to multiple cases, e.g. value0 = 50, value0 = limit0, value0 = 0, etc. And the switch node would then only take one path. I believe each time you want to make the comparisons of the current state to the limit every time for each value thus you will have to use conditionals as you currently are.
Hope this helps,
Erin
Hi Erin
Thank you so much.
I gonna implement this changes.
Thanks again.
Hi Erin
I cleaned up my Sandbox and start over.
I am trying to implement your suggestions with no success .
I’m building the new workflow and even though Workflow debug tab, application tab and Device tab shown a payload coming from particle device on device tab appear "Awaiting first connection to Losant "
On the other hand following your guidelines to set limit_i for value_i those limit_i does not appear in the payload as you can see :
{
"device_to_update": {
"connectionInfo": {
"connected": null
},
"id": "5c60c507122b8f000933fbef",
"deviceId": "5c60c507122b8f000933fbef",
"lastUpdated": "2019-02-11T01:41:33.800Z",
"creationDate": "2019-02-11T00:42:47.385Z",
"applicationId": "5c60c3aa0b719400072d2510",
"deviceClass": "standalone",
"tags": {
"limit2": [
"69"
],
"limit1": [
"64"
],
"limit0": [
"26"
],
"particle_device_id": [
"3e0039000247363339343638"
]
},
"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"
}
],
"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": "249",
"value7": "229",
"value6": "229",
"value5": "229",
"value4": "34",
"value3": "34",
"value2": "27",
"value1": "22",
"value0": "7",
"name": "Photon_test1",
"coreid": "3e0039000247xxxxxxxxxxxxxx",
"published_at": "2019-02-11T02:02:43.862Z",
"ttl": 60,
"data": "7:22:27:34:34:229:229:229:249"
},
"time": "2019-02-11T02:02:43.885Z"
}
Can you help me with that?
Thank you
Hi,
I’ll look into this further and get back to you soon with a solution.
The “waiting for first connection to Losant” is only pertinent for devices connected to Losant with MQTT. Since you are connecting with a Particle integration, this does not pertain to you, your device is still connected!
Thanks,
Julia
Hello again,
I looked further into your problem and I think I see what you are trying to do, and if it is not, let me know and we will look again!
It looks as though you are trying to compare your limit0, limit1, and limit2 values to the value0, value1, etc., but are having some trouble finding the tag value within your payload. I recreated a subset of your workflow and dashboard, and you can see similar outputs in my payload.
Within this payload I can see that value0=22, and my saved tag value for limit0 is “38”.
Within my Input Control block, I have a button and slider to set value0, and when I set it to 22, the tag value updates as well:
I then added a Conditional node within my Particle workflow that is true when the limit0 tag value and incoming value0 are equal:
Thus, I am comparing my tag value and the current value0 to see if they are equal. Now you will be able to check and see if they are equal, unequal, or if one is greater than the other.
Hopefully this help!
Julia
Hi Julia
Thank you again, your suggestion did work.
Although it were need to use a different conditional expression from you, the workflow works very well.
In your test the conditional expression is : {{data.value0}} =={{result .tags.[0].value1}}
The mine is like that: {{data.value0}} > {{device_to_update.tags.limit0}}
The reason is the payload’s tags is like that:
"limit0": [
"24"
],
Please see attached payload.
But with this solution came an issue with the Indicator block.
On February 5th you asked me to implement a couple of queries to get the
{{ data.value0) and {{ data.limit0} and I succefully implemented the indicator block.
But at that time limit0 was an attribute in the payload, now limit0 is tag which value is a string.
Then I’m doing the following: Query 0 and Query 1
Because value-0 and value-1 is a string:
{{add 0 value-0}} > {{add 0 value-1}}
{{add 0 value-0}} <= {{add 0 value-1}}
However, I do not get any value for {{add 0 value-1}}
May be it is not enough info because for indicator block setting is involved
the context variable I set on slider0 like this;
and this is the slider0 payload .
{
"limit0" : {{range-0}},
"deviceId": "{{ctx.deviceId}}"
}
Well, I hope you can help me with that.
Thank you very much in advance.
The payload:
{
"device_to_update": {
"connectionInfo": {
"connected": null
},
"id": "5c60c507122b8f000933fbef",
"deviceId": "5c60c507122b8f000933fbef",
"lastUpdated": "2019-02-12T05:08:19.820Z",
"creationDate": "2019-02-11T00:42:47.385Z",
"applicationId": "5c60c3aa0b719400072d2510",
"deviceClass": "standalone",
"tags": {
"limit8": [
"50"
],
"limit7": [
"50"
],
"limit6": [
"50"
],
"limit5": [
"50"
],
"limit4": [
"50"
],
"limit3": [
"50"
],
"limit2": [
"65"
],
"limit1": [
"11"
],
"limit0": [
"92"
],
"particle_device_id": [
"3e0039000247363339343638"
]
},
"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"
}
],
"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": "838",
"value7": "818",
"value6": "818",
"value5": "818",
"value4": "23",
"value3": "17",
"value2": "10",
"value1": "5",
"value0": "91",
"name": "Photon_test1",
"coreid": "3e003900xxxxxxxxxxxxxxxxxxxxxxx",
"published_at": "2019-02-12T05:17:10.261Z",
"ttl": 60,
"data": "91:5:10:17:23:818:818:818:838"
},
"time": "2019-02-12T05:17:10.332Z"
}
Hello,
Device Tags work a bit differently in an Indicator Block. Currently, we do not support a live update of tag values within the Indicator Block, but can support static variables. If your limit0 value were a static value that did not change with the Input Control block, tags could be very useful. For example, if I set a Context Variable for my device tag that is always 28, I could use it within an Indicator Block, like so:
Since your limit0 value is dynamic and changes, I would recommend changing limit0 from a tag to an attribute, and following our walkthrough together from this post.
I was also wondering if you could provide some information on your end goal for this project so that I can recommend the most accommodating steps in the future!
Hopefully this helps,
Julia
Hi Julia
Thanks for your answer.
My project is about reading 8 sensors, and alert the customer when the sensors reading
are out of the healthy range. The point is that these healthy range should be set by the user, either for high limits or minimum limits.
Also I should implement a drop down menu to select the units in which some of those sensors should be displayed in the metrics.
This in summary the goal of my project.
According to your current explanation about static values, then I’ll go back to the approach I was using at the beginning, that is to say use limit_i as device payload attributes and not device tags.
I will trying that again again and I’'ll get back to you.
Thank so much again.
Hi again !
After your answer I tried to implement limit_i as attributes, not as device attributes but as the ones
created by Device update nodes .
The result is that those limit_i doesn’t appear in the payload , just those value_i .
Maybe you can take a look to my workflow to check what is wrong, because I tried many ways to set up the device update nodes and cannot get the correct payload.
Tank you.