On door open - Logic problem

Any ideas how this can be done?