Sx1509: support reading input pins?

Looking for a guidance / comments / early review.

I added support for reading input pins via SX1509 I2C IO expander that piggy-backs on the “buttons” interface / implementation. The primary use-case is ERCF MMU unit where things are getting a bit crazy with one pre-gate sensor for each color supported, hence the need for many input pins!
I know that I2C expanders are not good for a low-latency use-cases such as endstops, but my implementation does not allow using them as endstops, only as buttons (filament sensor switch, for example).

So, I would like to know:

  1. Does this fit into Klipper design principles?
  2. Just how reasonable my implementation is? It’s basically “wait for an interrupt via GPIO pin, when received, read IO inputs via I2C register, process, rinse and repeat”, all done on Python side. No changes to MCU code.

Sample configuration:

[sx1509 expander]
i2c_address: 62
i2c_bus: i2c1a
interrupt_pin: !PB7

[filament_switch_sensor pin0]
switch_pin: ^!sx1509_expander:PIN_0
[filament_switch_sensor pin1]
switch_pin: ^!sx1509_expander:PIN_1

Also, for completeness, here is an alternative implementation which is an addon that doesn’t require changes to Klipper. It’s a total hack (parses protocol messages to simulate MCU behavior for buttons), but the advantage is that it doesn’t have to be part of the Klipper mainline and could be part, for example, of Happy-Hare, since this is where we need all these extra inputs…).