-
Scripting email actions
03/18/2022 at 20:00 • 0 commentsBy going to Consoles > Edit Script you can create your own scripts and actions, that can be persistent through reboot.
Good sources of info regarding scripting are:
Documentation: https://tasmota.github.io/docs/Scripting-Language/#script-sections
Examples(for better understanding): https://github.com/efal/Sonoff-Tasmota/blob/development/scripter.md
Additional examples(also check some comments): https://github.com/arendst/Tasmota/issues/5689
You must tick the box Script enable and Save to make the script valid and running
NOTE: subject doesn't matter since gmail will replace it with device name you used to generate 16 letter password.
This is the most basic email sending script. Every time device reboots, email is sent.
>D ;define and init variables here >B ;executed on BOOT time before sensors are initialized and on save script >BS ;executed on BOOT time after sensors are initialized >F ;Executed every 100 ms >S ;Executed every second >R ;Executed on restart. p vars are saved automatically after this call =>sendmail [smtp.gmail.com:465:gmail.username:16leterpassword:senders.email@gmail.com:receivers.email@gmail.com:subject] Device has just restarted
Olimex ESP32 POE has a button on GPIO34, therefore we used GPIO34 as status variable and we are setting pin[34] as input with pull-up(2).
With some additional lines to trigger only on status changes, we can set it to send email on button change from 1 to 0.>D ;define and init variables here GPIO34=0 >B ;executed on BOOT time before sensors are initialized and on save script spinm(34 2) >BS ;executed on BOOT time after sensors are initialized >F ;Executed every 100 ms GPIO34=pin[34] if chg[GPIO34]>0 and GPIO34==0 then print input status changed =>sendmail [smtp.gmail.com:465:gmail.username:16leterpassword:senders.email@gmail.com:receivers.email@gmail.com:Button pressed] Button was pressed at %tstamp% . delay(10000) print 10s repeat email timeout passed GPIO34=0 endif >S ;Executed every second >E Executed when a Tasmota MQTT RESULT message is received >R ;Executed on restart. p vars are saved automatically after this call =>sendmail [smtp.gmail.com:465:gmail.username:16leterpassword:senders.email@gmail.com:receivers.email@gmail.com:Device restart] Device has just restarted.
Behaviour can be monitored from Tasmota console Consoles > Console
-
Flashing, testing email and configuring the device
03/10/2022 at 23:15 • 0 comments- Use ESP flasher or comparable tool for flashing ESP32 devices
https://github.com/esphome/esphome-flasher/releases - Use your phone to connect to device by wifi AP set by device "tasmota ..."
- You will be redirected to wifi setup page (required even if you only plan to use it over Ethernet later) Use 192.168.4.1 if no auto redirection
- Wifi configuration page will provide you with the new IP address that it has received from the network
- To test sending emails just go to Consoles>Console and write + enter
*if using this on some esp8266 or arduino script <> symbols might be required around receiverssendmail [smtp.gmail.com:465:gmail.username:16leterspassword:senders.email@gmail.com:receivers.email@gmail.com] test
- If successful you might prefer to flesh your device with a bin without extensive email debugging, since Tasmota is already installed you can use OTA update through the web interface
- If using Olimex ESP32 PoE Board configure the board and pinout by:
- Goig to Configuration > Configure Other menu
- Copy the template from https://templates.blakadder.com/olimex_ESP32-POE.html to the template wind
{"NAME":"Olimex ESP32-PoE","GPIO":[1,1,1,1,1,1,0,0,5536,1,1,1,1,0,5600,0,0,0,0,5568,0,0,0,0,0,0,0,0,1,1,1,1,1,0,0,1],"FLAG":0,"BASE":1}
- Tick Activate and Save
- Restart the device
- Ethernet should be working
- If you plan on using GPIOs as input in the script make sure the pin that you are planning to use is not reserved by system
- Go to Configuration > Configure Template
- Go to the GPIO you want to use ( for example on Olimex ESP32 PoE board button is connected to GPIO34 )
- Select user from drop down menu
- Use ESP flasher or comparable tool for flashing ESP32 devices
-
Setting up gmail
03/10/2022 at 22:53 • 0 commentsFor using gmail you will not be allowed to use or own gmail password due to security issues.
Therefore you need to generate 16character(ignore spaces) app password
more info here: https://support.google.com/accounts/answer/185833?hl=en
requirements are that you have- set-up 2FA (2 factor authentication) for that email account
- the birth date specified in the account is more than 18 years ago.