The problem I’m having is I now want to save the state of an automation when I turn it on or off from the GUI, and have that reflected in system_cleanup.
I was thinking that I could create an automation that adds every automation that is “off” to a new group anytime an automation is turned on or off, and then use this group in system_cleanup to turn these automations off.
How can I create an automation that fires anytime an automation is turned on or off?
But are there just a couple of automations that are a problem running on restart? if that’s the case then it might just as easy to turn those to "initial_state: ‘off’ " then turn those back on after HA completes it’s restart. I do that for some low battery notifications that erroneously report low batteries at restart.
If so, one simple way to fix it is to include a condition in the automations that requires the zwave network to be ready.
That way you can leave out the initial_state code all together such that the automations will just restore to their previous states on boot.