You just need to use button state change as a trigger. E.g. Switch light_switch Switch light rule "Toggle light by switch" when      Item light_switch changed from OFF to ON then     if (light.state == OFF) {         light.sendCommand(ON)     } else {         light.sendCommand(OFF)     } end