Troubleshoot motion detector that turns on for only a few seconds at a time
Motion sensors don't like having power cut

You may think of a motion sensor as a stateless device: ”detect motion, turn on, how hard is that?"   But actually, there's a lot more going on. 

To start with, how often do you see motion sensors coming on by daylight?  You don't.   That's because they have light sensors so they don't come on in the day.  

Day. Night.  How hard is that?   The human eye has a complex iris that allows adaptation to a wide variety of light levels. Because of this auto-compensation, day is just day, and night is just night.   But to a machine, it sees only absolute lux to the sensor, and only on the light frequencies it detects.  Turns out a shady north facing location can have less absolute lux by day then a location with a lot of artificial lighting by night.  So the sensor must "see" a reasonable chunk of a day-night cycle to see what light levels will look like here.  And after having spent much of a day learning that, it will store that data for future use.   

However, if you cut its power, you wipe its memory and it must start over. 

So expect substandard performance from your motion sensor as long as you have it on a switch.  Nature of the beast.