How to accumulate watt Hours correctly from an input?

I suspect there is a way of extracting the quarter-hourly data once the raw data is in a feed inside emonCMS, but I think that is not going to work with your design as you have it at present. In any case, I do not know emonCMS well enough to be able to tell you what to do.

What is this RTC? Having two clocks in a system is a well-known problem with the emonTx/emonTH and emonCMS and is the reason why those always send their data is just less than the feed rate in emonCMS.

emonCMS runs on Internet time, so if you were to send a message to your '328P energy monitor to tell it to send it’s accumulated energy values immediately, your synchronisation problem would disappear.

That is how I read the code - you can look for yourself if you wish. I happen to have it in my editor:

    public function wh_accumulator($feedid, $time, $value)
    {
        $max_power = 60000; // in Watt
        $totalwh = $value;
        
        global $redis;
        if (!$redis) return $value; // return if redis is not available

        if ($redis->exists("process:whaccumulator:$feedid")) {
            $last_input = $redis->hmget("process:whaccumulator:$feedid",array('time','value'));
    
            $last_feed  = $this->feed->get_timevalue($feedid);
            $totalwh = $last_feed['value'];
            
            $time_diff = $time - $last_feed['time'];
            $val_diff = $value - $last_input['value'];
            
            if ($time_diff>0) {
                $power = ($val_diff * 3600) / $time_diff;
            
                if ($val_diff>0 && $power<$max_power) $totalwh += $val_diff;
            }

            $padding_mode = "join";
            $this->feed->insert_data($feedid, $time, $time, $totalwh, $padding_mode);
        }
        $redis->hMset("process:whaccumulator:$feedid", array('time' => $time, 'value' => $value));

        return $totalwh;
    }