Blynk <-> Notehub Integration - Can't receive Location coordinates on Blynk datastream

We’re testing out the official Notehub<->Blynk integration and we are having problems relaying location data. All of the other datastreams are populating just fine, it’s only the location datastream that will not receive any coordinates.

I have a support thread in progress with Blynk support already, as I suspect the problem is on their end. They don’t seem to have it figured out yet however, so I thought I would mention it here in case someone on the Notehub team might be able to lend a hand in some way.

All of the details (and a few replies from Blynk support) are already in this thread: Blues Notehub Integration - JSON format for sending 2 values (long,lat) to GPS datastream? - #6 by ironhalo2021 - Need Help With My Project - Blynk Community

Please let me know if you might have a clue what’s going on, or if you need more info to help troubleshoot it. I’m really hoping there is an easy solution to this, as we bought into the Blues ecosystem specifically because of the advertised Blynk integration. Unfortunately, without location data, the integration is a non-starter for us.

Thanks in advance!

1 Like

UPDATE: We made a little progress with Blynk support on this, but only enough to know that…

  1. The JSONata transform option definitely does not work for sending data to Blynk. (It appeared as though it was working initially, but only because the integration is apparently still sending the sensor data via sensors.qo in the background even when JSONata was selected as the payload.) Which makes me wonder why was the JSONata Expression option was not put in place in the integration? Having a transform method in between Notehub and Blynk would be incredibly useful, adding an option for augmenting data that doesn’t require MCU code.

  2. The only way to get location data to Blynk is to have the MCU manually add it to a note file, such as: {“req”:“note.add”,“body”:{“location”: [1.11, 2.22]}}. If this is the case, how would we send the “best_lon” and “best_lat” data from the event API? And even if we can access those attributes, it seems rather inefficient for the MCU to be fetching those and feeding them back to the Notecard when those event attributes are already being sent with each sync by default. It would be really simple to alleviate the MCU from having to deal with location at all by using the following JSONata expression, but again the JSONata transform doesn’t seem to be working unfortunately…

{
"body": {
   "location": [best_lon, best_lat]
  }
}

Is this something that can be remedied?

Hey @josh77,

Sorry you ran into issues here. I’ll start with the good news: you don’t have to replicate the location logic in your MCU as JSONata has the ability to append the best_lat and best_lon to the body of your Notes. See Using JSONata to Transform JSON - Blues Developers.

I just tried this JSONata out and it appended a location to the body in my webhook.site test route as expected.

(
    $merge([$, {"body": $merge([body, { 
        "location": [best_lat, best_lon]
    }])}])
)

However, I did verify that for whatever strange reason these JSONata adjustments do not seem to be making it to Blynk specifically—which is… odd. I’m looking into it. Just wanted to let you know we saw this and appreciate the thorough report.

TJ

Confirmed, I am having great success getting the location data to webhook.site as well using JSONata. But yes, JSONata to Blynk is definitely the issue.

Thanks for confirming and looking into this TJ!

Hi TJ, just checking back in to see what you found out about making JSONata work with Blynk. The last thing Blynk support said in the other thread is that they would reach out to Blues to try to resolve it. Thanks!

Hey @josh77,

We’ve confirmed that the JSONata not applying is a bug on our end. I don’t have an exact date for a fix for you, but our cloud team is aware of the problem and it’s on their short list.

When I have an update I’ll reach out and let you know.

TJ

3 Likes

Hey @josh77,

Our fix for this went out on Friday. Sorry for the delay, and let us know if you hit any other issues.

TJ

Hey @tjvantoll ,

JSONata Transform is still not working for us with Blynk unfortunately. We’ve simplified our testing down to passing one single parameter. When we do a hub.sync, it transmits to Blynk successfully if we configure the route for ‘No Transformation’ (and we get a 200 success in the Route Log). However a sync fails to transmit to Blynk when we use a JSONata Expression (and we get a 400 error in the Route Log). I’ll attach some screenshots so you can see what’s going on.

I’m happy to do a screencast with one of your team members so they can see our test results in realtime if that’s helpful.

Interesting. I was just able to recreate the 400 error you show above, but the JSONata I’ve been using to just add the location is working fine:

(
    $merge([$, {"body": $merge([body, { 
        "location": [best_lat, best_lon]
    }])}])
)

My guess is Blynk requires some other bit of metadata in the Note and fails without it. I’ll keep testing.

TJ

Ok, it looks like all Blynk wants is just a body in the JSON, so this works.

{
    "body": {
        "temp": body.temp
    }
}

TJ

1 Like

Awesome, I can confirm that works for us, and confirm that the location data is getting to Blynk as well, using this JSONata expression:

{
"body": {
   "temp": body.temp,
   "location": [best_lon, best_lat]   // FYI - Blynk requires longitude before latitude
  }
}

Thanks very much TJ, I think we’re in business now. We appreciate you continuing to follow up on this until it was resolved.

3 Likes