It shouldn’t be very difficult to implement that in an emonTx, but I didn’t suggest it because @m2ts specifically wants to calculate it in emonCMS, and similarly but in my case, it’s the internals of emonCMS that I’m (mostly) ignorant about.
Plus, we don’t know that he has an emonTx.
What you have written in the thread title is not the same as what you have presented using the numbers.
If your requirement is for what I would call the quarter-hour average maximum demand, then it’s relatively simple to do in the emonTx sketch. The sketch would need to accumulate the kWh values reported by emonLibCM (which you must use, in order not to miss the peak completely) over the quarter-hour period and average those, and report them to emonCMS. And the easy way to do that is to make the emonTx two Nodes, so the first NodeID reports the standard values every 10 s, the second reports every 15 minutes (and our RFM library can do that, or the standard serial interfacer; NOT the “EmonHubTx3eInterfacer”).
EmonLibCM could in theory report every 15 minutes, but there’s a danger that the internal variables could overflow - it was designed for and tested up to 5 minutes reporting interval.
If your requirement is exactly according to the thread title, then we need to know what is the averaging time that the meter will use? if it is the peak over 1 cycle (the practical minimum), then that’s quite unfair because a normal refrigerator draws a peak of something like five to ten times the running current for a few cycles on starting - it’s called “inrush” and it’s perfectly normal and largely harmless (to the system, because it’s of such short duration, though it can make a lamp flicker). I would think that you would need an averaging time at least an order of magnitude larger than an inrush peak, and I’d refer you to a recent post PV and night tariff + EV and immersion heater - #24 by dBC that indicates one specific type of meter works on a 1 second cycle. If your meter is the same, then you’d need to set that to report to the sketch every second, which it’s quite capable of doing, the sketch will need to record the maximum power and report that every quarter-hour, in the meantime accumulate those 1 s values and report the 10 s average values as normal.
This is not a completely new concept, when I was an apprentice 50 years ago, the firm I worked for was making a controller that could turn off non-essential loads if the half-hour average demand was predicted to exceed a set value - and this was using analogue electronics.