How to set a timer?

Hi, please help
I have OPENHAB2 MQTT working on PI3
A SONOFF switch is connected to the Biler, the switch works on ON and OFF everything is OK, and now I want to set a timer for half an hour, and after 30 minutes the switch will switch OFF.
I realized that I have to set the RULES, but I do not know how.

Thank you

Switch Hotwater “Hotwater” (gLight) {mqtt=">[broker:cmnd/Hotwater/POWER:command:*:default], <[broker:stat/Hotwater/POWER:state:default]", autoupdate=“false”}

Frame label=“Hotwater”
Switch item=Hotwater

, expire="30m,command=OFF"

Thanks for the quick response, where do I put the command?

Thank you

after autoupdate=“false”

Switch Hotwater "Hotwater" (gLight) {mqtt=">[broker:cmnd/Hotwater/POWER:command:*:default], <[broker:stat/Hotwater/POWER:state:default]", autoupdate="false", expire="30m,command=OFF"}


Or if the timer is part of a rule, ie do something, wait for some time and then do something else you can use the createtimer option…

This post gives a good couple of examples, but if you search the forums for createtimer you’ll find loads of others

Thank you, sorry but the command you sent still does not respond to what I need.
I need such a situation, the hot water is ON, and after 30 minutes it goes OFF.

Thank you

you must install the add-on
paperui -> add ons -> Bindings -> Expire Binding

Thank you
work :slight_smile:

Don’t forget that the expire part doesn’t actually turn anything else on or off, all that happens is it will change the item state to = ON or = OFF which might work for you day 1 but you may need more logic behind it, ie only switch it on if it is daytime and you are home…to do this you will need to create rules to actually do something else.

So, you need to create a rule that does something when the item state = ON and then another one when the state = OFF:

rule "do something when hot water item state changes"
    	Item MyHotWaterItem changed
    	if(MyHotWaterItem.state==ON) {
    			// do something
else {
                       // do something else

In this case the rule will run when the state changes, if it is ON then it will ‘do something’ otherwise, (and logic says it will be OFF), it will ‘do something else’

Using expire=, you can specify if you would like it to perform a command or a state update at expiry time.
If a command, it will be acted on just the same as a command from a rule or UI, i.e. it will get sent to any bound devices.