Auto motion script (motion sensor) AND hue switch (turn off light

Annoying problem: I have a PYSCRIPT script auto_motion_light.py
It turns on a light, when there’s motion, and after some time, it turns the light off.
So far so good.
I have also a hue switch. (four buttons;:ON, dim up,dim down, OFF)
Now, when I press OFF button, the light does not go OFF. Obviously, when I press the OFF button, there’s motion, so, the script auto_motion_light.py turn my light on…
any Idea’s how to solve this nicely?

Don’t know anything about pyscript, but with HA native automations, I would add a condition to the automation such that it would not run if the light changed state within the last second (or so.)