OpenMarine
Node red -> signalK. Data not showing - Printable Version

+- OpenMarine (https://forum.openmarine.net)
+-- Forum: OpenPlotter (https://forum.openmarine.net/forumdisplay.php?fid=1)
+--- Forum: Node Red (https://forum.openmarine.net/forumdisplay.php?fid=15)
+--- Thread: Node red -> signalK. Data not showing (/showthread.php?tid=3899)

Pages: 1 2


Node red -> signalK. Data not showing - kniven - 2022-01-30

Hi all. I'm trying to set up a connection between Node-Red and signalK. Both are running on the same Paspberry Pi 4. I have successfully installed the signalK plugin in Node Red. And the SignalK server is running fine.

The quiestion is: What do I have to specify in order to make the output from Node-Red visible and detected by my SignalK server. Any plugins, authetications?
The data I'm trying to send is the barometric pressure from Sense Hat.

Thank you!


RE: Node red -> signalK. Data not showing - kniven - 2022-01-31

Screenshot from node red. Should there be some sort of details pointing to the signalK server in the fields?


RE: Node red -> signalK. Data not showing - PaddyB - 2022-01-31

(2022-01-31, 05:34 PM)kniven Wrote: Screenshot from node red. Should there be some sort of details pointing to the signalK server in the fields?

No screenshot here...?

In the signalk node red app there are nodes to receive & send signalk deltas. Deltas created inside node-red won't show up in node red without changing the source which can be a bit confusing. 

[Image: 4lWpsFY.png]


RE: Node red -> signalK. Data not showing - kniven - 2022-01-31

Hi. Thanks for your guidance. 
I now managed to connect to the node-red server. Only issue is, as you pointed out, that I have to change the source to for each node. If not, Signalk only recognize one of the outputs (as they all have the same path/name).. Is there no more elegant way to specify the path for each node?

   


RE: Node red -> signalK. Data not showing - kniven - 2022-02-01

Any ideas of why this flow doesn't work?

   


[{"id":"3f463f63dad2fe3c","type":"tab","label":"Flow 5","disabled":false,"info":"","env":[]},{"id":"c78ae99d602b4cdd","type":"rpi-sensehat in","z":"3f463f63dad2fe3c","name":"","motion":true,"env":true,"stick":false,"x":70,"y":340,"wires":[["79d492ee700e4470"]]},{"id":"4a80ecd8273a43b6","type":"change","z":"3f463f63dad2fe3c","name":"temp","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.temperature","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":465,"y":312,"wires":[["61fd52fe5142db98"]]},{"id":"79d492ee700e4470","type":"switch","z":"3f463f63dad2fe3c","name":"","property":"topic","propertyType":"msg","rules":[{"t":"eq","v":"environment","vt":"str"},{"t":"eq","v":"","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":210,"y":340,"wires":[["4a80ecd8273a43b6","4e09a1778a2b10b4","1cab46908f035dfc"],["fc3b803136c4c4e3","8d56a0b68b22e74b","e66644fbaf157fe8","84b0597c9dc2ef2d"]]},{"id":"4e09a1778a2b10b4","type":"change","z":"3f463f63dad2fe3c","name":"hum","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.humidity","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":466.5,"y":379,"wires":[["847d07f6f6efd8c8"]]},{"id":"1cab46908f035dfc","type":"change","z":"3f463f63dad2fe3c","name":"atm","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.pressure","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":465.5,"y":433,"wires":[["8fca500f106f9e7f"]]},{"id":"61fd52fe5142db98","type":"signalk-send-pathvalue","z":"3f463f63dad2fe3c","name":"","source":"temp","meta":"","x":890,"y":300,"wires":[]},{"id":"8fca500f106f9e7f","type":"signalk-send-pathvalue","z":"3f463f63dad2fe3c","name":"","source":"press","meta":"","x":890,"y":420,"wires":[]},{"id":"847d07f6f6efd8c8","type":"signalk-send-pathvalue","z":"3f463f63dad2fe3c","name":"","source":"hum","meta":"","x":890,"y":360,"wires":[]},{"id":"191a0afc283a410e","type":"signalk-send-pathvalue","z":"3f463f63dad2fe3c","name":"AccelX","source":"acc","meta":"","x":1250,"y":580,"wires":[],"inputLabels":["eerverv"]},{"id":"fc3b803136c4c4e3","type":"change","z":"3f463f63dad2fe3c","name":"acceleration","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.acceleration.z","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":550,"y":560,"wires":[["531e25e7e10c401a"]],"inputLabels":["accelx"],"outputLabels":["Accelx"]},{"id":"8d56a0b68b22e74b","type":"change","z":"3f463f63dad2fe3c","name":"gyroscope","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.gyroscope.x","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":554,"y":599,"wires":[["4cca667b2fb910ee"]]},{"id":"e66644fbaf157fe8","type":"change","z":"3f463f63dad2fe3c","name":"orientation","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.orientation.pitch","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":554,"y":639,"wires":[["2eb58f1056915983"]]},{"id":"84b0597c9dc2ef2d","type":"change","z":"3f463f63dad2fe3c","name":"compass","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.compass","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":544,"y":679,"wires":[["77237f4c598328cc"]]},{"id":"2eb58f1056915983","type":"signalk-send-pathvalue","z":"3f463f63dad2fe3c","name":"","source":"orient","meta":"","x":1003.8958129882812,"y":709.8888854980469,"wires":[]},{"id":"4cca667b2fb910ee","type":"signalk-send-pathvalue","z":"3f463f63dad2fe3c","name":"","source":"gyro","meta":"","x":950,"y":640,"wires":[]},{"id":"77237f4c598328cc","type":"signalk-send-pathvalue","z":"3f463f63dad2fe3c","name":"","source":"comp","meta":"","x":855,"y":860,"wires":[],"inputLabels":["ec"],"l":false},{"id":"531e25e7e10c401a","type":"smooth","z":"3f463f63dad2fe3c","name":"","property":"payload","action":"mean","count":"10","round":"3","mult":"single","reduce":false,"x":790,"y":560,"wires":[["191a0afc283a410e"]]}]


RE: Node red -> signalK. Data not showing - PaddyB - 2022-02-01

(2022-02-01, 08:15 AM)kniven Wrote: Any ideas of why this flow doesn't work?

Some debug nodes along the flow will help seeing what data gets where, set to show complete message so all data gets shown and not just msg.payload. Inject nodes useful as well, send just a little of the data & see where it goes. To help debugging this the output of senshat would help. 


Doesn't look like there are msg.topic definitions so the send-pathvalue knows what the delta gets sent as?


RE: Node red -> signalK. Data not showing - PaddyB - 2022-02-01

Lots can be done inside function nodes as well >>

Code:
[
   {
       "id": "407fe70a51278625",
       "type": "debug",
       "z": "3f463f63dad2fe3c",
       "name": "",
       "active": false,
       "tosidebar": true,
       "console": false,
       "tostatus": false,
       "complete": "true",
       "targetType": "full",
       "statusVal": "",
       "statusType": "auto",
       "x": 790,
       "y": 100,
       "wires": []
   },
   {
       "id": "a5f386c3edce3e40",
       "type": "rpi-sensehatsim in",
       "z": "3f463f63dad2fe3c",
       "name": "",
       "motion": false,
       "env": true,
       "stick": false,
       "x": 220,
       "y": 120,
       "wires": [
           [
               "f74e9fbc25b41660"
           ]
       ]
   },
   {
       "id": "f74e9fbc25b41660",
       "type": "function",
       "z": "3f463f63dad2fe3c",
       "name": "",
       "func": "msg1 = {payload: msg.payload.temperature, topic: \"env.outside.temperature\"};\nmsg2 = {payload: msg.payload.humidity, topic: \"env.outside.humidity\"};\nmsg3 = {payload: msg.payload.pressure, topic: \"env.outside.pressure\"};\n\nreturn [[msg1,msg2, msg3]];",
       "outputs": 1,
       "noerr": 0,
       "initialize": "",
       "finalize": "",
       "libs": [],
       "x": 600,
       "y": 120,
       "wires": [
           [
               "407fe70a51278625",
               "7ef4965869c94839"
           ]
       ]
   },
   {
       "id": "7ef4965869c94839",
       "type": "signalk-send-pathvalue",
       "z": "3f463f63dad2fe3c",
       "name": "",
       "source": "temp",
       "meta": "",
       "x": 850,
       "y": 140,
       "wires": []
   }
]

More info in here > https://githubhelp.com/SignalK/node-red-embedded


RE: Node red -> signalK. Data not showing - kniven - 2022-02-01

That function block was exactly what i needed.  Smile


RE: Node red -> signalK. Data not showing - PaddyB - 2022-02-01

(2022-02-01, 04:57 PM)kniven Wrote: That function block was exactly what i needed.  Smile



Cool


RE: Node red -> signalK. Data not showing - kniven - 2022-02-01

So, to recap. There is a bug in the node-red implementation. When selecting BOTH of the outputs "environment" and "motion" from the sense hat, only the motion data was available in node-red...

I found the solution here:

The solution was to change the default python from python3 to python2 (python) in this file


Code:
sudo nano ./.signalk/red/node_modules/node-red-node-pi-sense-hat/sensehat

and change this line  

Code:
#!/bin/bash

python_cmd='python3'
to
Code:
#!/bin/bash

python_cmd='python'

Great result. Thank you PaddyB for your help