Heya,
I am trying to create a function that will update the name of a data point. I have successfully used a similar function to create a point but this one does not appear to work:
function updateDataPointName(deviceName, pointName, newName) {
var dataPoints = JSON.parse(JsonEmport.getConfiguration("dataPoints")).dataPoints;
// LOG.info(JSON.stringify(dataPoints));
function findByName(list, deviceName, pointName) {
for (var k = 0; k < list.length; k+=1)
if (list[k].deviceName === deviceName && list[k].name === pointName)
return list[k];
return undefined;
}
var point = findByName(dataPoints, deviceName, pointName);
if (typeof point === 'undefined') {
LOG.info('Could not find point with name '+deviceName+' - '+pointName);
}
else {
point.name = newName;
LOG.info(JSON.stringify(point));
JsonEmport.setImportDuringValidation(true);
JsonEmport.doImport(JSON.stringify({"dataPoints": [point]}));
}
}
The logs show that the point name is being changed but when I check the point in the data source, the name was not changed. I don't see any errors in the ma.log either.
Any suggestions? Can you change the data point name this way?
Thanks
Ian