perform if-based condition only once or multiple times?

Thanks for those enlightening answers, karma added to the both of you.

In my particular case I just realised that when the sensor state changes I need to start a timer, so I do have to make sure that particular piece of code is addressed just once. So PeterPan321's suggestion in your second paragraph is pertinent (state change detection).