Sending location data from Node-RED to Map widget

I’m trying to send location data from Node-RED to Map widget, however, nothing shows up in the interface.

The function, which generates the message is:

msg.payload = [2,47.488,19.135,"may"];
msg.pin = 15;
return msg;'

The message then fed into an - otherwise working - Pin Dynamic Write node.

Anyone could help fo figure put the appropriate payload format, to get the map widget working?

Thanks,
regards,

András

I’m not sure that the standard write Node is capable of being used with the map widget.
Other widgets that need more complex data structures, such as Table & LCD have their own nodes.

@gab.lau should be able to tell you if it’s possible with the current ws contrib. if it’s not, then I guess it could be done using a Blynk API call from Node-Red.

Pete.

Hi András,
I’m not at home for next 3 weeks, so no test or debug sorry :grinning:

From the official docs it’s ok to use a write node to send data to map widget.

You can try to pass array of string, like this:
msg.payload = ["1","47.488","19.135","may"]; msg.pin = 15; return msg
The first parameter is an index, try to start from number 1.

Let me know

Best regards
Gabriele

1 Like

Hi Gabriele,

thank you for the fast reply, unfortunately, passing all parameters as string did not help. I’ll investigate the problem further in the following days.

Regards,
András

Ok,

so the trick is in the line 35 of blynk-ws-out-write.js:

var payload = Buffer.isBuffer(msg.payload) ? msg.payload : RED.util.ensureString(msg.payload);

This will stringify anything but buffers, changing it to:

var payload = msg.payload;

made things work instantly, while it may produce other conflicts. Creating the appropriate buffer is the other option, I have to look deeper into that.

Regards,
András

1 Like

You are right!

Change from this:
var payload = Buffer.isBuffer(msg.payload) ? msg.payload : RED.util.ensureString(msg.payload);

To this:
var payload = Array.isArray(msg.payload) ? msg.payload : [RED.util.ensureString(msg.payload)];

It is more correct that the payload variable is an array.

Let me know

Gabriele

For now, I can’t see any downside of not converting payloads at all. Will look deeper into that a bit later, I need some holiday now :wink:

András