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:
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.
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?
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.'
@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
P.S. I moved all the files from /volume1/web/emoncms/Modules/emailreport/emailreport-module
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.
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.
Hello @Tehnoinstyle_Aleksey I appreciate your enthusiasm but your moving too fast 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