I currently have a wemo switch connected to a portable heater and have set up the item in openhab.
Am I able to create an additional button to turn the switch on, then back off after an hour?
I have read an example rule that will handle the timer, but I don’t understand how to map an additional button to the rule and switch.
To be clear, I don’t want the timer rule to trigger every time the switch is turned on, I want this as a separate control similar to a boost option for central heating.
You have to define a virtual switch without any binding config in your items and sitemap definition.
The rule then should start with a trigger ( when item changed then…)
Switch HeaterTimer "Heat on for one hour" <temperature>
Swtich Heater // your current Item that is bound to your heater
Note there is no binding.
Rule
var Timer timer = null
rule "One Hour Heat On"
when
Item HeaterTimer received command
then
Heater.sendCommand(ON)
if(timer == null || timer.hasTerminated){
timer = createTimer(now.plusHours(1), [|
Heater.sendCommand(OFF)
timer = null
])
}
else {
timer.reschedule(now.plsuHours(1) // if pressed a second time keep it on for another hour from now
}
end
Sitemap:
Switch item=HeaterTimer mappings=[ON=Set]
The above will put a line on your sitemap with a button labeled “Set”. When you press the button it will send the ON command to the Heater and set a timer to send the command OFF after 1 hour. If there is already a timer set it will reschedule the timer for one hour from when the button was pressed again.