Hi,
This is my first post, so please let me know if I'm doing something wrong.
I am using node-red v1.0.6 on a Raspberry Pi 4 B.
I am currently using a custom node module in my function nodes, imported by using the functionGlobalContext in the settings.js file. the js file is saved in /.node-red/custom_classes/Classes.js.
From the settings.js file:
functionGlobalContext: {
Classes : require('/home/pi/.node-red/custom_classes/Classes.js')
Here is what I'm currently doing in a function node (simplified):
const Classes = global.get('Classes');
let device1 = new Classes.Device();
let device2 = new Classes.Device();
let devices = [];
devices.push(device1);
devices.push(device2);
global.set("devices",devices,"file")
Then I am using the Device objects in other function nodes like this:
var devices = global.get("devices","file");
for (var device of devices) {
for (var tag of device.tags) {
console.log(tag.name);
}
}
This is working correctly, and i can access all the methods in the Device objects from the function nodes.
The problem is that when I reboot the raspberry pi, I get "TypeError: device.tags is not iterable". I am saving the devices array to file (using contextStorage) so I can see the devices array in the global context menu bar after reboot (see picture), with all field variables, but apparently I can't access the methods.
I don't know how to work this out, so any help with this is appreciated!