The expire binding is not a binding that is going to replace your MQTT binding. You can use it on top th define a command that is to be sent after a specified amount of time expired.
E.g. I can ask Alexa to turn on light for 5 minutes. This means a specific switch will be turned on. By using expire the switch will be turned off after 5 minutes without further manual interaction.
The item in my case looks like:
Switch Rule_Fuenf_Minuten_Aussenlicht_einschalten "Fuenf_Minuten_Aussenlicht" ["Switchable"] { expire="300s,command=OFF" }
the related rule that I have uses a script to turn on/off the physical switch of the light via a UDP command. That script could be adapted to send MQTT commands:
rule "rule triggered by Rule_Fuenf_Minuten_Aussenlicht_einschalten"
when
Item Rule_Fuenf_Minuten_Aussenlicht_einschalten received command
then
if (receivedCommand === ON ) {
executeCommandLine( "/etc/openhab2/scripts/aussenlicht.sh OUT4 1" )
}
else if ( receivedCommand == OFF ) {
executeCommandLine( "/etc/openhab2/scripts/aussenlicht.sh OUT4 0" )
}
end
I do not use Expire binding that was mentioned in a previous post because it is a V1 binding that will not be supported in the upcomming OH3.
Instead I use a jython replacement which is described here: