Read node data from node-info pane


i'm currently writing a node to bring enocean to node-red.
enocean is an iot protocol. I'm facing following problem:

enocean telegrams come in different encodings. to know wich encoding is use by a device, it can send a learn telegram telling the receiver about the special encoding (called EEP). If you save that information you can then decode incoming data telegrams of that device. this process is called pairing.

i have implemented pairing by writing the information (EEP and sender id) into the nodes context.

Because the EEP used determines what information is encoded in the telegram, i can only give hints on what is encoded after i got the learn telegram.

it would be really nice to give specific help for a node and its payload content in the information pane, but for that i have to somehow access the nodes context data from the information or property pane.

is that possible? if yes how? if not do you have any idea how to gives users some hints based on context data?



in your oneditprepare function you can set .info - this will get added to any info already there (ie at the bottom). This can be a function rather than fixed text so you can return a variety of text based on some value of the config node selected.



thanks for your answer. i'm not sure i understand.

i get the part with oneditprepare and .info, but how do i get data from the node.context()?

in oneditprepare can i have node.contex().get("somekey")?

p.s.: it's not a config-node



no - context is on the server side... you are in the browser side so you just need to read it from either the ui (jquery $('#node-input-...) style to read direct from the user input or "this." style to read from the state.

1 Like


this." style to read from the state

does that mean i have access to the nodes state text? that might be an option... brilliant idea, i'll try that when i'm home.



no - it's the state of the configuration parameters of the node at editprepare time (ie all the things you can see in the configuration editor window you have set up) - but yes - console.log out "this" and see.



i found the following solution:

when you open the "context data" pane, there is a refresh button. that calls /context/node/ So in oneditprepare i can do:

oneditprepare: async function(){
  var res = await fetch("/context/node/"
  var json = await res.json()
  var eep = json.default.eep.msg = eep

perfect :smiley: exactly what i was looking for! thanks!

1 Like


This does of course mean you can't give that help until the node has been deployed and done something to store info in context. I hope you've considered how you'll help the user the very first time they encounter your node and have not deployed anything yet.



yes, sure. as long as there is no concrete eep tought in, i give directions how to teach in the sensors. only after the sensor is tought in, i want to give some help about what information will be in the payload, which is different for each sensor(EEP).