Delay between 2 relays

I’m trying to create a script that should trigger a relayA (command.on).
But this relayA should not be triggered if relayB has ran during fe the last hour.
In normal cases, this should never be happening, but I want to build in a kind of safety in…

What’s the best way to configure this?

You can try expire https://docs.openhab.org/addons/bindings/expire1/readme.html
Whenever relayB changed to ON set relayA (with expire 1h) to OFF.

rule "relay rule"
when
    Item relayA_proxy received command ON
then
    if(relayB.lastUpdate.isBefore(now.minusHours(1))) relayA.sendCommand(ON)
end

The isBefore part is probably wrong but you get the idea. Look at the transform posting or section of the docs for the details if the above won’t work.

1 Like