Dirk SV MOIN - Hi, I am new to Node Red and how...

Hi, I am new to Node Red and how to interact with SignalK data. What I would love to do: Telegam Chatbot receives /SOC and sents electrical.batteries.0.capacity.stateOfCharge back. Is there a node where I "only" can read data? The SingalK-Subscribe node permanently sents data and this is not what I am looking for, I am looking for return value when asked for it. Thanks a lot.
4 Replies
Scott Bender
Scott Bender•3w ago
in a function you can do this:
let app = global.get('app')

let volts = app.getSelfPath('electrical.batteries.house.voltage.value')
let app = global.get('app')

let volts = app.getSelfPath('electrical.batteries.house.voltage.value')
Dirk SV MOIN
Dirk SV MOINOP•3w ago
Thanks a lot, seems I have to find now how to convert a number to a string 🙂 hmm, seems "volts" is an object. how can I access it's value?
Scott Bender
Scott Bender•3w ago
volts.value or wait see in my example above? the path? make sure you have .value
Dirk SV MOIN
Dirk SV MOINOP•3w ago
Thanks, that was the trick. It seems not to be niced code, but this works: let app = global.get('app') let soc = app.getSelfPath('electrical.batteries.0.capacity.stateOfCharge.value') let res = Math.round(soc*100); let res2 = res.toFixed(0); res2 += "% State of Charge"; msg.payload.content = res2; return msg;
Want results from more Discord servers?
Add your server