Would you be willing to share your macro? I'm guessing that your Mac isn't asleep, but that the screen saver is on (which is different.) The KM Engine cannot run when the Mac is asleep, as stated in here:
There are ways to wake up a sleeping Mac using macOS commands, which can even be activated using KM actions, but that doesn't sound like what you are doing here.