Light turn off not working properly some times

Hello,
I have a light automation created to switch off the pool pump after one hour. I use KNX switches to start/stop the pump. I wanted to do the automation to switch off the pump in HA and not in KnX for various reasons. However, some times it works perfect but sometimes, for whatever reasons, it switches off at non regular intervals (after few seconds, then maybe after few minutes etc.) and it is more an d more difficult then to make it as programmed (for one hour). The pump
is also control by e level sensor which could stop the pump if the water level is below a trash hold. But this was never the case. What I noticed some time is that if I take out the sensor from the water sometimes it starts working normally again. Do you have any idea what the cause can be and where to look? I attach a print screen of the automation and a print screen with the logs.
Thanks a lot in advance for your support!


Is the pump a light?

yes - i set it as a light

Have a look at the automation debugger: Troubleshooting Automations - Home Assistant

You could change it to be a switch instead of a light. It would make more sense, but probably behave exactly the same.