Act when powering off Nvidia Shield TV

I’m running a Nvidia Shield TV unit (Android). I would like to send a message to HASS whenever the Shield TV unit is about to enter Sleep Mode / Power Off to trigger some events on HASS.

For this, I’m wondering the simplest and easiest way to accomplish this. There seem to be many options like Tasker, AutoRemote, SSH, ADB, MQTT etc…

It seems tricky to catch the state of Sleep / Power off and at the same time send a message to HASS. How would you solve this?


Did you found a solution to accomplish an action based on the power state of the shield?