2017-08-04, 01:03 PM
Give this a go.. note that the input on this flow is a link to the websocket from signalk, looks like you can maybe just have one websocket going at once so you'll need to edit tha to get it connected to your websocket. This works from signalk data.
Code:
[
{
"id": "9b9b0cf3.9bca4",
"type": "worldmap",
"z": "3f30ea31.da3756",
"name": "map",
"lat": "37",
"lon": "-7",
"zoom": "10",
"layer": "Esri Ocean",
"cluster": "10",
"maxage": "",
"usermenu": "show",
"panit": "true",
"x": 555,
"y": 155,
"wires": []
},
{
"id": "1996dede.bab381",
"type": "link in",
"z": "3f30ea31.da3756",
"name": "from database",
"links": [
"8b385a5c.b0c248",
"faa85eeb.a9f43"
],
"x": 90,
"y": 150,
"wires": [
[
"f7e4c77.e7a5438"
]
]
},
{
"id": "f7e4c77.e7a5438",
"type": "switch",
"z": "3f30ea31.da3756",
"name": "Is it nav data?",
"property": "msg.payload.updates.source.sentence",
"propertyType": "jsonata",
"rules": [
{
"t": "cont",
"v": "GLL",
"vt": "str"
}
],
"checkall": "false",
"outputs": 1,
"x": 230,
"y": 195,
"wires": [
[
"f2aa41f7.ef5bc"
]
]
},
{
"id": "f2aa41f7.ef5bc",
"type": "change",
"z": "3f30ea31.da3756",
"name": "create msg.lat etc",
"rules": [
{
"t": "set",
"p": "LAT",
"pt": "msg",
"to": "payload.updates.values.value.latitude",
"tot": "jsonata"
},
{
"t": "set",
"p": "LONG",
"pt": "msg",
"to": "payload.updates.values.value.longitude",
"tot": "jsonata"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 315,
"y": 270,
"wires": [
[
"5ca44ad8.da2324"
]
]
},
{
"id": "5ca44ad8.da2324",
"type": "function",
"z": "3f30ea31.da3756",
"name": "Make JSON",
"func": "var mymsg = {\"name\":\"MyPlace\",\"lat\":msg.LAT,\"lon\":msg.LONG, icon:\"ship\",\niconColor:\"red\"};\n\nmsg.payload=mymsg;\nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 445,
"y": 195,
"wires": [
[
"9b9b0cf3.9bca4"
]
]
}
]