There is another recent discussion with a very similar use case: Motion Activated Light, but with conditions