Well it seems that you may have a template that is causing the issue. With you deleting all the templates should have cured the problem, but you might have missed one. Something that you can do is use the Developer Tools and check to see if all your templates are correct. You just have to paste the template in and see if it gives you an error. This is where I would start.
I’m assuming you’re not manually triggering the some automation as part of testing. If you are, there is no trigger.
Otherwise, do you have automations that have e.g. both a state and time trigger? If you have a template that refers to fields that will only exist if the state trigger fires, but it actually triggered based on time, then you could get such an error.