Kwh not updated in bulk update

@TrystanLea,

I’m not sure the status of this problem. We’ve talked about it before, but it occurs on every significant WiFi recovery and I’ve seen it in all of the systems I have running. The problem is that when recovering from an extended WiFi outage (hours or days), the Kwh feed does not update.

Most of the input processes are just “log to feed” followed by “Power to Kwh”. These processes seem to work fine when posting several intervals at once, as I ordinarily do. But when uploading a lot of data, the Kwh feed does not seem to accumulate, even though the power feed is updated fine.

I’m pretty certain the updates are presented in chronological order. The nature of the code that sends the updates is that it works through the log file, which is in chronological order. This is the exact same code and process that is used in normal updating. The only difference is that it groups more entries into one GET request. All of the data seems to be arriving at the input and is posted OK to the power feed. It just doesn’t seem to get added to the Kwh feed.

I suspect this has to do with the time increment attributed to the data when posting to Kwh. If that is somehow zero instead of 10 seconds, the result would be what we see here - zero Kwh for the period.

Can you take a look at that code when you get a chance?

Hello @overeasy, I think I have found the source of this issue and have implemented the fix this morning, I was using the time of the processing script where I should have been using the time of the input:

    if ($last_time && ((time()-$last_time)<7200)) {
        // kWh calculation
        $time_elapsed = ($time_now - $last_time);
        $kwh_inc = ($time_elapsed * $value) / 3600000.0;
    } else

changed to:

    if ($last_time && (($time_now-$last_time)<7200)) {
        // kWh calculation
        $time_elapsed = ($time_now - $last_time);
        $kwh_inc = ($time_elapsed * $value) / 3600000.0;
    } else

Hopefully that should work fine on the next outage

Thanks, I’ll let you know one way or the other after the next event.

One of my sites just recovered from a 12 hour WiFi outage. Both Power and Kwh recovered 100% of the data. Case closed. Thanks.

great to hear!