regenerate kwh data

Help!

I upgraded to version 9 rc2 from git. Since then my kwh data reset back to zero.

New data is adding correctly and as expected now increasing again - a nice sawtooth pattern.

Is there anyway to recreate all the data by processing the raw "feed to log" data - both are phpfina's

I also need to do the same for all the subsequent data feeds

Any thoughts?

Paul Reed's picture

Re: regenerate kwh data

Yes I had (have) the same problem...

Trystan commented about this here, but it didn't work for me.
However, my 'feed to log' was phpfiwa, so please let us know if it works for you.

Paul

octagon's picture

Re: regenerate kwh data

The other wrinkly is that if I use the "live" feed view and zoom out to the "hour" view

i get no data.. just blank - any fixes ?

I'll try trystans re-generation script later. Hopefully there's similar for the kwh/d and the histograms...

octagon's picture

Re: regenerate kwh data

Running the process script and it chucks out a few errors

Warning: unpack(): Type f: not enough input, need 4, have 0 in /var/www/emoncms/usefulscripts/process/Lib/PHPFina.php on line 320
PHP Warning:  unpack(): Type f: not enough input, need 4, have 0 in /var/www/emoncms/usefulscripts/process/Lib/PHPFina.php on line 320

 

Will let you know how it finishes..

Paul Reed's picture

Re: regenerate kwh data

...this is an issue that really could do with sorting.

For example, below is my 'Power to kWh' feed, and as you can see, everytime there is an interruption to the network, the accumulative totals drop - meaning negative values in 'my power' and a distorted view of imported power.

 

Paul

octagon's picture

Re: regenerate kwh data

yeap that looks like mine - but i only have 2 drops - last time the clock changed and this upgrade.

But I'm running it all locally so the "network" is only from the emontx to the raspberry.

the processing seems to be taking a while so I'm testing the time it will take over night. do the proper fix tomorrow...

Any ideas on the zoom out issue - its really annoying not getting the "hour" view. Is it because its a fina and it should be a fiwa ?

octagon's picture

Re: regenerate kwh data

Paul - the network interruption is that on the original log to feed and the impact of that is being felt in the output of the power to kwh? 

Does the log to feed get upset when there is no data for a given timestamp? is it a fixed time data record type issue? my initial log to feed is a REALTIME / PHPFINA data source - what's yours?

Perhaps the other question is - what should it be ?

Paul Reed's picture

Re: regenerate kwh data

The network interruption is where I've unplugged to ethernet cable, disconnecting the Pi from the LAN (my router only has 2 ethernet ports - one is used for VOIP full time, and the other I've needed to occasionally share with another project I've been working on). The dips seem to coincide with when the LAN is disconnected.
The original log to feed is a realtime phpfiwa feed, and that looks completely normal, with no changes whatsoever when the 'power to kwh' feed shows the dips.

This is more a minor annoyance for me, hence I haven't looked too far into it, however to others it could present a considerable issue if that data is important.

Paul

octagon's picture

Re: regenerate kwh data

is your Pi reporting the data across to a remote emoncms then?

Mine is doing it all locally - hence less issues i guess.

I'm sure that the power to kwh will have a knock-on impact on the kwh/d process and the histogram's that i'm running as well. Yes for me the data is important - using it to build a case to get an battery to increase my self-consumption...

PS you can get a network switch to solve your 2 port issue ;-) 

Paul Reed's picture

Re: regenerate kwh data

I'm not reporting to a remote emoncms, just need the LAN connection for apache to serve up the website.

If I run the script (just tried again), I get;

pi@raspberrypi ~/usefulscripts/process $ sudo php power_to_kwh.php
Power to kWh processor feed 14 -> feed 41
Recalculated in 71s
pi@raspberrypi ~/usefulscripts/process $

And the graph looks exactly the same.

Paul

octagon's picture

Re: regenerate kwh data

71s? What are you running it on?

mine hasn't finished yet.

So a regeneration won't fix it - probably related to all the errors

Warning: unpack(): Type f: not enough input, need 4, have 0 in /var/www/emoncms/usefulscripts/process/Lib/PHPFina.php on line 320

The issues must be in the source data - or how the missing data is being handled 

who knows most about that PHPFina.php code?

 

TrystanLea's picture

Re: regenerate kwh data

I've implemented what I think should be a fix for the error on line 320 of PHPFina, but I dont think this is the cause of the larger issue. Can there be a large negative spike at that point in the power feed?

It may be possible to get around this issue with an extra line after line 67: https://github.com/emoncms/usefulscripts/blob/master/process/power_to_kw...

if ($kwh_inc<0) $kwh_inc=0;

but ideally it would be good to know whats causing the large negative $kwh_inc values

Paul Reed's picture

Re: regenerate kwh data

Mine runs from a powered hub, which also powers the USB HDD too.
Whenever I shut down the pi, I always use sudo poweroff, and ensure that it's completed it's shutdown before removing the power.
So no idea where the spike is coming from.
Didn't you experience the same issue when you installed v9 too.

Paul

octagon's picture

Re: regenerate kwh data

trystan - thats  not fixed it. I added an extra line of debug -> 

            if ($last_time && ($time-$last_time)<7200)
            {
                // kWh calculation
                $time_elapsed = ($time - $last_time);
                $kwh_inc = ($time_elapsed * $power) / 3600000.0;
                if ($kwh_inc<0) {
                        print "Weird low spike power =  last time=$last_time, time=$time, power=$power, kwh_inc = $kwh_inc\n";
                        $kwh_inc=0;
                }

                $kwh += $kwh_inc;

but that debug never appears - but still getting the same error. 

Adding some more debug its actually the read 

    while ($dp = $engine[$source_engine]->readnext($source))

that is throwing the error. (added debug at the beginning and end of the loop...)

 

TrystanLea's picture

Re: regenerate kwh data

@Paul I think that was a separate issue to do with existing power_to_kwh feeds, my solution was to recompile using the script?

@Octagon, what error exactly is while ($dp = $engine[$source_engine]->readnext($source)) throwing. It's not using the lastvalue function in which "Warning: unpack(): Type f: not enough input, need 4, have 0 in /var/www/emoncms/usefulscripts/process/Lib/PHPFina.php on line 320" originated?

octagon's picture

Re: regenerate kwh data

Notice: Trying to get property of non-object in /var/www/emoncms/usefulscripts/process/Lib/PHPFina.php on line 422
PHP Notice:  Trying to get property of non-object in /var/www/emoncms/usefulscripts/process/Lib/PHPFina.php on line 422

the read is now responsible for that above !

Seems we have moved the target. 

 

 

 

octagon's picture

Re: regenerate kwh data

Ah that one was my bad. I'd copied the original feed I wanted to process so that emon could continue running, But i'd not done the meta data...

Now my debug is working I get output like : 

Weird low spike power =  last time=1405761350, time=1405761360, power=-113, kwh_inc = -0.00031388888888889
Weird low spike power =  last time=1405761360, time=1405761375, power=-87, kwh_inc = -0.0003625
Weird low spike power =  last time=1405761375, time=1405761385, power=-68, kwh_inc = -0.00018888888888889
Weird low spike power =  last time=1405761385, time=1405761395, power=-86, kwh_inc = -0.00023888888888889

I produce a chunk of electricity from the PV. My graphs can go "negative" because of the amount i pump out...

 

 

 

 

octagon's picture

Re: regenerate kwh data

careful timing caught this :

Weird low spike power =  last time=1409501355, time=1409501365, power=-28, kwh_inc = -7.7777777777778E-5
Weird low spike power =  last time=1409501365, time=1409501375, power=-20, kwh_inc = -5.5555555555556E-5
Weird low spike power =  last time=1409501395, time=1409501410, power=-6, kwh_inc = -2.5E-5
PHP Warning:  unpack(): Type f: not enough input, need 4, have 0 in /var/www/emoncms/usefulscripts/process/Lib/PHPFina.php on line 320

Warning: unpack(): Type f: not enough input, need 4, have 0 in /var/www/emoncms/usefulscripts/process/Lib/PHPFina.php on line 320
Weird low spike power =  last time=1409557125, time=1409557135, power=-7, kwh_inc = -1.9444444444444E-5
Weird low spike power =  last time=1409557135, time=1409557145, power=-7, kwh_inc = -1.9444444444444E-5

octagon's picture

Re: regenerate kwh data

well it ran - now looks as if something had eaten a small slice !

Going to re-run without the kwh_inc resets and see what happens.

octagon's picture

Re: regenerate kwh data

OK the graph looks better now.

Now when I'm exporting it does what I'm expecting - not add it onto the consumption :)

still annoying to get those huge "anti-spike"s in the data

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.