Automation Hat - Input - Interrupt driven?

I’ve just started to play around with the Automation HAT and Python (newbie, but have coded in various things previously).

Is there any way to have the inputs interrupt driven to run some specific code, or do I have to sit in a loop and continually poll and check for changes in values?

The scenario I’m looking for is to have a rain sensor trigger one of the inputs that would then fire off an email (and do some other stuff) when rain is detected, and also when the rain clears, etc.

Is this possible at all?

This is possible in Python with RPi.GPIO, which supports interrupts (they’re actually polling under the hood IIRC) and also in C with WiringPi with WiringPiISR which sets up a sleeping worker threat that asks the kernel to wake it up on a pin state change (closer to a real interrupt).

This series by Alex of covers the RPi.GPIO stuff well: