Phew! After many not fun hours fighting with ChatGPT and Deepseek, I finally have a working software solution, if anybody is mad enough to have a look the code is below.
Basically I gave up on using a MOSFET module as neither ChatGPT nor Deepseek could figure out the logic required to turn it on...