This topic is old, but I will reply if it is found through search functions:
I found a solution, what can be applied with small external hardware modifications. It is possible to take some measurements on HAT interface's pin "5VIN".
If powered by USB:
Powered by battery and switched off:
Powered by battery and switched on:
Using voltage divider with two same resistors, we get usable logic values for HIGH and LOW ( ~2.3V and ~1.2V). The measured values are not inside garanteed logic range but as a workaround: it works well. Maybe it helps someone else...