Emoncms.org Email Reports

A quick post to introduce a new module on emoncms.org which can be used to setup a weekly email report of home consumption and solar generation if you are monitoring solar.

The module can be found under the Extras tab top-right:

In the configuration interface you can enter an email title so that you can differentiate between report emails from different emoncms.org accounts such as a home energy monitor account and a office energy monitor account.

Up to 5 email addresses can be entered for work colleagues, family members, friends.

The email generator needs a cumulative kwh consumption feed (and solar if applicable), the same type of feed as used by the emoncms app module:

Click on ‘Send test email’ to check that it all works.

The weekly process that runs this at present runs at around 9am on Monday UTC time.

UK renewable energy
To make the emails a bit more interesting I’ve added the section on UK renewable energy in the last week which gives a quick overview of how much solar, wind and hydro was generated. I will add the option to hide this section for those outside of the UK where its less relevant.

Solar PV
There is a provisional solar pv report which Im still working on, I plan on adding imported energy readings and daily self consumption statistics.

Source code
The source code for this module is on github here: GitHub - emoncms/emailreport: Emoncms email report generator
Emails are currently sent using the emoncms.org email batch process, the module will not currently work on emonpi/emonbase installations but Id like to add support for this.

1 Like

This looks awesome Trystan - thanks for sharing!

I just tried to run it on my local emoncms install (latest pull from master) and I got the following error;

web@web01:~$ sudo php /home/web/emailreport/weekly-cron.php >> /var/log/emoncms/emailreport.log
PHP Warning:  require(Modules/log/EmonLogger.php): failed to open stream: No such file or directory in /home/web/emailreport/weekly-cron.php on line 10
PHP Fatal error:  require(): Failed opening required 'Modules/log/EmonLogger.php' (include_path='.:/usr/share/php:/usr/share/pear') in /home/web/emailreport/weekly-cron.php on line 10

So I updated weekly-cron.php to look for EmonLogger.php in /Lib and then got the following error;

PHP Fatal error:  Cannot redeclare class Rememberme in /var/www/emoncms/Modules/user/rememberme_model.php on line 3

I am pretty hopeless when it comes to PHP but I am wondering if this new script needs some sort of dev branch of emoncms? Or am I just doing something stupid?


Didn’t Trystan write

I read that as saying the the module will be coming to a locally hosted version, but at present it is for emoncms.org (the OEM-hosted website) only.

The reason presumably is that although emonCMS & emoncms.org perform much the same function, there are distinct differences in their implementation.

Thanks @ben.jones12,. Yes, there are a number of things to work on to make this work on emonpi/emonbase type installs. I will update when I get a chance to do so.

Not related to the errors you have above, but a question related to the next step, Have you setup the SMTP email settings on your system? Do password reset emails work for you? The default setting on the emonpi/emonbase has this disabled.

From comments I’ve read here recently, that might mean a ‘plug-in’ to suit the various email servers that various hosts provide, or allow, or (apparently in some cases) don’t allow.
(see Could not find SwiftMailer and SwiftMailer error)

@TrystanLea I have configured $smtp_email_settings to use my local mail server but when I try a password reset I get the following in the logs;

2017-07-09 23:49:07.989|ERROR|email.php|check() Could not find SwiftMailer, email functions are ignored.
2017-07-09 23:49:07.989|ERROR|email.php|check() Could not find SwiftMailer, email functions are ignored.
2017-07-09 23:49:07.989|ERROR|email.php|check() Could not find SwiftMailer, email functions are ignored.
2017-07-09 23:49:07.989|ERROR|email.php|check() Could not find SwiftMailer, email functions are ignored.
2017-07-09 23:49:07.989|ERROR|user_model.php|0 message='Could not find SwiftMailer, email not sent.'

FYI it appears I have swiftmailer installed;

root@web01:/var/www/emoncms# pear channel-discover pear.swiftmailer.org
Channel "pear.swiftmailer.org" is already initialized

@ben.jones12, try editing L16 of emoncms/Lib/email.php

remove “Swift/” so that it points to just “swift_required.php” like so

    // include SwiftMailer. path from a PEAR install,
    $this->have_swift = @include_once ("swift_required.php");

When swiftmailer is installed, it does not install “swift_required.php” inside the “Swift” folder, it installs to the same folder AS the “Swift” folder

pi@emoncmsPi: $ ls -la /usr/share/php/{{S,s}wift*.*,Swift/{S,s}wift*.*}
-rw-r--r-- 1 root root  735 Jun 13 18:20 /usr/share/php/swift_init.php
-rw-r--r-- 1 root root 2110 Jun 13 18:20 /usr/share/php/Swift.php
-rw-r--r-- 1 root root  693 Jun 13 18:20 /usr/share/php/swift_required.php
-rw-r--r-- 1 root root  536 Jun 13 18:20 /usr/share/php/Swift/SwiftException.php

Thanks @pb66 that seems to have done the trick - I can get Emoncms to send password reset emails. Thanks!

Indeed he did. I read that as meaning there was a new module, available to all, which had been deployed to emoncms.org for those using that platform.

I was obviously wrong and you were right however! All good, happy to wait, but looking forward to it as it looks to be a very cool new feature.

Sorry for jumping the gun :).

Thanks @ben.jones12, @daturach. I will make that uk grid feature optional and provide the option to set a region/country average for comparison.

@Tehnoinstyle_Aleksey I think your error is also relating to the use of redis for the uk energy stats. I will update with a fix soon

Appreciate you making those changes @TrystanLea - I just pulled and tried again but got the following;

Fatal error: Call to a member function get() on boolean in /home/web/emailreport/emailreport-module/emailreport_controller.php on line 62

I don’t have redis enabled on my install and that line seems to correspond to;


The good news is I was able to save the email report config in the web UI (which wasn’t working previously) so we are making progress!!

I managed to get the email to send by removing all references to ukenergy in both emailreport_controller.php and emailreportgenerator.php.

Could I be cheeky and ask for an option to disable this part of the email since it has no relevance to us folk outside of the UK?

Really very cool feature tho - going to get some good use out of this!

Thanks for adding this email feature.

Regarding "UK household average " value, would it be possible to add a variable so that we can compare our consumption to another country?

thanks again for all your work.

Hey @TrystanLea

I have the EmonCMS 9.8.7 set on the Synology NAS. I try to install the module, but I do not know how to make a symlink on Synology NAS.


Symlink the web part of the emailreport module into emoncms/Modules, if not using Raspberry Pi replace ‘pi’ with your home folder name:

ln -s /home/user/emailreport/emailreport-module /var/www/emoncms/Modules/emailreport

What will the command look like in my case?

EmonCMS Installed along the path:


Module emailreport Installed along the path:




Thank you.

P.S. I moved all the files from
to /volume1/web/emoncms/Modules/emailreport
and the module started work. But I received an error message:

Fatal error: Uncaught Error: Call to a member function get() on boolean in /volume1/web/emoncms/Modules/emailreport/emailreport_controller.php:62 Stack trace: #0 /volume1/web/emoncms/core.php(64): emailreport_controller() #1 /volume1/web/emoncms/index.php(180): controller('emailreport') #2 {main} thrown in /volume1/web/emoncms/Modules/emailreport/emailreport_controller.php on line 62

A quick note to say that I’ve fixed a number of bugs that became apparent on this weeks email out. Pushed all changes to the master branch on github.

I havent yet had a chance to make it possible to disable the uk energy stats.

@Tehnoinstyle_Aleksey I think the error your getting relates to the line requesting the uk energy stats from redis, once I’ve sorted an option to toggle that it should work for you.

Hi @TrystanLea

I updated the version of the emoncms to 9.8.8 and, accordingly, all the modules, including the mailreport. But again errors, and the module does not work for me.

What am I doing wrong?

P.S. I removing all references to “ukenergy” in both emailreport_controller.php and emailreportgenerator.php I got a preview:

But I can not send mail, get an error:

How to fix it? Thank you.

Hello @Tehnoinstyle_Aleksey I appreciate your enthusiasm but your moving too fast :slight_smile: The errors you are getting I think are as a result of redis being missing on Synology NAS. I mentioned I hadnt yet had a chance to develop the ability to switch uk energy stats off and the primary development target is emoncms.org then followed by emonpi/emonbase installs and so redis is currently a requirement. Please wait a little longer :slight_smile:

Ok, tell me please, when he’ll be ready.

I can try to install Radis if required. Install Redis on Synology

But I would like without it.

11 posts were split to a new topic: Email reports: pcharts licencing