Detect when Apple TV off/sleeps?

This might help you, although I haven’t tried it.