ioBroker Datapoints Read / Write in a function-Node in javascript How to do?

Hello,
all attempts to read or write the data points from the ioBroker within a function node have failed so far.
The "Node ioBroker IN/OUT" works of course but the same in a "function Node" in javascript does not work by any way.
Googling doesn't help either.

Can someone please post simple examples ? :grinning:

More details:

I use this javascript in the function Node without success :slight_smile:

`//var data = { payload : javascript.0.Rollladen_OG.Rolllade_OG1};

//var data = parseInt(data, 16)

//var data = getState('javascript.0.Rollladen_OG.Rolllade_OG1').val;

//var data = get('javascript.0.Rollladen_OG.Rolllade_OG1').val;

//var data = get(javascript.0.Rollladen_OG.Rolllade_OG1, );

//var ioBroker = global.get('ioBroker');

//var data = global.get('javascript.0.Rollladen_OG.Rolllade_OG1');

//var data = iobroker.get("javascript.0.Rollladen_OG.Rolllade_OG1").val;

var data = global.get("javascript.0.Rollladen_OG.Rolllade_OG1");

msg.payload = data;

return msg;
`

Before you can get data from context (global.get) it has to be there. How are you saving that data to context? With your code it looks as if you try to get the content of the topic from another unrelated message? To get that using the context, you first have to save it there. Another way is to feed that message to a function node, eventually using a change node (set msg,payload to msg.topic) or simply do that with code inside the function node

Instead of bringing up unclear code and incomplete examples, better describe with reasonable description what you would like to achieve

Hallo krambriw,
My problem is to read an existing iobroker data-point within the "function-Node" using javascript.
Unfortunately, "getState" - command is not available in the function-Node.
I just want to read the value. The topic is "javascript.0.Rollladen_OG.Rolllade_OG1" and the readout works fine with the Node "ioBroker get".
Bur only in the function-Node manually read the value is not possible... ( for me )
I need only the simple javascript. I hope it is easy for a profi. I´m a beginner, sorry.
Thank´s a lot krambriw !!!

Unfortunately it is most likely much more needed if you want that. The node might use some software libraries, api's, protocols or other kind of methods to communicate with the iobroker

One way to find out is to study the javascript code of the iobroker node you are talking about and have installed. You should find the node in the .node-red/node_modules directory. There you should also find the folder for the node. Inside you should have a .js file that can be studied to understand how it works. With this knowledge it should then be possible to write code in a function code doing what you are looking for but that is not done during a short coffe break

EDIT: you could also look for alternative ways to communicate with ioBroker, like MQTT

The javascript-Code of this "Node - iobroker_ get" is there: ioBroker.node-red/nodes/ioBroker.js at master · ioBroker/ioBroker.node-red · GitHub
But I can not reduce this code for a simple use like the following example:

Is anyone able to write the desired software extract? Thanks!