Rule with Timer

Hi, i want to create an openhab rule with a timer event.

I want to have a button on my visu to start making warmwater with my heatingpump. My time-program for warmwater is one time on noon, rest of the day warm water program is disabled.

But sometimes it would be nice to have warm water by pressing a button. I want to make a rule which enables warmwater on my hatingpump for about 60 minutes and after the time is over or the temperature is reached, the warmwater-settings in the heatingpump should be set to the old variables.

How can i do this? Can someone help me a little bit?

Use a timer. You don’t provide enough detail (Items, variables, etc) so this code is notional.

var Timer hotWaterTimer = null

rule "Manual hot water"
when
    Item ManualHotWaterSwitch received command
then
    // save current states into vals

    if(hotWaterTimer == null) {
        hotWaterTimer = createTimer(now.plusHours(1), [|
            // turn off the hot water
            // postUpdates with saved states in the vals saved above
            hotWaterTimer = null
        ]
    }
    else {
       hotWaterTimer.resechedule(now.plusHours(1))
    }
end

Thank you.

But there is another problem:

I want to end the warmwater programm after 60 minutes or if the water-temperature reached a temp. But i want to stop warmwater on reaching the temp only when the timer is active.

The automatic warmwater program of the heatingpump should run without any changes through the rule.

Create another rule in the same rules file that triggers on the temp sensor. Have this rule:

if(hotWaterTimer != null) {
    hotWaterTimer.reschedule(now.plusSeconds(1))
}

This will cause the timer to go off one second after the temp is reached and requires the least amount of code.