OpenMarine
How to insert unit with signalk sentence from node-red - 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: How to insert unit with signalk sentence from node-red (/showthread.php?tid=3337)



How to insert unit with signalk sentence from node-red - jamos.tan@gmail.com - 2021-03-16

Hi,

I am using an ina219 and report three sentences to signalk:

- electrical.batteries.system.voltage
- electrical.batteries.system.current
- electrical.batteries.system.power

In SignalK data browser you'l then get some of them to report units, like so:

Voltage: V
Current: A
Power: (no unit)

I decided that I wanted to change the last two of the sentence names, as follows:

- electrical.batteries.system.voltage (unchanged)
- electrical.external.connections.current (changed)
- electrical.external.connections.power (changed)

But then, the unit for electrical.external.connections.current disapeared, so there is no "A" anymore. And, it wasn't there for the power (W , for watts) in the first place.

My question is, looking at my flow, how can I make sure I can add specific units? Or is this a process that is automatic in SignalK?


Code:
[{"id":"4a1d7508.60855c","type":"tab","label":"12v","disabled":false,"info":""},{"id":"5d9fe981.6e7708","type":"signalk-send-pathvalue","z":"4a1d7508.60855c","name":"","source":"","x":750,"y":140,"wires":[]},{"id":"f3918cff.9c8ab8","type":"function","z":"4a1d7508.60855c","name":"current&power","func":"msg.topic = \"electrical.external.connections.current\";\nmsg.payload = Number(msg.payload)/1000;\nnode.send(msg);\nmsg.topic = \"electrical.external.connections.power\";\nmsg.payload = Number(flow.get('voltage'))*Number(msg.payload);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":460,"y":200,"wires":[["5d9fe981.6e7708"]]},{"id":"4ac9724a.23dc94","type":"function","z":"4a1d7508.60855c","name":"voltage","func":"msg.topic = \"electrical.batteries.system.voltage\";\nflow.set('voltage', msg.payload);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":420,"y":140,"wires":[["5d9fe981.6e7708","d116b1fc.857e3"]]},{"id":"9dd53318.b65b58","type":"ina-sensor","z":"4a1d7508.60855c","name":"","handle":"5072781c.9046f8","x":230,"y":140,"wires":[["4ac9724a.23dc94","67437216.a422bc"],["f3918cff.9c8ab8","67437216.a422bc"]]},{"id":"d116b1fc.857e3","type":"ui_gauge","z":"4a1d7508.60855c","name":"","group":"ccbcb301.5f66f","order":1,"width":0,"height":0,"gtype":"gage","title":"System voltage","label":"volts","format":"{{value}}","min":0,"max":"15","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","x":730,"y":60,"wires":[]},{"id":"67437216.a422bc","type":"debug","z":"4a1d7508.60855c","name":"","active":true,"tosidebar":false,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":380,"y":280,"wires":[]},{"id":"5072781c.9046f8","type":"ina-sensor-manager","address":"0x40","delay":"1000","ohms":"0.01","customResistor":true},{"id":"ccbcb301.5f66f","type":"ui_group","name":"Dashboard","tab":"8715a7c2.f768b8","order":1,"disp":true,"width":"6","collapse":false},{"id":"8715a7c2.f768b8","type":"ui_tab","name":"Home","icon":"dashboard","disabled":false,"hidden":false}]

Going through http://signalk.org/specification/1.2.0/doc/signalk.pdf I guess I am already answering my own question. Am I right in assuming the following is correct?

/vessels/<RegExp>/electrical/inverters/<RegExp>/ac/appa
rentPower
Units: W (Watt)
Description: Apparent power.

Googling it says:

Apparent power is the combined power value that is obtained by allowing for the different values of current and voltage. Essentially, this measurement is found by multiplying the applied voltage to the current generated. Most electrical systems operate by the use of apparent power.

In my node-red flow I can indeed see that it is calculated or derived from the voltage and current.
I'll change the sentence to it and see if the W will appear.

No, im wrong this is only for AC. Also changing to electrical.batteries.ext-connections.apparentpower doesnt add the W.
So, hope anybody got the answer for me. Smile