# SetOption65 1 will turn off fast power cycle detection device recovery. This will avoid reset to default
# firmware settings if there are several reboots or brownouts. Warning: there will be no way to reset
# settings without physical access to the device
BACKLOG poweronstate 0; Longitude -68.059105; Latitude -38.951607; Timezone -3; SetOption65 1
Backlog SaveData 600; WifiConfig 4
A slight modification of the Tamosta rule cookbook #14
"Using Timers, you can be set to turn on and off a light for iluminate a street/patio by night. But if the Sonoff Device has no power at the trigger time, then, when it powers up, the light will be off all night. So, as a failsafe, can be implemented a conditional control to be checked at Sonoff Startup with rules."
Also as an ehancment to the existing rule, after a 10 second delay, check the current power state, so that MQTT message is published. This is better than a retained MQTT message, so that OpenHAB gets the latest POWER state after a reboot of the ESP8266 Sonoff device.
# Handle case when mains power was cut off and then turned back on
# If before midnight and after sunset, or if before sunrise and after midnight, then turn on the light
# If daytime then turn off the light
Rule1 ON Time#Initialized DO backlog event checksunrise=%time%; event checksunset=%time% ENDON
ON event#checksunset>%sunset% DO power1 1 ENDON
ON event#checksunrise<%sunrise% DO power1 1 ENDON
# reboot everyday at 10am. It was unreachbale via Wifi once, so see if this does anything
Rule2 on Time#Minute==600 do restart 1 endon
Turn on those rules
backlog Rule1 1; Rule2 1
# Set saving of paramters if there are "changes" every 600 seconds
SaveData 600
Still an open issue with Ghost switching because of capacitor hardware problem with the Sonoff TX switch. NOT the more talked about MQTT ghost switching problem when retain is on.
This is attempt to resolve that issue, making the touch screen less sensitive
# - this buttondebounce is still debatable 2020-July
# - poweronstate power OFF after reboot
# - Stop detecting input change on the button GPIO. Solves #5449
# - SetOption40 Active only when SetOption1 1 and SetOption13 0. This disables all long press functionality.
# Must reverse to configure the IR remote
Backlog poweronstate 0; SetOption1 1; SetOption13 0; SetOption40 10; buttondebounce 175
# If given the power = blink command, then blink 10 times, every half second
Backlog BlinkCount 10; BlinkTime 5
Lights on and off everyday
BACKLOG Timer1 {"Enable":1,"Mode":2,"Time":"02:05","Window":5,"Days":"1111111","Repeat":1,"Output":2,"Action":0};
Timer2 {"Enable":1,"Mode":1,"Time":"00:00","Window":10,"Days":"1111111","Repeat":1,"Output":2,"Action":1};
Timer3 {"Enable":1, "Arm":1,"Mode":2,"Time":"00:15","Window":10,"Days":"1111111","Repeat":1,"Output":2,"Action":1};
Timer4 {"Enable":1, "Arm":1,"Mode":1,"Time":"01:30","Window":10,"Days":"1111111","Repeat":1,"Output":2,"Action":0};
Timer5 {"Enable":1, "Arm":1,"Mode":2,"Time":"00:05","Window":10,"Days":"1111111","Repeat":1,"Output":3,"Action":1};
Timer6 {"Enable":1, "Arm":1,"Mode":1,"Time":"-00:15","Window":10,"Days":"1111111","Repeat":1,"Output":3,"Action":0};
Timer7 {"Enable":0, "Arm":0,"Mode":0,"Time":"00:00","Window":10,"Days":"1111111","Repeat":0,"Output":1,"Action":0};
Timers 1
# If was rebooted and
# If before midnight and after sunset, or if before sunrise and after midnight, then turn on the light
# For SWITCH #3 only!
Rule1
ON Time#Initialized DO backlog event checksunrise=%time%; event checksunset=%time% ENDON
ON event#checksunset>%sunset% DO power3 1 ENDON
ON event#checksunrise<%sunrise% DO power3 1 ENDON
Rule1 1
# Send MQTT msg to another device when 1st button (of 3) is pressed
Rule2 ON button1#state DO publish tasmota/cmnd/sonff-NNN-01/POWER1 toggle ENDON
Backlog Rule1 1; Rule2 1
Lights on and off everyday
# Tasmota Version 8.3 uses the word "ARM" not "Enable"
# Example to turn the lights on a sunset + 1 minute +/- one minute, off + 6 minutes +/- 1 minute
BACKLOG Timer1 {"Arm":1,"Mode":2,"Time":"00:01","Window":1,"Days":"1111111","Repeat":1,"Output":1,"Action":1}; Timer2 {"Arm":1,"Mode":2,"Time":"00:06","Window":1,"Days":"1111111","Repeat":1,"Output":1,"Action":0}; Timers 1
# example turn on 6am for one hour, su/tu/th/fr
Timer1 {"Arm":1,"Mode":0,"Time":"06:00","Window":0,"Days":"1010110","Repeat":1,"Output":1,"Action":1}
Timer2 {"Arm":1,"Mode":0,"Time":"07:00","Window":0,"Days":"1010110","Repeat":1,"Output":1,"Action":0}
# Modify multi-press actions. React as a single press
# Also send a mqtt topic message when RF button is pressed
#Backlog SetOption1 1; SetOption13 1; ButtonTopic 1
# If the RF is triggered, then tell another switch to blink
Rule1 ON button1#state DO backlog publish tasmota/cmnd/sonff-NN-01/POWER2 blink; publish openhab/cmnd/doorbell-01 pressed; ENDON
Rule1 1
# SetOption65 1 will turn off fast power cycle detection device recovery. This will avoid reset to default
# firmware settings if there are several reboots or brownouts. Warning: there will be no way to reset
# settings without physical access to the device
# PowerOnState == 4 == always turn on if rebooted, and do not let it be changed
# PowerOnState == 0 == reboot to be set to off
BACKLOG poweronstate 0; Longitude -68.059105; Latitude -38.951607; Timezone -3; SetOption65 1; NtpServer1 10.12.14.40; NtpServer2 ar.pool.tnp.org
# Now if Power command is give it will turn on for 30 seconds.
Rule1 ON clock#Timer=1 DO Power on ENDON
Timer1 {"Arm":1,"Mode":0,"Time":"04:45","Window":0,"Days":"0100100","Repeat":1,"Output":1,"Action":3}
#NOT WORKING Backlog BlinkCount 1; BlinkTime 300; Rule1 1
# Pulse time 130 = 130 - 100 = 30 seconds
Backlog PulseTime 130; Rule1 1
# These are the calibration numbers recieved from a factory Sonoff POW R2 when monitoring a 53W incandescent light bulb
BACKLOG WattRes 2; EnergyRes 3; VoltRes 2
PowerSet 54.86
CurrentSet 0.25
VoltageSet 227.48
# I know ~55 watts and ~67 watts and < ~3 watts are repeatable important power states to monitor for my usage case.
# Though still watch for other wattage changes
# Set to report every time the Watts change by 2
PowerDelta 102