Dust and Pollution - How to add new functions like NowCast

Hi friends and helpers

I would like to create a Json or curl function on EmonCMS, to be used from an Arduino to compute the NowCast Dust level as per the AQI methodology. It requires first to compute the Hourly average then to compute the NowCast of the last 12 hours. Where to add this kind of function ? Does anyone has build that already ?

Thank you very much.

Dan

function NOWPM25(hourly)
{
	
	var hour12Avg = 0
	var nowCast = -999
	var hour4Avg = 0
	var ratioRecentHour = 0
    var adjustedhourly=new Array(12);
    var items = 12
    var missing12 = 0
    var missing4 = 0
    var adjusted4hour=new Array(4);
    var averagearray=new Array(12);
    var items4 = 0
    var max =0.0
    var min = 99999.9
    var range = 0
    var rateofchange = 0
    var weightfactor = 0;
    var sumofweightingfactor = 0;
    var sumofdatatimesweightingfactor =0
    var nowcast = 0;
// Find the number of missing values
// 
	 missing12=0;
	 missing4 =0;
	 items3 = 3;
	 
 for (i = 0; i < items3;i++)
 {

    if(hourly[i] == "")
    {
	    missing4++
	}
 }
 
 if(missing4 < 2)
 {
	 
 for (i = 0; i < items;i++)
	{
		if(hourly[i] !== "")
		{
		 if(hourly[i] < min)
		 {
		 	min = hourly[i]
		 }
		 if(hourly[i] > max)
		 {
			max = hourly[i]
	  	 }
  	   } 
	}
 
	 range = max - min;
	 rateofchange = range/max
	 weightfactor = 1-rateofchange
	  
	 if(weightfactor < .5 )
	 {
		 weightfactor = .5
	 }
	 /// step 4 here.
	 for (i = 0; i < items;i++)
	 {
     	if(hourly[i] !== "")
     	{
	     	sumofdatatimesweightingfactor += hourly[i]*(Math.pow(weightfactor, i));
	 		sumofweightingfactor += Math.pow(weightfactor, i);
 		}
 	}
	nowCast = sumofdatatimesweightingfactor/sumofweightingfactor
 
         nowCast = Math.floor(10*nowCast)/10
 	     
 }
 	return (nowCast)

 }