Difference between revisions of "EasyNotifications"
Sandominion (talk | contribs) |
m (clarifications) |
||
(13 intermediate revisions by 3 users not shown) | |||
Line 46: | Line 46: | ||
---[ 1M resistor ] --- | ---[ 1M resistor ] --- | ||
− | The capacitor will make sure it | + | The capacitor will make sure it doesn't stay in reset-mode if the switch closed for a longer time. |
== ESPEasy settings == | == ESPEasy settings == | ||
− | * Enable deep sleep with a sleep time of 0 seconds. | + | * Enable deep sleep with a sleep time of 0 seconds. This will ensure that it only wakes from the switch closure. |
* Enable '''Sleep on connection failure''' | * Enable '''Sleep on connection failure''' | ||
* Set message delay to 0. | * Set message delay to 0. | ||
− | * Add an email notification. | + | * Add an [[EasyNotifications#Email Notification|email notification]]. |
* Enable rules. | * Enable rules. | ||
* Create a rule that mails you on system boot, like this: | * Create a rule that mails you on system boot, like this: | ||
− | on | + | on WiFi#Connected do |
notify 1 | notify 1 | ||
endon | endon | ||
− | * Consider compiling ESPEasy with FEATURE_ADC_VCC. (enable it in ESPEasy.ino) This way you can add a sysinfo task that sends the battery level to your homecontroller, every time it wakes up. | + | * Consider compiling ESPEasy with FEATURE_ADC_VCC. (enable it in ESPEasy.ino) This way you can add a sysinfo task that sends the battery level to your homecontroller, every time it wakes up. You can also add the %vcc% macro to your email. |
+ | |||
+ | == Email Notification == | ||
+ | |||
+ | '''IMPORTANT:''' ESPEasy can’t send Emails using popular providers like Gmail.com or Yahoo.com. Why? Most Email service providers stopped support for non-secure SMTP (w/o SSL) around 2014. ESPEasy's Email-Notification does NOT support SSL due to limited resources. [https://github.com/letscontrolit/ESPEasy/issues/179] | ||
+ | |||
+ | There are two common solutions, as follows: (1) Operate a mailserver inside your local network, or (2) Use an SMTP Email account from one of the rare providers still offering SMTP with no or optional SSL (e.g. SMTP2go.com, smart-mail.de). | ||
+ | |||
+ | Remember, you won’t be able to use the ESPEasy's Email Notification if your SMTP email server requires a secure connection (e.g. TLS / SSL). | ||
+ | |||
+ | |||
+ | '''NOTIFICATION SETTINGS''' | ||
+ | |||
+ | For this discussion we will be using a "non-secure" SMTP account from SMTP2go.com or smart-mail.de. | ||
+ | |||
+ | Using a web browser go to your ESPEasy device's "Notifications" tab. Consult each table row (see below) and configure ESPEasy with the following Notification Settings: | ||
+ | |||
+ | {| class="wikitable" | ||
+ | !style="border-right:medium solid" | Contend !!Example 1 !!Example 2 !! Description | ||
+ | |- | ||
+ | |style="border-right:medium solid" | Notification: || style="text-align:center" colspan="2" | Email (SMTP) || Type of notification | ||
+ | |- | ||
+ | |style="border-right:medium solid" | Domain: || style="text-align:center" | smtp2go.com || style="text-align:center" | smart-mail.de || Web address of Email service provider | ||
+ | |- | ||
+ | |style="border-right:medium solid" | Server: || style="text-align:center" | mail.smtp2go.com || style="text-align:center" | smtp.smart-mail.de || Full server name to deliver Email via SMTP | ||
+ | |- | ||
+ | |style="border-right:medium solid" | Port: || style="text-align:center" | 2525 || style="text-align:center" | 25 || Enter SMTP port recommended by provider | ||
+ | |- | ||
+ | |style="border-right:medium solid" | Sender: || style="text-align:center" | joe@anydomain.com || style="text-align:center" | joe@anydomain.com || Sender's Email address to be shown on the email | ||
+ | |- | ||
+ | |style="border-right:medium solid" | Receiver: || style="text-align:center" colspan="2" | JohnDoe@gmail.com || Recipient's email address. Note: Multiple allowed, use comma (,) between each address. | ||
+ | |- | ||
+ | |style="border-right:medium solid" | Subject: || style="text-align:center" colspan="2" | Message from your ESPEasy || Topic in Email headline (fixed) | ||
+ | |- | ||
+ | |style="border-right:medium solid" | User: || style="text-align:center" | ESP123 || style="text-align:center" | ESP123@smart-mail.de || Enter Username to login to the SMTP Server | ||
+ | |- | ||
+ | |style="border-right:medium solid" | Pass: || style="text-align:center" | 2S€cr€t4you || style="text-align:center" | 2S€cr€t4me || Enter Password to login to the SMTP Server | ||
+ | |- | ||
+ | |style="border-right:medium solid" | Body: || style="text-align:center" colspan="2" | Device is on duty since %uptime% minutes.<br />Connect via WiFi %ssid% to<br />http://%sysname%.fritz.box || Default text is send only if command "notify X" is called without optional text for the body | ||
+ | |- | ||
+ | |style="border-right:medium solid" | Enabled || style="text-align:center" colspan="2" | <hook> || Needs to be active | ||
+ | |} | ||
+ | |||
+ | Now you can use the command e.g. like: | ||
+ | Notify 1, Hello_world! | ||
+ | |||
+ | The general syntax is: | ||
+ | Notify <position>, [message_in_the_body] | ||
+ | Where <position> is the No. of notification 1...3 in the list of all Notifications and [message_in_the_body] the optional text to replace the default text from "Body:" in Notification Settings. | ||
+ | |||
+ | Might-be-useful rule example (NTC enabled): | ||
+ | On Time#Initialized do //connected to WiFi & TimeServer | ||
+ | notify 1, "Connected after Reboot via %ssid%" //Send Email | ||
+ | endon | ||
+ | |||
+ | Some more hints: | ||
+ | * Put [optional] text of body message with space characters in quotation marks or use “_” instead and %CR% for a new line. | ||
+ | * The "Unit Name" from "Main Settings" (if defined) is used as Email Sender Name (usually displayed to Receiver with Email address). | ||
+ | * If you need to differ between subjects you could create (almost same) Notifications for each subject. | ||
+ | * If you don't receive any E-Mails then confirm that your Internet router is configured to enable the Port number entered in Notifications. | ||
+ | * If you still have problems then confirm you have checked the box labeled "Enabled" inside Notifications Settings. | ||
+ | * Cross your fingers and hope that the Email provider of your choice doesn’t stop providing SMTP w/o SSL. |
Latest revision as of 20:34, 2 November 2021
Contents
ESPEasy notifications
ESPEasy notifications are to be used in combination with rules.
For example, to send a message on system boot use a rule like this:
on System#Boot do notify 1,system_is_started endon
Note: Use v2.0.0-dev11 or higher. There was a bug in dev10 and older versions that lead to crashes.
Creating a paper-mail to email gateway
I used notifications in combination with Deep Sleep to create a system that notifies me when I have new paper mail in my actual mailbox:
Hardware
- Core: A bare esp-12-f. Not a development board, so it has no voltage regulator and no usb-to-serial interface that draws current while sleeping.
- Casing: Google for Waterproof Clear Cover Plastic Electronic Box Project
- Magnetic microswitch: Google for something like 10pcs/lot Wired Door Window Magnetic Sensor Switch
- Use a GOOD and high temperature hot-glu gun like the Dremel 940. This saves a lot of frustration and allows you to make everything nice and solid.
For power I used an old powerbank, those you use to charge your phone. Most power-banks use lithium cells that are a perfect 3.3 volts. And they are easy to charge as well. :)
Wiring
- You need to connect some extra pins to VCC or GND if you use a bare ESP-12-f, google for this. :)
- Connect D0 to vcc, to ensure the device goes into deep sleep. (connect to GND to disable deep sleep)
- Connect the magnetic switch:
- Connect one side of the magnetic switch to GND.
- Connect the other side of switch it to the - side of a capacitor (4u7), with a 1 meg. resistor in parallel.
- Connect those the the RST pin.
This will wake up the ESPEasy from deep sleep when the magnetic switch is closed.
An awesome "schematic" of the switch-part:
[ GND ] --- [ magnetic switch ] -----+- [ 4u7 capicitor ] --+-- [ ESP8266 RST pin ] | | ---[ 1M resistor ] ---
The capacitor will make sure it doesn't stay in reset-mode if the switch closed for a longer time.
ESPEasy settings
- Enable deep sleep with a sleep time of 0 seconds. This will ensure that it only wakes from the switch closure.
- Enable Sleep on connection failure
- Set message delay to 0.
- Add an email notification.
- Enable rules.
- Create a rule that mails you on system boot, like this:
on WiFi#Connected do notify 1 endon
- Consider compiling ESPEasy with FEATURE_ADC_VCC. (enable it in ESPEasy.ino) This way you can add a sysinfo task that sends the battery level to your homecontroller, every time it wakes up. You can also add the %vcc% macro to your email.
Email Notification
IMPORTANT: ESPEasy can’t send Emails using popular providers like Gmail.com or Yahoo.com. Why? Most Email service providers stopped support for non-secure SMTP (w/o SSL) around 2014. ESPEasy's Email-Notification does NOT support SSL due to limited resources. [1]
There are two common solutions, as follows: (1) Operate a mailserver inside your local network, or (2) Use an SMTP Email account from one of the rare providers still offering SMTP with no or optional SSL (e.g. SMTP2go.com, smart-mail.de).
Remember, you won’t be able to use the ESPEasy's Email Notification if your SMTP email server requires a secure connection (e.g. TLS / SSL).
NOTIFICATION SETTINGS
For this discussion we will be using a "non-secure" SMTP account from SMTP2go.com or smart-mail.de.
Using a web browser go to your ESPEasy device's "Notifications" tab. Consult each table row (see below) and configure ESPEasy with the following Notification Settings:
Contend | Example 1 | Example 2 | Description |
---|---|---|---|
Notification: | Email (SMTP) | Type of notification | |
Domain: | smtp2go.com | smart-mail.de | Web address of Email service provider |
Server: | mail.smtp2go.com | smtp.smart-mail.de | Full server name to deliver Email via SMTP |
Port: | 2525 | 25 | Enter SMTP port recommended by provider |
Sender: | joe@anydomain.com | joe@anydomain.com | Sender's Email address to be shown on the email |
Receiver: | JohnDoe@gmail.com | Recipient's email address. Note: Multiple allowed, use comma (,) between each address. | |
Subject: | Message from your ESPEasy | Topic in Email headline (fixed) | |
User: | ESP123 | ESP123@smart-mail.de | Enter Username to login to the SMTP Server |
Pass: | 2S€cr€t4you | 2S€cr€t4me | Enter Password to login to the SMTP Server |
Body: | Device is on duty since %uptime% minutes. Connect via WiFi %ssid% to http://%sysname%.fritz.box |
Default text is send only if command "notify X" is called without optional text for the body | |
Enabled | <hook> | Needs to be active |
Now you can use the command e.g. like:
Notify 1, Hello_world!
The general syntax is:
Notify <position>, [message_in_the_body]
Where <position> is the No. of notification 1...3 in the list of all Notifications and [message_in_the_body] the optional text to replace the default text from "Body:" in Notification Settings.
Might-be-useful rule example (NTC enabled):
On Time#Initialized do //connected to WiFi & TimeServer notify 1, "Connected after Reboot via %ssid%" //Send Email endon
Some more hints:
- Put [optional] text of body message with space characters in quotation marks or use “_” instead and %CR% for a new line.
- The "Unit Name" from "Main Settings" (if defined) is used as Email Sender Name (usually displayed to Receiver with Email address).
- If you need to differ between subjects you could create (almost same) Notifications for each subject.
- If you don't receive any E-Mails then confirm that your Internet router is configured to enable the Port number entered in Notifications.
- If you still have problems then confirm you have checked the box labeled "Enabled" inside Notifications Settings.
- Cross your fingers and hope that the Email provider of your choice doesn’t stop providing SMTP w/o SSL.