By 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
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.