This page is part of archived documentation for openHAB 4.1. Go to the current stable version

// This rule simulates a push button behaviour.
rule "PushButton of group gV"
    when
        Item gV changed
    then
        // waiting a second.
            Thread::sleep(1000)
        // Foreach-Switch-is-ON
        gV.allMembers.filter( s | s.state == ON).forEach[i|
            // switching OFF
                i.sendCommand(OFF)
        ]
    end