In my script, there is a global variable named "ccu-192_168_30_22" which holds the following data:
{
"values": {
"VirtualDevices.INT0000001:1.CONTROL_MODE": {
"topic": "",
"payload": 0,
"deviceName": "F2-1315.03",
"datapoint": "CONTROL_MODE",
"room": "F2"
},
"HmIP-RF.00201BE9A13271:1.CONTROL_MODE": {
"topic": "",
"payload": 0,
"deviceName": "F02A-1315.02",
"datapoint": "CONTROL_MODE",
"room": "F02A"
},
"HmIP-RF.00265BE98E8C53:0.UNREACH": {
"topic": "",
"payload": 0,
"deviceName": "F1-1315.01",
"datapoint": "UNREACH",
"room": ""
}
}
}
I am trying to extract device names and rooms from objects with "datapoint": "CONTROL_MODE", using the code snippet provided below.
for (var device in global.get("ccu-192_168_30_22").values) {
if (device.datapoint == "CONTROL_MODE") {
list.push(device.deviceName);
list.push(device.room);
}
}
msg.payload = list;
return msg;
However, when I run this code, I only receive an empty array as msg.payload.