======Tasmota Rules to control a triple Bathroom light button====== =====Button Type===== -- A three pushbutton device with Tasmota installed (KS-811 Triple) -- Controls Main Lights (1), Mirror Lights (2), Extract Fan (3) -- Prevents mirror lights from remaining on -- Does run on timer function for extract fan -- All carried out inside the device with rules (no MQTT or external control needed) =====First Rule===== -- Combines 3 actions in rule1 -- If Timer 2 finishes, set Power2 OFF (I like to match the timer numbers etc with the output number. This isn't necessary) -- If Timer 3 finishes, set Power3 Off -- If Button 1 is pressed once, toggle Power1 output (just turn the main lights on/off on press) %%rule1 on Rules#Timer=2 do power2 off endon on Rules#Timer=3 do power3 off endon on button1#state=10 do power1 toggle endon%% =====Second Rule===== -- Combines 1 actions in rule2 -- If button2 is pressed once, toggle the output2 and start the timer running down from 3600 (i.e mirror lights go on for one hour max) %%rule2 on button2#state=10 do backlog power2 toggle; ruletimer2 3600 endon%% =====Third Rule===== -- Combines 3 actions in rule3 -- If Button 3 pressed once, toggle output 3 (the bathroom fan). Also, set ruletimer3 to start counting down from 600 seconds (10 minutes) -- If Button 3 pressed twice, toggle output 3 and set ruletimer3 to start counting down from 3600 seconds (1 hour) -- If Button 3 is triple pressed, toggle output 3 and set ruletimer3 to start counting down from 4 hours. %%rule3 on button3#state=10 do backlog power3 toggle; ruletimer3 600 endon on button3#state=11 do backlog power3 toggle; ruletimer3 3600 endon on button3#state=12 do backlog power3 toggle; ruletimer3 14400 endon%% =====Setup Actions===== Turn the rules on %%backlog rule1 1;rule2 1; rule3 1; %% Restrict button actions to 1-5 presses or HOLD (no special functions) %%setoption1 1%% Allow immediate single button press detection (this is the default) %%setoption13 0%% Number of 0.1 second increments for HOLD detection (it is 40 by default, we aren't using this yet) %%setoption32 60%% Detach all buttons from activating relays. It will just send MQTT messages and we will use rule to activate relays. %%setoption73 1%% =====Full rules and actions set===== %%rule1 on Rules#Timer=2 do power2 off endon on Rules#Timer=3 do power3 off endon on button1#state=10 do power1 toggle endon rule2 on button2#state=10 do backlog power2 toggle endon; ruletimer2 3600 endon rule3 on button3#state=10 do backlog power3 toggle; ruletimer3 600 endon on button3#state=11 do backlog power3 toggle; ruletimer3 3600 endon on button3#state=12 do backlog power3 toggle; ruletimer3 14400 endon backlog rule1 1; rule2 1; rule3 1; setoption1 1; setoption13 0; setoption32 60; setoption73 1%% =====Other useful info===== **Button States** 10=1 short press 11=2 short press 12=3 short press 13=4 short press 14=5 short press 3=LONG press **Check how long the rule timers have to go** %%ruletimer%% {{lastedit show="3"}} ---- CategoryHomeAutomation CategoryMQTT CategoryTasmota CategoryTasmotaRules