I guess I can set a RM rule that takes care of the switch turning on, and after a second change to off, but just want to make sure there is no easier way to do it.
As you said you could add it to the driver like this:
input name: "autoOff", type: "enum", title: "Automatically switch back to off this many seconds after being turned on:",
options: [[0:"Do not automatically switch off"],[1:"1 second"],[2:"2 seconds"],[5:"5 seconds"],[10:"10 seconds"],[30:"30 seconds"],[60:"60 seconds"],[120:"120 seconds"],[300:"300 seconds"]]
//What happens when switch is set to on.
void on() {
if (logEnable == true) log.debug "on()"
if (txtEnable == true && device.currentValue("switch") != "on") log.info "${device.displayName} is on"
if (state.isSwitch == true) {sendEvent(name: "switch", value: "on")}
if (autoOff) {
Integer disableTime = autoOff as Integer
if (disableTime > 0) {
runIn(disableTime,"off")
}
}
}
Of course, great catch! Only thing to bear in mind is that you can't turn it off too quick otherwise the rule that does the Hubitat sync won't work. A wait of 2 or more seconds should be sufficient.
One thing to bear in mind - I suggested rule2 - assuming you might have a rule1 already. Check to make sure you’re not already using rule2 before overwriting it. I can’t recall which rule the community tasmota driver uses.
You can check rule1 through rule3 by simply typing rule1 in the console and check if there’s already a rule written and if the rule is on.