Getting HDMI input from the device
See original GitHub issueFor my (Home Assistant) setup, I only care about the HDMI input of the device. I have found out that this value changes as the HDMI input changes:
$ adb shell dumpsys activity starter | grep "HW[0-9]"
Intent { act=android.intent.action.VIEW dat=content://android.media.tv/passthrough/com.mediatek.tvinput%2F.hdmi.HDMIInputService%2FHW5 flg=0x10000000 cmp=org.droidtv.playtv/.PlayTvActivity (has extras) }
mIntent=Intent { act=android.intent.action.VIEW dat=content://android.media.tv/passthrough/com.mediatek.tvinput/.hdmi.HDMIInputService/HW5 flg=0x10000000 cmp=org.droidtv.playtv/.PlayTvActivity (has extras) }
Specifically, for my two HDMI inputs, you’d either get HW5 or HW6. So a neater solution is:
$ adb shell dumpsys activity starter | grep -o "HW[0-9]" | head -n 1
Now I can do some magic and run a script that calls androidtv.adb_command
every 5 seconds or so and then grab the output from the device’s adb_response
. I then also have to take in to account whether the device is turned on, etc (not that the command fails otherwise, but it makes little sense querying an inactive device).
But ideally this would be integrated in to this repo, so the state can be returned in home assistant and it can be used by more people. The thing is, I have no idea whether this works for everyone.
Otherwise, it would be nice if we could do something like this to automatically include custom states in the entity’s attributes:
media_player:
- platform: androidtv
name: Philips TV
host: 10.0.0.100
adb_server_ip: 127.0.0.1
get_sources: false
track:
- name: hdmi_input
command: dumpsys activity starter | grep -o "HW[0-9]" | head -n 1
My TV is a Philips 55POS9002 by the way.
Issue Analytics
- State:
- Created 3 years ago
- Comments:11 (6 by maintainers)
Top GitHub Comments
I added a
get_hdmi_input()
function.For including this in Home Assistant, the HDMI input should be retrieved as part of the
update()
function, which in turn means that it should be obtained inget_properties()
. So the ADB commands will need to be modified and the HDMI input will need to be parsed from the output.https://github.com/JeffLIrion/python-androidtv/blob/ba60b553e02f76569ba760c76accbe5c5a4b612e/androidtv/constants.py#L67-L101
I think my Fire TV stick doesn’t have the
head
command, but your command could be modified to:For starters, I’ll add a
get_hdmi_input()
function.