I think the DEFER statement is the problem. Regardless of where it is in the program it will execute. Looks to me like 2 minutes after this program is evaluated the outlet is always turned on.
it makes no difference where in the program the defer statement is it is the last to be executed this is true, but as I see it it does not supersede the command that says if the switch is open then off and it is a stand alone statement that instructs a delay prior to restart.
If I follow your thinking you are separating out functions that require real time communication from preprogrammed functions
"NOT CONNECTED TO FUSION" but it's not communicating with Fusion or the Apex and provides no message telling you that, again all looks normal. In this phase if one was to try and input a manual command such turning on a light the slider acts like a two pole momentary switch, toggling it from AUTO to ON or OFF it will snap back to the AUTO position,