Hi!
I’m relatively new to Losant workflows. I can see how powerful is but I’m struggling into implementing my use case. I’ve been reading the docs and some of the topics of this forum and was in help! But still not achieving my purpose. Any help will be welcomed.
We’ve a device that just test GSM mobile networks. A SBC + usb modem. Very basic routine: loop through operators in your country and access technologies (2G/3G/4G), try registering, establish data connection and ping google.
What I’m trying to achieve is to design a workflow to open a Losant event called “Incidence” only when after 3 times in a row there was an error with any of the operations of the routine for the same operator and technology (i.e. for after 3 cycles of the routine the modem couldn’t ping Google when registered in T-Mobile in the US). The event will be automatically marked as resolved by the workflow when a success code is received instead of an error.
I’ve read about using “Storage”, “Conditionals” and “Counter” nodes, But still don’t know how to do. They only allow me to query one value at a time of the full JSON, but the detection of the error is 3 times in a row for the same operator + access tech.
Find below the JSON format of the telemetry data pushed to Losant if that helps:
{
"TIME_START": "2018-11-26T11:12:25Z",
"TIME_END": "2018-11-26T11:13:40Z",
"CARRIER": "Spain Orange",
"ACT": "2G",
"RSSI": -51.0,
"SIGNAL_STATE": "Excellent",
"ERROR_CODE": "0.0",
"ERROR_NAME": "No Error",
}
Hi Felix,
If you do not care about the error itself, just that one occurred, I would suggest you look at the Device Inactive Trigger Node. You can create a device for each operator, use the device recipe and you can create a bunch of devices at once. Then you can report state for every routine that completed successfully. You can use the Device Inactivity Node to trigger whenever that state stops reporting, e.g. report state every minute, the device inactivity node could be triggered when the device has been inactive for 3 minutes which would indicate 3 errors in a row. When that node is triggered, then use the Record Event node to set the incident. After that use the Storage Node to store the Event ID, so you can later on access and resolve it. I would set my key to be the Device ID and the value to be the Event ID. Then to resolve the Event use a Device State Trigger Node, get the Event ID from storage and (if you can find it) then use the Modify Event Node to resolve your incident.
Hope this helps!
Erin
Hi @Erin_Thompson! Really thank you for your quick feedback !!!
I’m afraid the strategy of creating a device per operator can be really complicated. Think there’s thousands of operators worldwide (we’ll be deploying units in different countries). Also, it is not just a matter of counting error per operator but per each combination of operator + access technology (2G/3G/4G). I mean, a different event will be recorded for 3 unsuccessful attempts of registering with VerizonUS-2G or VerizonUS-4G.
Wouldn’t be possible to store a value with a key took from the payload? Have a look at the screenshot below. If I could just store a value setting the its key from the payload (as in {{data.CARRIER}}{{data.ACT}}), I guess the effort will be reduced. But I believe Losant does not support storing values defining the key from payload (have a look at the “MissingFieldError Missing Storage Key” error in the debug node).
Is there any other way of allowing Losant generate and store values with random keys from the payload?
Thanks in advance.
Hi,
So I can see on your payload that both data.CARRIER
and data.ACT
is not on your payload, you need to send those in the device state object. That is why you are getting the Missing Field Error
. Once those are on your payload then you are right {{data.CARRIER}}{{data.ACT}}
will create the proper key, since it can be a
string template.
Best,
Erin
Hi @Erin_Thompson, thanks again for the feedback. I’ve learnt a lot about string templates now and looks powerful. I’ve discovered my previous error was caused by another different workflow that incorrectly trimmed the device payloads. Thanks to help me realising
However I’m still stuck on the same point. I’m trying to store a value with keys defined via string templates from the payload but I get a InvalidPayloadPathError.
Erin, perhaps what is failing is my approach on how to model my use case with Losant Workflows.
I’d like to keep, between workflow runs, a series of counters. The counters are created, increased or cleared depending on the payload data (per each combination of data.CARRIER + data.ACT). The id of each counter comes from payload data as well (data.CARRIER + data.ACT). If in a particular workflow run, any of the counters goes above a threshold (defined via workflow global variable), a Losant event will be created. If any of the counters is cleared, the correspondent Losant event will be marked as resolved.
Does it makes sense?
Regards
You should be creating the key earlier in your workflow and using a single string template when you need to use it in set/get nodes.
Also paths are different to keys; (though they could be the same value but are not the same).
The path refers to the path in the payload. Using {{key}} in the Result Path of the Set node would result in
data. having the result.
where as the key in the set operation is just that, a key.
It might be clearer if you use a function or mutate node that explicitly creates the and key , i.e key = data.Carrier + data.ACT
and the use {{key}} everywhere consistantly
T
Hi Felix,
You are trying to use a string template in a result path, where the Result Path
field can only be a string e.g. ‘data.currentStoredValue’. This is actually a validation issue and I’ll file a ticket to have that updated since that is not a valid path.
At this point in your workflow, you have already incremented the key {{data.CARRIER}}{{data.ACT}}
, you don’t need to use that as the payload path you store the result because each time this workflow runs it’s only going to increment or clear one device state object. And then don’t forget to update your conditional below to use the string path.
Hope that helps,
Erin