@loddem, your topic has been moved to a more suitable location on the forum. Installation and Troubleshooting is not for problems with (nor for advise on) your project
See About the Installation & Troubleshooting category.
You can keep track in loop() if you have done an action and if not do the action and if yes, don't do the action.