question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Getting HDMI input from the device

See original GitHub issue

For 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:closed
  • Created 3 years ago
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
JeffLIrioncommented, Oct 21, 2020

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 in get_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

1reaction
JeffLIrioncommented, Oct 20, 2020

I think my Fire TV stick doesn’t have the head command, but your command could be modified to:

adb shell dumpsys activity starter | grep -o "HW[0-9]" -m 1

For starters, I’ll add a get_hdmi_input() function.

Read more comments on GitHub >

github_iconTop Results From Across the Web

HDMI Input On A Laptop: Possible? - Blue Cine Tech
Unfortunately, the reality is that it's not possible to get HDMI input on a laptop unless it has a separate HDMI port labelled...
Read more >
Is there any way that a laptop can get an HDMI input? - Quora
No, not directly. A laptop's HDMI port is built to be output only, so you can't use it as an input port no...
Read more >
Easy Ways to Display HDMI on a Laptop - wikiHow
1. Open Projection Settings. Use the search field in the lower left-hand corner of your Windows taskbar. You may also access it by...
Read more >
How to Turn on the HDMI Port on an HP Computer
Right-click the "Volume" icon on the Windows taskbar, select "Sounds" and choose the "Playback" tab. Click the "Digital Output Device (HDMI)" option and...
Read more >
how do I get my laptop to recognize the HDMI cable?
Type troubleshooting in the search bar. · Select Troubleshooting. · Select View all on the top left corner. · Click on Hardware and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found