Email report complains has not enough data, while it has

Hi

Some days ago installe the module in my emonSD running in a Rpi2 following the instructions provided.
Installed swiftmailer and updated&Checked the database.

All seemed to work but I get the following warning:

Not enough days returned in data request
Warning: Cannot modify header information - headers already sent by (output started at /home/pi/emailreport/emailreport-module/emailreportgenerator.php:51) in /var/www/emoncms/index.php on line 265

Notice: Array to string conversion in /var/www/emoncms/index.php on line 266
Array

If I exectute the script “by hand”:

sudo php /home/pi/emailreport/weekly-cron.php

I get the following:

Sending energy update emails

  • Myemoncmsusername
    Not enough days returned in data request
  • Myemoncmsusername

For the avoidance of doubt: I have more than 3 weeks of data on the selected feed.
Same feed works in emoncms.org despite I’m not getting the automatic email (But I get the ttest email…)

Any clue?

Thank you in advance

In general that error message indicates text before a web page declaration header.

Here’s an explanation with details:

Thanks a lot for your answer

Problem is that I’m spooted in previous step “Not enough days returned in data request”

But I do have plenty of data…

Any clue?

Thanks in advance

The line “Not enough days returned in data request” can be generated in 3 different places in the code so I cannot be 100% sure where it is tripping up. I have no idea why they would be identical messages and have submitted a PR to change 2 of the 3 messages.

1 Like

Assuming you have 3wks data for both the solar and use feeds, I suspect this might be caused by the changes made to the core feed api’s. I do not know that for sure, but the code used to work and it it’s now possibly not returning the right number of days data, that is too coincidental to overlook.

Some background in the “Could not do basic feed API query - #12 by CDuffy” thread.

You could try commenting out this line in emailreport/emailreport-module/emailreportgenerator.php

as it looks like there has now been a “+1 day” added to the feed api so maybe there are 9 days being returned that the fail the “if != 8” tests.

otherwise you could try editing those "8"s directly to see it you can workout how many datapoints are being returned

just be sure to use the same number for those last 2 otherwise the next check will fail

1 Like

Thanks a lot for such an answer!!!

Changing each !=8 by !=9 did it!

Now it generates the preview thus it is not sending the email nor seeing any log with the error.

I will open another thead re this error in order to keep it clean.

Than you very much!

Thanks for testing and reporting back. Can you tell me did commenting the $date->modify("+1 day"); line out not work or did you not try it?

Commented it. Did not work.
So uncommented it and tried the next thing (changing the 8 first to 7 and then to 6) did not work.
So changed it to 9 and yes… did it!

Rgds

I re-open comments in the thread.
As commented yesterday changing the:

(count($data)!=8)
by
(count($data)!=9)

Solved my problem of

Not enough days returned in data request

But one thing I did not notice yesterday is that the mail is sending 8 days of data (from Sunday to Sunday both included).

To be honest: this is something I can live with, but if there is going to be an update, I thought it was worth mentioning.

Rgds

You are right the expected days is 8, ideally the fix should be that the feed api requests 1 day less data as the recent core changes mean one extra day is returned for the same api call. Changing the “8” to “9” basically just allows the data to be the wrong number of days rather than fixing it properly.

That’s why I had hoped removing the “+ 1 day” would have worked hence my question about whether you had tried it. Hopefully @TrystanLea or @emrys will see this or the issue you raised on the emailreport repo (I have since added link back to here)

Also worth noting that when the fix is added, your local changes will block the git pull update. You will need to undo those edits or just use git stash to pull in the updates.

Reopened.
Same has started happening at emoncms.org today (or at least I noticed it today).

Error is:

Not enough days returned in data request Array

Rgds

thanks @Jujonet on emoncms.org it looks like there’s a difference between the result from the phptimeseries engine and phpfina, I see your using phptimeseries, I will investigate in closer detail.

I’ve modified the PHPTimeSeries get data DMY method to align with the way the PHPFina method works and it seems to have cleared the error for your account @Jujonet, here’s the commit in the emoncms master branch modify phptimeseries DMY fn to return same as PHPFina · emoncms/emoncms@3644e05 · GitHub

Now working.
Thanks a lot :slight_smile:

I’m getting this error with the last version of the emailreport and emonpi (low-write 9.9.5)

1 Like

Same!