Correct format for GPS string

#1

Hi

We have GPS coords being sent inbound as part of SMS message.

I can pick this apart and set the device state using “Device State” node in workflow.
However I can only set the device property value if it is defined as a String property.
If I define the property type as GPS String the device state not updated. I can see this by having another workflow looking at the device events and payload.data is empty. So it seems to be with the format of the data.

The GPS coords are GPS decimal and in my payload.data are defined as

“Latitude”:"-21.10705"
“Longitude”:"+149.21245"

I could understand that maybe the + is extraneous, however the Latitude is also never set.

Not sure what I am missing here.

Thanks

Tim

0 Likes

#2

Below is the function that strips out the GPS data from the SMS message payload.

var result = payload.data.body.Body;
result = result.split("\n")
var message = ""
for (let s of result)  {
    if (s.substring(0,3) == 'Lat') {
       payload.data.Latitude = s.split(" ")[1].trim();  // remove trailing new line
       continue;
    }
   if (s.substring(0,3) == 'Lon') {
       payload.data.Longitude = s.split(" ")[1].trim();
       continue;
   }
   message = message + s + "\n"
  
    }
payload.data.message = message;

The message content at data.body.Body is

"Body":"Engine Started
Latitude: -21.10705
Longitude: +149.21245
"

I am then using the Device State node to set the properties
using path {{data.Latitude}} and {{data.Longitude}}

As I mentioned originally this works for String Properties but not for GPS String

0 Likes

#3

Ahhh

just twigged. Lat and Lon need to be combined in a single value.

Probably should have worked that out.

T

0 Likes

#4

Glad you got it worked out. This is an opportunity for us to improve the experience here. I think that providing better helper text in this context would go a long way.

0 Likes

#5

Yeah, if I had been working with GPS stuff for a while it would have been obvious, but for some reason I just felt it needed separate properties for lat/lon , in hindsight that was a stupid conclusion. But some explicit statement would be good.

0 Likes