Page 1 of 1

How to set-up email notification for battery voltage

Posted: 29 Nov 2020, 14:57
by theo100
Hi, i'm new here. I'm trying to use ESPEasy for different usecases. I run a few NodeMCU Boards hooked up to 5 V USB Chargers, with some DS18B20 to monitor Temperatures. But now i want to try to build a Battery driven ESP-12 with an BME280 Sensor. On the Hardwareside everything runs on an Breadboard working fine. I use an 18650 Akku for Powersupply. The Sensor is working and i can send Data to my Volkszaehler. Now i want an easy way to monitor the Battery. The Usage for later on is to run this board in Deepsleep for 10 min and then wakeup for few seconds to do a messurement and send to volkszaehler. This already works. For the Battery Monitoring i put an Resistor divider on the breadboard to supply 1 Volt to the ADC. In ESPEasy i set up an Device with ADC Internal named batterie and the value named spannung. I used the caibration of the ADC Device and the Value i get is the "real" voltage of the Powersupply. Now i want the ESPEasy to send me an email when the Batteryvolateg drops down under a certain value, maybe 2.5V. But this dosn't work for me. I set up an email notification, ths works when i type in notify 1 in the command line. I recive an email. I tryed to setup an rule but this dosen't work. First i setup an rule "on Wifi#connected do notify 1 endo" to try the rules itself. This works, when reboot the ESP i get an email. And then i tried "on Wifi#connected do if batterie#spannung<2.5 notify 1 endif endon" But that dosen't work. i tried this without deepsleep rebooting the ESP manually. What should the rule look like to function. Or is there maybe another workaround to do that?

thanks for help
Best,
Tobias

Re: How to set-up email notification for battery voltage

Posted: 29 Nov 2020, 15:39
by Ath
Hi Tobias,

You could add a rule like this: (goes in the same rules file you already have)

Code: Select all

on Batterie#Spannung do
  if %eventvalue%<2.5 and [var#1]=0
    notify 1
    let,1,1
  endif
  if %eventvalue%>2.5
    let,1,0
  endif
endon
I've added a mechanism (let,1,1)to only send the e-mail once, to avoid getting spammed while the voltage stays below 2.5V.

Edit: fixed a small but disturbing typo. :shock:

Re: How to set-up email notification for battery voltage

Posted: 29 Nov 2020, 20:32
by theo100
Hi Ath,

Thanks for your help. I tested it, but it seems not working right. If the Voltage is higher as the 2.5V in the log is after every EVENT:batterie#spannung an ACT: let,1,0 but if the Voltage is below 2.5V nothing happens. in the Log there is no more an ACT: When i delete the let,1,1 and let,1,0 and the %val1%=0 from the rule i get an notification after every reading of the ADC Device and in the log there is after every EVENT:batterie#spannung an ACT:notify 1

So it seems that something with the setting to send the notification just once is wrong

EDIT: Just read again in the wiki page about rules and found something which i tried. When i use [var#1]=0 instead of %val1%=0 then it works. Everytime the reading is above 2.5V the ACT is let,1,0, and once its below 2.5V the Act ist notify 1, let,1,1 and the mail is sent. The next reading below 2.5V dosen't trigger an notification

Re: How to set-up email notification for battery voltage

Posted: 29 Nov 2020, 21:00
by Ath
Hm, I made a typo, should have used [var#1] instead of %val1% :o

I've corrected the above post, please retry.

Re: How to set-up email notification for battery voltage

Posted: 18 May 2021, 11:26
by bonti69
Today I tried to configure email on my ESP device
I have a smtp server on my Synology, local LAN, which I use it for another devices without ssl encryption. The synology then forwards email to gmail, on my phone.
After many trials, I figure to use "192.168.4.109:" as server adress, with "192.168.4.109" ,I had nothing in log.
Now I have error connecting:
1632186: EMAIL: Connecting to 192.168.4.109:25
1632381: EMAIL: Error connecting to 192.168.4.109:25
The server works on two other devices
Any suggestions?
error.png
error.png (54.38 KiB) Viewed 8182 times
email.png
email.png (28.94 KiB) Viewed 8182 times

Re: How to set-up email notification for battery voltage

Posted: 18 May 2021, 11:39
by TD-er
Hmm that's strange, that you must include a colon in the hostname,
That string is literally used to connect to a host, so no wonder it does not work as the host "192.168.4.109:" does not exist.

I also don't see why it should not work on an IP-address.
The hostname string will first be tried to see if it is an IP-address, so it should not have to perform a DNS resolve.

Using the colon may only be beneficial to make the logs more readable, as it is missing a space or colon in the log entry.

Re: How to set-up email notification for battery voltage

Posted: 18 May 2021, 11:53
by bonti69
Without "hostname" same result
Tried all combinations in hostname/server...nope
Tried with gmail
gmail.png
gmail.png (13.63 KiB) Viewed 8173 times
error.2.png
error.2.png (25.55 KiB) Viewed 8173 times
syno.png
syno.png (113.12 KiB) Viewed 8170 times

Re: How to set-up email notification for battery voltage

Posted: 18 May 2021, 11:56
by TD-er
You should use a hostname in the "server" fiels, but this can be a DNS resolvable name like: "mynas.lan" or "192.168.4.109"
Just without the ":"

What do you set in the "domain" field?
Maybe that's where your mailserver refuses to send?

Re: How to set-up email notification for battery voltage

Posted: 18 May 2021, 12:03
by TD-er
See the wiki for more detailed info on the email notificiation plugin: https://www.letscontrolit.com/wiki/inde ... ifications

Re: How to set-up email notification for battery voltage

Posted: 18 May 2021, 12:12
by bonti69
Of course I already read the instructions
Nevermind, not so important
Anyway, massive frustration for a guy like me, average IT user, not be able to set a f....ing smtp , aka "Simple Mail Transfer Protocol". Wild world,took me hours to set on my other crippled devices (without ssl) & synology...enable/disable authentification...ports...encryption
This one works fine
Screenshot_2021-05-18 Email.png
Screenshot_2021-05-18 Email.png (73.35 KiB) Viewed 8166 times
Thank you, anyway, for your prompt support...a genuine keeper /guardian .Kudos

Re: How to set-up email notification for battery voltage

Posted: 18 May 2021, 12:27
by TD-er
The screenshot of your thermometer does not show the "EHLO" step.
But if that's a missing (but expected) step, then you should see some timeout log.

Re: How to set-up email notification for battery voltage

Posted: 18 May 2021, 12:30
by TD-er
Oh and is the ESP still up and running, or maybe rebooting?
Can you setup a syslog services (perhaps on your synology too) to make it perhaps easier to gather logs.

Re: How to set-up email notification for battery voltage

Posted: 18 May 2021, 13:36
by bonti69
Tried with gmail
error.3.png
error.3.png (35.68 KiB) Viewed 8158 times
gmail.png
gmail.png (13.63 KiB) Viewed 8158 times

Re: How to set-up email notification for battery voltage

Posted: 18 May 2021, 14:32
by TD-er
Gmail doesn't allow non-SSL connections, so that will not work at all.
The documented SMTP2go should work. (I tested it myself in the past)

Re: How to set-up email notification for battery voltage

Posted: 19 May 2021, 07:43
by bonti69
Yes, I know, that's the reason for using synology as intermediary smtp relay...just everything goes to "error connecting...".I think nothing reach to synology smtp server,unfortunately does not have any debug log available . Maybe plugin needs some overhaul?
Smtp2go seems to be hungry :lol: (https://www.smtp2go.com/pricing/)
Of course the synology smtp server needs gmail smtp relay to work
Screenshot_2021-05-18 Create Your Mail System Synology Inc _cr.jpg
Screenshot_2021-05-18 Create Your Mail System Synology Inc _cr.jpg (35.11 KiB) Viewed 8117 times
A simple "Merry Christmas" in plain text to send via email became rocket science these days.Almost impossible.Because of "security reason".

Re: How to set-up email notification for battery voltage

Posted: 11 Jun 2021, 16:43
by ed007
Hi! How to set up email notifications no more than 1 per minute? Continuous notifications, spam:

Code: Select all

 on Adc#analog<3.1 do notify 3 "adc lov" endon
Try

Code: Select all

 On System#Boot do    //When the ESP boots, do
   timerSet,1,30     //Set Timer 1 for the next event in 30 seconds
endon
On Rules#Timer=1 do  //When Timer1 expires
  if Adc#analog<3.1 do notify 3 "adc lov" 
Endif
 timerSet,1,30      //Resets the Timer 1 for another 30 seconds
endon
Does not work. Please help :roll:

Re: How to set-up email notification for battery voltage

Posted: 11 Jun 2021, 16:55
by Micha_he
Test this:

Code: Select all

On System#Boot do    //When the ESP boots, do
   timerSet,1,30     //Set Timer 1 for the next event in 30 seconds
endon

On Rules#Timer=1 do  //When Timer1 expires
  if Adc#analog<3.1
    Notify 3 "adc lov" 
  Endif
  timerSet,1,30      //Resets the Timer 1 for another 30 seconds
endon
No 'do' after 'if' !

Re: How to set-up email notification for battery voltage

Posted: 11 Jun 2021, 17:46
by ed007
Micha_he Thanks a lot for the help now everything works :)