To detect the state of the gate I have the switch of the Shelly 1 connected to the AUX 2 (FREE CONTACT) output of the ThaliaP controller. The AUX 2 output is configured as the gate light that causes it to be off when the gate is closed, it toggles between on and off when the gate is in motion and remains on when the gate is open.

