I think those are not okay. This means your character will never forget to close the doors, because macro (and yet IRL humans do it all the time), and also it puts you an unfair advantage against someone who may try to use that window of opportunity to sneak into your place, as while they face reaction time for typing in "sneak w101" after the door opens up, you will send "close w101" as soon as out through the door.
So I think that those are not fair. I am a happy user of exiting/entering macros myself, but the follow-up trigger part is not fair in my mind. Yep, that means you will forget to lock the doors behind you, just like we all do IRL from time to time.