OpenMarine
Change data path... - Printable Version

+- OpenMarine (https://forum.openmarine.net)
+-- Forum: OpenPlotter (https://forum.openmarine.net/forumdisplay.php?fid=1)
+--- Forum: How do I...? (https://forum.openmarine.net/forumdisplay.php?fid=3)
+--- Thread: Change data path... (/showthread.php?tid=3335)



Change data path... - SCarns - 2021-03-13

Hi everyone.

I'm receiving "relativeHumidity" from a Ruuvi Tag through the RuuviTag plugin. It sends the humidity path as "environment.outside.relativeHumidity" and I want this info in "environment.outside.humidity" so it can be used by DerivedData plugin to calculate additional information. What's the best way to make this happen (i.e. easiest, most flexible)?

Thanks,

Steve


RE: Change data path... - beercansailor - 2021-03-13

Hi Steve, you may want to look into applying node-RED to this challenge. It's one of the signalk plugins.


RE: Change data path... - SCarns - 2021-03-14

(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


RE: Change data path... - PaddyB - 2021-03-14

(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 >
[Image: QnQwQAj.png]

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}]}]}
[Image: Zd2B4PU.png]

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": []
   }
]



RE: Change data path... - SCarns - 2021-03-14

Thanks PaddyB!!!

That is some real help. However, it did not work for me, as there is some sort of error in Node-Red I have to sort out. It took a reinstall to get it to work to begin with, then there was another flow that had an error. I included Debug tags and was able to view that the flow was indeed working, but it wasn't getting inserted back into SK.

In the meantime, I found another Node-Red plugin by Scott Bender called "Path Mapper" that instantly and easily solved the problem. I an just beginning with this Linux/Node-Red/RPi stuff, but am really enjoying it so far, so much so I have a second Pi already that does nothing but OpenCPN, replacing my old Mac Mini and runs off of 12 volt! This is all fun stuff!

Thanks again PaddyB. I appreciate the effort and the lesson!

Steve