HA control vs microcontroller

Lets say we have a fan or tank controller. Under normal circumstances it is controlled via HA with all the benefits. But if for some reason HA is not available is there a way to program the microcontroller to fallback to it’s own logic?

You can do an awful lot of control on board the ESP: Automations and Templates — ESPHome

However I don’t think you can say “do it on HA but if HA isn’t working, fall back to the ESP”.

But you can split the functions, so that ESPhome does the mission critical (like maintaining your fish temperature) while HA does fancier/less important stuff (like remembering the number of days since the last filter change).

I’ve read through that. And question remains if connectivity to HA can be a condition to launch own automation

Oh OK, I guess the api_connected condition could be used on all your internal automations Native API Component — ESPHome