Community
OpenEnergyMonitor

Community

If Watt Feed goes to Zero Send Email

I have been trying to get my Emoncms to send an email if the Watt Feed goes to zero.

I have a breaker that is monitored. There are times, for reasons I cannot find yet, the breaker trips and my pool pump is now shut off.

I would like to have a feed monitor the pool feed and if it goes to 0 watts then send me an email.

I have tried many things and I cannot get it to work. The image is just my latest attempt.

Can someone help me?

Kemper

Hello @SpaceAce have you configured the email settings in settings.ini?
e.g in this section: https://github.com/emoncms/emoncms/blob/master/example.settings.ini#L53

In other posts that I have read it said to do it in settings.php.

I saw the email stuff in the settings.ini but I left the ini alone because all the other posts said .php.

I can try to mark out email stuff in php and open them in the ini and try it.

Kemper

1 Like

@SpaceAce
@TrystanLea

I’ve had email problems but in a different context to yours.
When I switched to the Oct 2019 image, I found that ssmtp did not work apparently because Buster no longer supports it and the Oct 2019 image is based on Buster.
I fixed my problem with msmtp.
For what it’s worth, here’s a copy & paste extract from my build notes …

How to add a Mail Transfer Agent (MTA) …

Previously ssmtp was used but this is no longer supported by Buster
msmtp is used instead … to install …

sudo apt-get install msmtp msmtp-mta mailutils

Now create the log file & open up permissions …

sudo touch /var/log/msmtp.log
sudo chmod 777 /var/log/msmtp.log

Now create the msmtp configuration file with the content shown …

sudo nano /etc/msmtprc

++++++++++++++++++++++

defaults
auth                 on
tls                     on
tls_trust_file  /etc/ssl/certs/ca-certificates.crt
logfile              /var/log/msmtp.log
account          gmail
host                smtp.gmail.com
port                587
from               [email protected]
user                [email protected]
password       ~~~~~~~~~~~~~
account default : gmail

++++++++++++++++++++++

Finally open up permissions with …

sudo chmod 777 /etc/msmtprc

Here’s a good ref…

[https://www.sylvaindurand.org/send-emails-with-msmtp/](https://www.sylvaindurand.org/send-emails-with-msmtp/)
 
Send a test message with …

echo "Message" | mail -s "Title" j~~~~~~~~~~~~.co.uk

And to read the log …      tail -f /var/log/msmtp.log   

I hope this is relevant and helps.

Some items in your post did help me get closer.
Now I get this error in the admin log area.

"2020-03-08 20:54:45.256|ERROR|eventp_processlist.php|No email address specified"

Kemper

@TrystanLea

Can you help with that?

@TrystanLea I have the triggers working.
I see this “No email address specified” in the eventp_processlist.php file at the end. So for some reason I am getting FALSE as the answer within the script. I am not an expert with code but I did look for some missing or incorrect things in the php file. Like section names and etc.
I even removed settings.ini and settings.php and even their default named files and my self hosted enomcms still worked. I am so confused about that. I have no other files in my installation or root with those names. I hope someone can help me. I am so close to making it work. Kemper

I realise that SwiftMailer has stopped being available via pear/pecl and we dont include as standard on the latest emonSD either. I’ve made a minor modification to the emoncms master branch to support installation of swiftmailer in the new emoncms directory structure.

The steps to get email up and running is now:

1. Install SwiftMailer, SSH into the pi or EmonScripts based system:

git -C /opt/emoncms/modules clone -b 'v5.4.8' --single-branch https://github.com/swiftmailer/swiftmailer.git

2. Set SMTP mail settings:

[smtp]
; Email address to email proccessed input values
default_emailto = ''

host = ""
; 25, 465, 587
port = ""
from_email = ''
from_name = ''
; Comment lines below that dont apply
; ssl, tls
encryption = ""
username = ""
password = ""

3. For input processing / event based email its important to set the default_emailto to the address you wish the email to be sent to.

@SpaceAce - do you have Node-Red installed anywhere? If so pass the value to MQTT and handle it there. Many more options such as Telegram, IFTTT, Alexa, Google Assistant etc. for the notification.

Could also read the data with Home Assistant (other home automation platforms are available) and handle it there.

I think emonCMS should be left to do what it does best personally.

2 Likes

yes I agree with that, this particular feature in emoncms is not one that we are actively maintaining really.

However, the email is useful to recover passwords - does that work if swiftmailer is installed?

Yes and tested to work here. The password reset settings needs to be set to true in the interface section of settings.ini:

enable_password_reset = true
1 Like

Might be worth adding back in then to the image / scripts.

[edit]

or even an option to disable authentication altogether.

Do you mean SwiftMailer installation or password recovery?
SwiftMailer still requires SMTP settings to work, so I dont think we’d have it enabled by default. Perhaps a good idea to include SwiftMailer in the installation though…?

Password recovery was still there I thought, just no MTA to handle it.

1 Like