My implementation is slightly different and it works as I expected. I’m not an expert in either Python or Micro-controller programming, so there could be improvements to the code.
interrupt = 1 tim = machine.Timer(-1) def enable_interrupt(timer): global interrupt interrupt = 1 def handle_pin_change(pin, value): pinConfig = pin_config_util.getThingByInputPin(pin) output_pin_id = pin_config_util.getOutputPinConfig(pinConfig.thing_id, pinConfig.thing_prop) # DO THE REAL WORK HERE #THIS IS WHAT WE HOOK UP WITH PIN.IRQ def debounce(pin): global interrupt if interrupt == 1 and pin.value() == 1: tim.init(period=300, mode=machine.Timer.ONE_SHOT, callback=lambda t:enable_interrupt(t)) interrupt = 0 handle_pin_change(pin, pin.value())