After exiting the maintenance mode the sockets just get the inputs of the assigned logic. For example, in your case the input is always on, so the socket would be set to on. The function will be ignored.

Solution:
Set the input of your logic to maintenance and invert it. Then the socket will be delayed on after maintenance.