@Macguyver
As said, the screenshots helped a lot, and their was a surprise included.
I had expected that the array, created by the html node would contain 114 elements, but it does not. It contains 115 elements.
Your first included screenshot at March 12, 17:45 did not include the copyright notice from 2013 Altenergy Power System Inc.
In the array, this is in element 114. So the length of the array, which is used to determine the number of loops over the array, is not 114, but 115 [0-114].
Also the screenshot of the debug output below the table of March 12, caused the trouble.
As you can see, e.g, the temperature was presented as "15 oC". As I explained in the previous post, if I want to keep only 15, I have to chop 8 characters off. (So .slice (0,-8)).
The number of loops over the array is calculated as follows:
Code: Select all
for (i = 0; i < (msg.payload.length-7)/12; i++)
The number of iterations was 10, based on (115 - 6)/12 = 9.08 (until i>9.08). However it should have been 9.
Therefore I changed the value to msg.payload.length-7, which is 108/12 and is exactly 9.
That extra, unwanted, loop causes the error message.
I also changed the values, so that the unnecessary space in front of the figure is removed, as well.
I commented out unused variables.(//). Ifyou want, you can delete them.
I do not understand, why that screenshot with "15 oC" has turned to a normal value.
So below you will find the new contents of the first Function node
Code: Select all
var i;
for (i = 0; i < (msg.payload.length-7)/12; i++) {
var InverterIDA = msg.payload[12*i+6];
var CurrentPowerA = msg.payload[12*i+7];
var GridFreqA = msg.payload[12*i+8];
var GridVoltageA = msg.payload[12*i+9];
var TempA = msg.payload[12*i+10];
//var DateA = msg.payload[12*i+11];
//var InverterIDB = msg.payload[12*i+12];
var CurrentPowerB = msg.payload[12*i+13];
//var GridFreqB = msg.payload[12*i+14];
var GridVoltageB = msg.payload[12*i+15];
//var TempB = msg.payload[12*i+16];
//var DateB = msg.payload[12*i+17];
newMsg = {payload: ([InverterIDA.substr(0,12),CurrentPowerA.slice(1,-2),GridVoltageA.slice(1,-2),CurrentPowerB.slice(1,-2),GridVoltageB.slice(1,-2),GridFreqA.slice(1,-3),TempA.slice(1,-3)])}
node.send(newMsg);
}
If that all is running fine, we shall look to the overview page.
Best regards