Auto-off timer ruleset with warning blinks and re-up (for soldering iron, etc) #10380
inventhouse
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I wanted to set up some basic "smart plugs" as nice auto-off timers for my soldering iron and hot glue gun; there is a cookbook rule for a very basic version but I wanted a few extra things:
Here's what I've come up with;
SetOption32 20
sets the button-hold threshold to 2s,Mem1
is the total timeout in seconds (1 hour),Mem2
is the warning time in seconds (5 mins.)Mem1
andMem2
times can be changed and will get picked up when the timeout is (re)started.Breaking that down, I built a state machine:
Var1=0
clears the timers, turns off power, and cleans upVar1=1
turns power on, does some setup, and goes to state 2. This split is needed because the%var%
substitution appears to take place all at once; if we do math to put the right value inVar2
, we can't use it in the same rule or we won't get the new value.Var1=2
starts the timeout-until-warningVar1>2
blinks the LED to warn that the time is almost up;Mult1 1
"updates"Var1
without changing it re-triggering the rule, but if something else changes it to a different state, any backlogged commands won't cause a problem. Be aware that this creates a lot of console activity and could bog down your device, though I haven't had any issues in my testing. Also note that theLedPower
command needed for blinking also changes the LedState as a side-effect; some of the other rules try to clean this up, but I've hard-coded that to return toLedState 1
There are two timer handlers:
Timer=1
expires, start timer 2 for the remaining time and go to the blinking LED stateTimer=2
expires, the time is up, go to the power-off/cleanup stateAnd two button handlers:
Button1<3
(button clicked but not held) goes to the power-on/setup state (which chains into the start-timer state)Button1=3
(button held) goes to the power-off/cleanup stateHappy to answer any questions, though I'm still super-new to Tasmota and just hacked this until it did what I wanted.
Beta Was this translation helpful? Give feedback.
All reactions