2021-03-14, 10:11 AM
(2021-03-14, 05:41 AM)SCarns Wrote:(2021-03-13, 07:29 PM)beercansailor Wrote: Hi Steve, you may want to look into applying node-RED to this challenge. It's one of the signalk plugins.
I figured. I’ve been looking at it, but haven’t figured it out yet.
Thanks.
Steve
Try this, first install @signalk/signalk-node-red from the appstore/available if you haven't already. Then open node red by clicking on it in web apps.
With node red open press control-i, then copy and paste the code below, should look something like this >
Then click the import button and click the deploy button top right and that should be it!
SO what happens, the node on the left gets the data from environment.outside.relativeHumidity and sends it to the next node which is a function node, the data is passed in "msg.payload", all the function node does is set "msg.topic" to environment.outside.humidity. The last node on the right sends the msg.payload data to the path in msg.topic.
Hope this works, should do. You can test it by putting this into the data fiddler in the server>
{"updates": [{"values": [{"path": "environment.outside.relativeHumidity", "value": 40.04253}]}]}
Code:
[
{
"id": "b6e07228.375ca",
"type": "signalk-subscribe",
"z": "cc33fe4a.e428d",
"name": "input environment.outside.relativeHumidity",
"mode": "sendAll",
"flatten": true,
"context": "vessels.self",
"path": "environment.outside.relativeHumidity",
"source": "",
"period": 1000,
"x": 340,
"y": 440,
"wires": [
[
"efb6a8e7.c8ffe8"
]
]
},
{
"id": "efb6a8e7.c8ffe8",
"type": "function",
"z": "cc33fe4a.e428d",
"name": "",
"func": "msg.topic = \"environment.outside.humidity\"\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"x": 640,
"y": 440,
"wires": [
[
"b5fd7236.fe9bc"
]
]
},
{
"id": "b5fd7236.fe9bc",
"type": "signalk-send-delta",
"z": "cc33fe4a.e428d",
"name": "send environment.outside.humidity",
"x": 930,
"y": 440,
"wires": []
}
]