Correct state detection is a known issue for the Android TV integration. The way it works is by collecting some properties and then using some simple logic to determine the state. The challenge is that there’s no one way to determine the state that works for all apps, so logic needs to be implemented for each app in order to ensure correct results. This logic might even need to differ from one Android TV device to the next.
A solution that was suggested in a GitHub issue was to allow the user to provide custom rules for determining the state. I implemented that, but I haven’t had a chance to test it yet. That’s where you come in!
Here is a custom component for testing: https://github.com/JeffLIrion/ha-androidtv/tree/custom_state_detection/custom_components/androidtv
You need all the files in that directory. And make sure that you get the files from the custom_state_detection
branch!
Example config
media_player:
- platform: androidtv
name: Fire TV (Bedroom)
device_class: firetv
host: 192.168.0.10
state_detection_rules:
'com.amazon.tv.launcher':
- 'standby'
'com.netflix.ninja':
- 'media_session_state'
'com.hulu.plus':
- 'media_session_state'
- 'wake_lock_size':
1: 'playing' # this indentation is important!
2: 'paused' # this indentation is important!
- 'audio_state'