Check if ZigBee2MQTT is working

Z2M has a running entity which you can use to determine if it’s running or not:

Note that it might be disabled by default and you will probably have to enable it manually. I doubt you can get this entity’s state directly in your ESPHome code though - you might have to use an automation in HA as a workaround.

The above doesn’t solve the actual problem though. Z2M should not be going down for any period of time. I would start by reading this first and fixing the Z2M issue instead of trying to work around it.