Automation trigger when integration doesn't load/fails setup

Is there a way to listen for integrations going through “setup” that can be utilized in an automation?

Every now and then, my ZHA goes offline (Failed setup, will retry in UI “integrations” tab), and sometimes, the only thing that works is to power cycle the PoE coordinator. The PoE injector is plugged into a smart plug, so I just power cycle via the HA UI.

But it would be neat to just have it do that automatically, if the integration is in Failed setup, will retry for more than a few minutes.

All the solutions I have seen to this use an entity provided by the integration as a proxy for whether the integration itself is working (e.g, this or this). Since Zigbee devices can go offline for other reasons (someone flips a switch, batteries die, etc.), that approach wouldn’t work.

So, can you actually listen for whether the integration itself is “online”, and use that as a trigger in an automation?

Do you get an error in the log? If so you might be able to use that as a trigger. There’s an example here (the thread is very old, but the last post is recent):