IR flips on and off and on and off, endlessly at twilight, or dim light

Of course.

It’s demonstrated the same behavior in some other locations, where the illumination is not uniform. For example, interior hallway in the centre, window off to the side. However, if I put it on windowsill looking outside (where the field of view is more evenly illuminated), it doesn’t flip back/forth. That’s why I suggested some hysteresis in the dynamic switchover algorithm.