leiweibau / Pi.Alert

Scan the devices connected to your WIFI / LAN and alert you the connection of unknown devices. It also warns if a "always connected" device disconnects. In addition, it is possible to check web services for availability. For this purpose HTTP status codes and the response time of the service are evaluated.
https://leiweibau.net
GNU General Public License v3.0
406 stars 28 forks source link

[Documentation] Information for setting up email alerts #343

Closed user-566 closed 1 month ago

user-566 commented 1 month ago

Introduction

I installed recently the app but I couldn't figure out how to set up email alerts (which was the main reason I wanted to use it), and I didn't find any documentation in the FAQ/README. I eventually figured it out, so I thought I'd make this post for anyone else having trouble.

What I did

During the initial setup, I did get prompted to know if I wanted to enable email alerts, and to configure SMTP, which I of course did (didn't take any pictures because I didn't think it would be necessary, sorry). However after completing the installation and while I was still getting familiar with the interface, it was clear from the testing I was doing something was not working right.

Finally my doubts were confirmed when I visited the settings page of the web GUI: image

Since I couldn't find any options in the web GUI to configure email alerts, I dug a little deeper. I eventually found the ~/pialert/config/pialert.conf file, which I opened using nano to find the following: image

Like I said I'm about 99% percent sure I did chose to enable email alerts during initial setup, but nevertheless I edited both fields to "True" and saved the document, and now "Mail" showed up as green in the notifications in the settings page of the web GUI: image

With that out of the way, I wanted to test if the email alerts actually worked, but again was having trouble finding documentation on the subject. I did find the "Test Notification" button in the settings fairly quickly, and while it did give me a notification in the web GUI, I got no email and nothing indicated wether or not it even tried sending one. image

I eventually found issue #105, and this comment that indicated there was a command I could execute to send a test email notification. I navigated to the "~/pialert/back" folder and executed the "./pialert-cli reporting_test" as indicated and got the following error (redacted some numbers for privacy as I didn't know what they were): image

Thankfully, I knew exactly what the problem was as I had gone through the same thing with my UPS email alerts recently. As indicated on the Google support page linked in the error, I simply needed to use an app password instead of putting the password to my gmail account like I had done.

For those unaware, Google made a change in 2021 which broke a lot of apps that used your gmail account credentials to send emails. Fortunately the fix is fairly simple, first of all you need to enable 2 factor authentication on your Google Account. This is a requirement as the following steps will not work if it is not enabled (don't ask me how I know). After that just go to your Google account settings and search for "app passwords":

image

Create an app password for Pi-Alert and copy it to the "pialert.conf" file: image

Now executing the "./pialert-cli reporting_test" I do finally get an email alert: image

Also tested by enabling the "alert down" option on one of my devices and disconnecting it from the network, and likewise email notifications worked! If they don't for you, make sure you have this option enabled in the settings of the web GUI:

image

Conclusion

I'm sorry if this well known information or if it's already documented somewhere, the goal of this post was simply to save someone like me a bit of time in the future if they ran into the same troubles as I did. Please let me know if anything is not clear or doesn't work!

leiweibau commented 1 month ago

Yes, there is no documentation, especially in the accuracy you have listed here, because certain things differ from mail provider to mail provider. I would create a document based on your work that at least addresses certain specifics, such as the "app passwords".

May I use your screenshots?

leiweibau commented 1 month ago

I have now written a short guide. Would this document have helped you?

https://github.com/leiweibau/Pi.Alert/blob/next_update/docs/NOTIFICATION_MAIL.md

user-566 commented 1 month ago

Yes that's perfect! Thanks a lot 👍