Not sure what MS you are using, but I have time rules for My GoControl PIR and Schlage door locks that do exactly what you are asking. So it should work for you. " If door unlocks between 8P-11:59P turn on hall lights. " If upstairs hall motion detector detects motion between 12A-6A turn on hall lights.