This component works by polling your Fire TV device at regular intervals. It uses the output of ADB commands to determine properties – namely,
current_app – and uses these to predict the state of the device. The result will be the same regardless of whether you’re using the Python ADB implementation or an ADB server. This method works well for detecting whether the device is off or idle (i.e., in screensaver mode). However, it is not so accurate when it comes to detecting whether or not the device is playing, paused, or on standby. This is a difficult task, since not all Fire TV apps adhere to the same API (as I understand it) and also because many apps aren’t for playing videos at all, and so this state detection doesn’t really apply.
The code that does the state detection has been moved into the
firetv package in the
update function. If you’d like to try to improve it, you can use the
media_player.firetv_adb_cmd service to send ADB commands to the device and view their output, if any, in the Home Assistant log (logging level = INFO). For example, if you send the command
"dumpsys power | grep 'Display Power' | grep -q 'state=ON' && echo -e '1\\c' || echo -e '0\\c'"
(which is the concatenation of the
SUCCESS1_FAILURE0 strings), then the output will be “1” if the device is on and “0” if it is off. It may be necessary to determine the state differently depending on the current app, as indicated by the “TODO” in the
You’re welcome to submit pull requests with improved state detection to the firetv repository.