How to set-up email notification for battery voltage

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
theo100
New user
Posts: 2
Joined: 29 Nov 2020, 14:40

How to set-up email notification for battery voltage

#1 Post by theo100 » 29 Nov 2020, 14:57

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

User avatar
Ath
Normal user
Posts: 3416
Joined: 10 Jun 2018, 12:06
Location: NL

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

#2 Post by Ath » 29 Nov 2020, 15:39

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:
Last edited by Ath on 29 Nov 2020, 21:02, edited 2 times in total.
/Ton (PayPal.me)

theo100
New user
Posts: 2
Joined: 29 Nov 2020, 14:40

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

#3 Post by theo100 » 29 Nov 2020, 20:32

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

User avatar
Ath
Normal user
Posts: 3416
Joined: 10 Jun 2018, 12:06
Location: NL

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

#4 Post by Ath » 29 Nov 2020, 21:00

Hm, I made a typo, should have used [var#1] instead of %val1% :o

I've corrected the above post, please retry.
/Ton (PayPal.me)

bonti69
Normal user
Posts: 119
Joined: 08 Apr 2021, 12:16

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

#5 Post by bonti69 » 18 May 2021, 11:26

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 7876 times
email.png
email.png (28.94 KiB) Viewed 7876 times

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

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

#6 Post by TD-er » 18 May 2021, 11:39

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.

bonti69
Normal user
Posts: 119
Joined: 08 Apr 2021, 12:16

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

#7 Post by bonti69 » 18 May 2021, 11:53

Without "hostname" same result
Tried all combinations in hostname/server...nope
Tried with gmail
gmail.png
gmail.png (13.63 KiB) Viewed 7867 times
error.2.png
error.2.png (25.55 KiB) Viewed 7867 times
syno.png
syno.png (113.12 KiB) Viewed 7864 times
Last edited by bonti69 on 18 May 2021, 12:03, edited 2 times in total.

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

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

#8 Post by TD-er » 18 May 2021, 11:56

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?

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

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

#9 Post by TD-er » 18 May 2021, 12:03

See the wiki for more detailed info on the email notificiation plugin: https://www.letscontrolit.com/wiki/inde ... ifications

bonti69
Normal user
Posts: 119
Joined: 08 Apr 2021, 12:16

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

#10 Post by bonti69 » 18 May 2021, 12:12

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 7860 times
Thank you, anyway, for your prompt support...a genuine keeper /guardian .Kudos

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

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

#11 Post by TD-er » 18 May 2021, 12:27

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.

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

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

#12 Post by TD-er » 18 May 2021, 12:30

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.

bonti69
Normal user
Posts: 119
Joined: 08 Apr 2021, 12:16

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

#13 Post by bonti69 » 18 May 2021, 13:36

Tried with gmail
error.3.png
error.3.png (35.68 KiB) Viewed 7852 times
gmail.png
gmail.png (13.63 KiB) Viewed 7852 times

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

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

#14 Post by TD-er » 18 May 2021, 14:32

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)

bonti69
Normal user
Posts: 119
Joined: 08 Apr 2021, 12:16

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

#15 Post by bonti69 » 19 May 2021, 07:43

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 7811 times
A simple "Merry Christmas" in plain text to send via email became rocket science these days.Almost impossible.Because of "security reason".

ed007
New user
Posts: 2
Joined: 11 Jun 2021, 16:04

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

#16 Post by ed007 » 11 Jun 2021, 16:43

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:

Micha_he
Normal user
Posts: 369
Joined: 07 Feb 2018, 19:14
Location: Helmstedt, Germany

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

#17 Post by Micha_he » 11 Jun 2021, 16:55

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' !

ed007
New user
Posts: 2
Joined: 11 Jun 2021, 16:04

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

#18 Post by ed007 » 11 Jun 2021, 17:46

Micha_he Thanks a lot for the help now everything works :)

Post Reply

Who is online

Users browsing this forum: No registered users and 30 guests