Android TV HDMI

I was in here looking for how to do this exact same thing on the exact same hardware! Just wondering, did you have any luck since posting on how to get the XGIMI Horizon Ultra to switch Hdmi inputs using ADB commands?

(I’m a relative noob to scripting stuff, just hoping to overcome the limitation of the remote which doesn’t have a dedicated input change button on it)

Hi Jakub,

I never did work out how to get the XGIMI Horizon Ultra to switch Hdmi inputs using ADB commands. I feel like it should be possible in theory, but in practise nothing I tried worked. I’d be happy to know if someone had more success.

Matthew

How do i use this? What command do i need to use? And where to execute it?

Just for anyone who happens to need it (including me in a month when I forget and need to do it again), this is the command for a TCL C855 HDMI1:

adb shell am start -a android.intent.action.VIEW -d content://android.media.tv/passthrough/com.tcl.tvinput%2F.TvPassThroughService%2FHW15

I have a weird problem. On my TCL tv, if I use the correct HDMI command above it does change input no problem. However, if I manually change the input (using remote) it does NOT update ADB at all meaning that they are not in sync. Any solution? Thanks

I was unable to find a reliable way to change the input to HDMI 1 on my TCL 65QM850G Google TV using an adb shell command with the Android Debug Bridge integration in Home Assistant.

I was able to control many other TV features using it, but just not change the TV’s input to HDMI 1.

So I regressed to just simulating remote key-presses using HA’s Android TV Remote integration.

Fortunately, the TCL/Google TV input selector doesn’t allow “wrapping around”, so my script sends left one time more than the total number of input options displayed, which leaves it at the far left end.
Then I send right once to land on Input HDMI 1. Your counts will likely vary.
Here’s my UI-generated yaml as copied from scripts.yaml:

living_room_tv_hdmi_1:
  alias: Living room TV HDMI 1
  sequence:
  - action: remote.send_command
    target:
      entity_id: remote.living_room_tv
    data:
      command: HOME
  - action: remote.send_command
    metadata: {}
    data:
      command: F3
    target:
      entity_id: remote.living_room_tv
  - action: remote.send_command
    metadata: {}
    data:
      num_repeats: 5
      command: DPAD_LEFT
    target:
      entity_id: remote.living_room_tv
  - action: remote.send_command
    metadata: {}
    data:
      command: DPAD_RIGHT
    target:
      entity_id: remote.living_room_tv
  - action: remote.send_command
    metadata: {}
    data:
      command: ENTER
    target:
      entity_id: remote.living_room_tv
  mode: single
  icon: mdi:television

Sadly neither did I, it’s a real pitty because all the software tech is there without needing to go any other router (like using HDMI-CEC or) but we’re missing a way to know what message to type.

Incidentally, I did look into a different way to switch ports better via installing a different launcher software that removes the bloat of all those adds. But sadly that too had issues pinging the hardware to change hdmi ports.

I am in the same situation with a TCL 65C845 (Android 12). Sending HDMI key codes does not work and I began the ADB journey but noted that some streaming applications had problems with logging in when in debug mode. I will try to pinpoint if that really is the case or if it was a temporary glitch, but can it indeed be the case that applications know when debug mode is on?

Anyhow, I found another potential solution that seems to work for my TV set. The Android TV application Go to HDMI1 input by mpiero actually works! He (assuming here…) has corresponding applications for switching to other inputs as well, but many of them cost money, smart move :grinning:! I use the following card snippet then:

        tap_action:
          action: perform-action
          perform_action: remote.turn_on
          data:
            activity: com.mpiero.android.tvhdmi1
          target:
            entity_id: remote.smart_tv_pro

I’m not sure how this app is implemented. Could there be a general API in Android TV for controlling video sources? This then begs the question whether a backend app for Android TV and home assistant extended control could then be developed!

Just wanna share some tips

With my TV (TCL 65C645 with google tv) and home assistant, this works flawless for HDMI switching without needing tot setup ADB:

action: media_player.play_media
metadata: {}
data:
  media_content_type: app
  media_content_id: >-
    content://android.media.tv/passthrough/com.tcl.tvinput%2F.passthroughinput.TvPassThroughService%2FHW1413744384
target:
  entity_id: media_player.google_tv

These are the different HW ports:

HDMI1: content://android.media.tv/passthrough/com.tcl.tvinput%2F.passthroughinput.TvPassThroughService%2FHW1413744128
HDMI2: content://android.media.tv/passthrough/com.tcl.tvinput%2F.passthroughinput.TvPassThroughService%2FHW1413744384
HDMI3: content://android.media.tv/passthrough/com.tcl.tvinput%2F.passthroughinput.TvPassThroughService%2fHW1413744640
AV:  content://android.media.tv/passthrough/com.tcl.tvinput%2F.passthroughinput.TvPassThroughService%2FHW1413743104 
Cable TV: content://android.media.tv/passthrough/com.tcl.tvinput%2F.TDTVInputService%2FHW1413742848

This is the part (HW address) you prob have to change based on your model/chipset combo

HW1413744384

This part is different if you have an other brand of TV:

com.tcl.tvinput

Its the app that’s in control of the HW based inputs (cable, HDMI, AV) . Other brands have other apps (and thus they are named differently). But I suspect Google is providing a skeleton framework for manufactures to build upon, so it should work with other TV providing you change the appname (com.tcl.tvinput) and the hardware addr (HW1413744384) to fit for your TV brand/chipset.

You’ll see the android indent is almost the same as the ones mentioned above, but the “/” after the app responsible for the input control (in this case com.tcl.tvinput) are all escaped (=changed into %2F).

I think you should be able to pass all kinds of fun stuf to android tv using play_media and content://… als media_content_id without needing custom ABD stuff.

Happy hacking!

Thank you! I’m really trying to understand how to get the chipset?
In general, how to get all the informations that you got?

I want to switch from HDMI to TV and viceversa. This works to go in HDMI:

action: androidtv.adb_command
data:
  command: >-
    adb shell am start -a android.intent.action.VIEW -d content://android.media.tv/passthrough/com.mediatek.tvinput%2F.hdmi.HDMIInputService%2FHDMI100004
target:
  entity_id: media_player.tv_salone

But I can’t find a command to go back on TV (Philips 55PUS7906)

I cannot see where to get the log/responde of eventual ADB command launched to get the list? I’m on supervised home assistant

Replying to myself. Installed adb on my Mac (android platform tools), connected the tv and then typed adb shell. Then run the dump sys tv_input and got this.

PH0M_EA_T32:/ $ dumpsys tv_input
User Ids (Current user: 0):
  0
UserState (0):
  inputMap: inputId -> TvInputState
    com.mediatek.tvinput/.hdmi.HDMIInputService/HW8: info: TvInputInfo{id=com.mediatek.tvinput/.hdmi.HDMIInputService/HW8, pkg=com.mediatek.tvinput, service=com.mediatek.tvinput.hdmi.HDMIInputService}; state: 1
    com.mediatek.tvinput/.tuner.TunerInputService/HW1: info: TvInputInfo{id=com.mediatek.tvinput/.tuner.TunerInputService/HW1, pkg=com.mediatek.tvinput, service=com.mediatek.tvinput.tuner.TunerInputService}; state: 0
    com.mediatek.tvinput/.hdmi.HDMIInputService/HW7: info: TvInputInfo{id=com.mediatek.tvinput/.hdmi.HDMIInputService/HW7, pkg=com.mediatek.tvinput, service=com.mediatek.tvinput.hdmi.HDMIInputService}; state: 1
    com.google.android.videos/.tv.usecase.tvinput.playback.TvInputService: info: TvInputInfo{id=com.google.android.videos/.tv.usecase.tvinput.playback.TvInputService, pkg=com.google.android.videos, service=com.google.android.videos.tv.usecase.tvinput.playback.TvInputService}; state: 0
    com.mediatek.tvinput/.hdmi.HDMIInputService/HW6: info: TvInputInfo{id=com.mediatek.tvinput/.hdmi.HDMIInputService/HW6, pkg=com.mediatek.tvinput, service=com.mediatek.tvinput.hdmi.HDMIInputService}; state: 1
    com.mediatek.tvinput/.hdmi.HDMIInputService/HW5: info: TvInputInfo{id=com.mediatek.tvinput/.hdmi.HDMIInputService/HW5, pkg=com.mediatek.tvinput, service=com.mediatek.tvinput.hdmi.HDMIInputService}; state: 0
    com.mediatek.tvinput/.hdmi.HDMIInputService/HDMI100004: info: TvInputInfo{id=com.mediatek.tvinput/.hdmi.HDMIInputService/HDMI100004, pkg=com.mediatek.tvinput, service=com.mediatek.tvinput.hdmi.HDMIInputService}; state: 0
    com.google.android.videos/com.google.android.apps.play.movies.tv.usecase.tvinput.playback.VideoPreviewInputService: info: TvInputInfo{id=com.google.android.videos/com.google.android.apps.play.movies.tv.usecase.tvinput.playback.VideoPreviewInputService, pkg=com.google.android.videos, service=com.google.android.apps.play.movies.tv.usecase.tvinput.playback.VideoPreviewInputService}; state: 0
    com.mediatek.tvinput/.tuner.TunerInputService/HW0: info: TvInputInfo{id=com.mediatek.tvinput/.tuner.TunerInputService/HW0, pkg=com.mediatek.tvinput, service=com.mediatek.tvinput.tuner.TunerInputService}; state: 0
  packageSet:
    com.google.android.videos
    com.mediatek.tv.service
    com.mediatek.tvinput
  clientStateMap: ITvInputClient -> ClientState
    android.os.BinderProxy@15a49b7: com.android.server.tv.TvInputManagerService$ClientState@fcbee9f
      sessionTokens:
        android.os.Binder@bb829cf
      clientTokens: android.os.BinderProxy@15a49b7
      userId: 0
  serviceStateMap: ComponentName -> ServiceState
    ComponentInfo{com.mediatek.tv.service/com.mediatek.tv.agent.TVRemoteServiceAgent}: com.android.server.tv.TvInputManagerService$ServiceState@11d00db
      sessionTokens:
      service: android.media.tv.ITvInputService$Stub$Proxy@3fe4778
      callback: com.android.server.tv.TvInputManagerService$ServiceCallback@bdb2e51
      bound: true
      reconnecting: false
    ComponentInfo{com.mediatek.tvinput/com.mediatek.tvinput.tuner.TunerInputService}: com.android.server.tv.TvInputManagerService$ServiceState@81596b6
      sessionTokens:
      service: android.media.tv.ITvInputService$Stub$Proxy@be0cfb7
      callback: com.android.server.tv.TvInputManagerService$ServiceCallback@c8c6324
      bound: true
      reconnecting: false
    ComponentInfo{com.mediatek.tvinput/com.mediatek.tvinput.hdmi.HDMIInputService}: com.android.server.tv.TvInputManagerService$ServiceState@fd35e8d
      sessionTokens:
        android.os.Binder@bb829cf
      service: android.media.tv.ITvInputService$Stub$Proxy@1dc6842
      callback: com.android.server.tv.TvInputManagerService$ServiceCallback@7a8b053
      bound: true
      reconnecting: false
    ComponentInfo{com.mediatek.tvinput/com.mediatek.tvinput.component.ComponentInputService}: com.android.server.tv.TvInputManagerService$ServiceState@bbe8d90
      sessionTokens:
      service: android.media.tv.ITvInputService$Stub$Proxy@ca45689
      callback: com.android.server.tv.TvInputManagerService$ServiceCallback@b4cc68e
      bound: true
      reconnecting: false
    ComponentInfo{com.mediatek.tvinput/com.mediatek.tvinput.composite.CompositeInputService}: com.android.server.tv.TvInputManagerService$ServiceState@403feaf
      sessionTokens:
      service: android.media.tv.ITvInputService$Stub$Proxy@7a6f2bc
      callback: com.android.server.tv.TvInputManagerService$ServiceCallback@972d245
      bound: true
      reconnecting: false
    ComponentInfo{com.mediatek.tvinput/com.mediatek.tvinput.scart.SCARTInputService}: com.android.server.tv.TvInputManagerService$ServiceState@852bd9a
      sessionTokens:
      service: android.media.tv.ITvInputService$Stub$Proxy@1bd6cb
      callback: com.android.server.tv.TvInputManagerService$ServiceCallback@34e7ea8
      bound: true
      reconnecting: false
    ComponentInfo{com.mediatek.tvinput/com.mediatek.tvinput.vga.VGAInputService}: com.android.server.tv.TvInputManagerService$ServiceState@f34dc1
      sessionTokens:
      service: android.media.tv.ITvInputService$Stub$Proxy@d8f1966
      callback: com.android.server.tv.TvInputManagerService$ServiceCallback@a8f14a7
      bound: true
      reconnecting: false
  sessionStateMap: ITvInputSession -> SessionState
    android.os.Binder@bb829cf: com.android.server.tv.TvInputManagerService$SessionState@99e66ea
      inputId: com.mediatek.tvinput/.hdmi.HDMIInputService/HDMI100004
      sessionId: 1000301830
      client: android.media.tv.ITvInputClient$Stub$Proxy@ec94ddb
      seq: 2
      callingUid: 1000
      callingPid: 30183
      userId: 0
      sessionToken: android.os.Binder@bb829cf
      session: android.media.tv.ITvInputSession$Stub$Proxy@a833bec
      logUri: null
      hardwareSessionToken: null
  mCallbacks:
    android.media.tv.ITvInputManagerCallback$Stub$Proxy@c75208b
    android.media.tv.ITvInputManagerCallback$Stub$Proxy@ad14ebe
    android.media.tv.ITvInputManagerCallback$Stub$Proxy@2a4437b
    android.media.tv.ITvInputManagerCallback$Stub$Proxy@30e5443
    android.media.tv.ITvInputManagerCallback$Stub$Proxy@9987ac0
    android.media.tv.ITvInputManagerCallback$Stub$Proxy@bd2f3f9
    android.media.tv.ITvInputManagerCallback$Stub$Proxy@abdef3e
    android.media.tv.ITvInputManagerCallback$Stub$Proxy@eea82ec
    android.media.tv.ITvInputManagerCallback$Stub$Proxy@625c14a
    android.media.tv.ITvInputManagerCallback$Stub$Proxy@83408bb
    android.media.tv.TvInputManager$2@e0629e4
    android.media.tv.ITvInputManagerCallback$Stub$Proxy@8a26598
    android.media.tv.ITvInputManagerCallback$Stub$Proxy@4900086
  mainSessionToken: android.os.Binder@bb829cf
TvInputHardwareManager Info:
  mConnections: deviceId -> Connection
    0: Connection{ mHardwareInfo: TvInputHardwareInfo {id=0, type=2, audio_type=-2147467264, audio_addr=, cable_connection_status=0}, mInfo: null, mCallback: null, mConfigs: [TvStreamConfig {mStreamId=0;mType=1;mGeneration=1}, TvStreamConfig {mStreamId=1;mType=1;mGeneration=1}], mCallingUid: null, mResolvedUserId: null, mResourceClientProfile: null }
    1: Connection{ mHardwareInfo: TvInputHardwareInfo {id=1, type=2, audio_type=-2147467264, audio_addr=, cable_connection_status=0}, mInfo: null, mCallback: null, mConfigs: [TvStreamConfig {mStreamId=0;mType=1;mGeneration=1}, TvStreamConfig {mStreamId=1;mType=1;mGeneration=1}], mCallingUid: null, mResolvedUserId: null, mResourceClientProfile: null }
    5: Connection{ mHardwareInfo: TvInputHardwareInfo {id=5, type=9, audio_type=-2147483616, audio_addr=, hdmi_port=1, cable_connection_status=0}, mInfo: TvInputInfo{id=com.mediatek.tvinput/.hdmi.HDMIInputService/HDMI100004, pkg=com.mediatek.tvinput, service=com.mediatek.tvinput.hdmi.HDMIInputService}, mCallback: android.media.tv.ITvInputHardwareCallback$Stub$Proxy@aaa9bb5, mConfigs: [TvStreamConfig {mStreamId=0;mType=1;mGeneration=1}, TvStreamConfig {mStreamId=1;mType=1;mGeneration=1}], mCallingUid: 1000, mResolvedUserId: 0, mResourceClientProfile: ResourceClientProfile {tvInputSessionId=null, useCase=400} }
    6: Connection{ mHardwareInfo: TvInputHardwareInfo {id=6, type=9, audio_type=-2147483616, audio_addr=, hdmi_port=2, cable_connection_status=0}, mInfo: null, mCallback: null, mConfigs: [TvStreamConfig {mStreamId=0;mType=1;mGeneration=1}, TvStreamConfig {mStreamId=1;mType=1;mGeneration=1}], mCallingUid: null, mResolvedUserId: null, mResourceClientProfile: null }
    7: Connection{ mHardwareInfo: TvInputHardwareInfo {id=7, type=9, audio_type=-2147483616, audio_addr=, hdmi_port=3, cable_connection_status=0}, mInfo: null, mCallback: null, mConfigs: [TvStreamConfig {mStreamId=0;mType=1;mGeneration=1}, TvStreamConfig {mStreamId=1;mType=1;mGeneration=1}], mCallingUid: null, mResolvedUserId: null, mResourceClientProfile: null }
    8: Connection{ mHardwareInfo: TvInputHardwareInfo {id=8, type=9, audio_type=-2147483616, audio_addr=, hdmi_port=4, cable_connection_status=0}, mInfo: null, mCallback: null, mConfigs: [TvStreamConfig {mStreamId=0;mType=1;mGeneration=1}, TvStreamConfig {mStreamId=1;mType=1;mGeneration=1}], mCallingUid: null, mResolvedUserId: null, mResourceClientProfile: null }
    9: Connection{ mHardwareInfo: TvInputHardwareInfo {id=9, type=2, audio_type=-2147467264, audio_addr=, cable_connection_status=0}, mInfo: null, mCallback: null, mConfigs: [TvStreamConfig {mStreamId=0;mType=1;mGeneration=1}, TvStreamConfig {mStreamId=1;mType=1;mGeneration=1}], mCallingUid: null, mResolvedUserId: null, mResourceClientProfile: null }
    10: Connection{ mHardwareInfo: TvInputHardwareInfo {id=10, type=2, audio_type=-2147467264, audio_addr=, cable_connection_status=0}, mInfo: null, mCallback: null, mConfigs: [TvStreamConfig {mStreamId=0;mType=1;mGeneration=1}, TvStreamConfig {mStreamId=1;mType=1;mGeneration=1}], mCallingUid: null, mResolvedUserId: null, mResourceClientProfile: null }
    14: Connection{ mHardwareInfo: TvInputHardwareInfo {id=14, type=9, audio_type=-2147483616, audio_addr=, hdmi_port=1, cable_connection_status=0}, mInfo: null, mCallback: null, mConfigs: [TvStreamConfig {mStreamId=0;mType=1;mGeneration=1}, TvStreamConfig {mStreamId=1;mType=1;mGeneration=1}], mCallingUid: null, mResolvedUserId: null, mResourceClientProfile: null }
    15: Connection{ mHardwareInfo: TvInputHardwareInfo {id=15, type=9, audio_type=-2147483616, audio_addr=, hdmi_port=2, cable_connection_status=0}, mInfo: null, mCallback: null, mConfigs: [TvStreamConfig {mStreamId=0;mType=1;mGeneration=1}, TvStreamConfig {mStreamId=1;mType=1;mGeneration=1}], mCallingUid: null, mResolvedUserId: null, mResourceClientProfile: null }
    16: Connection{ mHardwareInfo: TvInputHardwareInfo {id=16, type=9, audio_type=-2147483616, audio_addr=, hdmi_port=3, cable_connection_status=0}, mInfo: null, mCallback: null, mConfigs: [TvStreamConfig {mStreamId=0;mType=1;mGeneration=1}, TvStreamConfig {mStreamId=1;mType=1;mGeneration=1}], mCallingUid: null, mResolvedUserId: null, mResourceClientProfile: null }
    17: Connection{ mHardwareInfo: TvInputHardwareInfo {id=17, type=9, audio_type=-2147483616, audio_addr=, hdmi_port=4, cable_connection_status=0}, mInfo: null, mCallback: null, mConfigs: [TvStreamConfig {mStreamId=0;mType=1;mGeneration=1}, TvStreamConfig {mStreamId=1;mType=1;mGeneration=1}], mCallingUid: null, mResolvedUserId: null, mResourceClientProfile: null }
  mHardwareList:
    TvInputHardwareInfo {id=0, type=2, audio_type=-2147467264, audio_addr=, cable_connection_status=0}
    TvInputHardwareInfo {id=1, type=2, audio_type=-2147467264, audio_addr=, cable_connection_status=0}
    TvInputHardwareInfo {id=5, type=9, audio_type=-2147483616, audio_addr=, hdmi_port=1, cable_connection_status=0}
    TvInputHardwareInfo {id=6, type=9, audio_type=-2147483616, audio_addr=, hdmi_port=2, cable_connection_status=0}
    TvInputHardwareInfo {id=7, type=9, audio_type=-2147483616, audio_addr=, hdmi_port=3, cable_connection_status=0}
    TvInputHardwareInfo {id=8, type=9, audio_type=-2147483616, audio_addr=, hdmi_port=4, cable_connection_status=0}
    TvInputHardwareInfo {id=9, type=2, audio_type=-2147467264, audio_addr=, cable_connection_status=0}
    TvInputHardwareInfo {id=10, type=2, audio_type=-2147467264, audio_addr=, cable_connection_status=0}
    TvInputHardwareInfo {id=14, type=9, audio_type=-2147483616, audio_addr=, hdmi_port=1, cable_connection_status=0}
    TvInputHardwareInfo {id=15, type=9, audio_type=-2147483616, audio_addr=, hdmi_port=2, cable_connection_status=0}
    TvInputHardwareInfo {id=16, type=9, audio_type=-2147483616, audio_addr=, hdmi_port=3, cable_connection_status=0}
    TvInputHardwareInfo {id=17, type=9, audio_type=-2147483616, audio_addr=, hdmi_port=4, cable_connection_status=0}
  mHdmiDeviceList:
    CEC: logical_address: 0x04 device_type: 4 vendor_id: 3303 display_name: Amazon Fire T power_status: 0 physical_address: 0x1000 port_id: 1
  mHardwareInputIdMap: deviceId -> inputId
    0: com.mediatek.tvinput/.tuner.TunerInputService/HW0
    1: com.mediatek.tvinput/.tuner.TunerInputService/HW1
    5: com.mediatek.tvinput/.hdmi.HDMIInputService/HW5
    6: com.mediatek.tvinput/.hdmi.HDMIInputService/HW6
    7: com.mediatek.tvinput/.hdmi.HDMIInputService/HW7
    8: com.mediatek.tvinput/.hdmi.HDMIInputService/HW8
  mHdmiInputIdMap: id -> inputId
    4: com.mediatek.tvinput/.hdmi.HDMIInputService/HDMI100004
  mInputMap: inputId -> inputInfo
    com.mediatek.tvinput/.tuner.TunerInputService/HW0: TvInputInfo{id=com.mediatek.tvinput/.tuner.TunerInputService/HW0, pkg=com.mediatek.tvinput, service=com.mediatek.tvinput.tuner.TunerInputService}
    com.mediatek.tvinput/.tuner.TunerInputService/HW1: TvInputInfo{id=com.mediatek.tvinput/.tuner.TunerInputService/HW1, pkg=com.mediatek.tvinput, service=com.mediatek.tvinput.tuner.TunerInputService}
    com.mediatek.tvinput/.hdmi.HDMIInputService/HW5: TvInputInfo{id=com.mediatek.tvinput/.hdmi.HDMIInputService/HW5, pkg=com.mediatek.tvinput, service=com.mediatek.tvinput.hdmi.HDMIInputService}
    com.mediatek.tvinput/.hdmi.HDMIInputService/HW6: TvInputInfo{id=com.mediatek.tvinput/.hdmi.HDMIInputService/HW6, pkg=com.mediatek.tvinput, service=com.mediatek.tvinput.hdmi.HDMIInputService}
    com.mediatek.tvinput/.hdmi.HDMIInputService/HW7: TvInputInfo{id=com.mediatek.tvinput/.hdmi.HDMIInputService/HW7, pkg=com.mediatek.tvinput, service=com.mediatek.tvinput.hdmi.HDMIInputService}
    com.mediatek.tvinput/.hdmi.HDMIInputService/HW8: TvInputInfo{id=com.mediatek.tvinput/.hdmi.HDMIInputService/HW8, pkg=com.mediatek.tvinput, service=com.mediatek.tvinput.hdmi.HDMIInputService}
    com.mediatek.tvinput/.hdmi.HDMIInputService/HDMI100004: TvInputInfo{id=com.mediatek.tvinput/.hdmi.HDMIInputService/HDMI100004, pkg=com.mediatek.tvinput, service=com.mediatek.tvinput.hdmi.HDMIInputService}

The “tuner.TunerInputService/HW0” is my DTV (cable TV input ) :slight_smile:
It now works with this service:

action: androidtv.adb_command
data:
  command: >-
    adb shell am start -a android.intent.action.VIEW -d
    content://android.media.tv/passthrough/com.mediatek.tvinput%2F.tuner.TunerInputService%2FHW0
target:
  entity_id: media_player.tv_salone

I’ve got TCL 85T8B and actually figured out accidentally when I tested casting from macbook to TV, that device got discovered in HA via HomeKit integration which allows switching source easily using media player - select source action

For my XGIMI Horizon Pro I managed to switch to HDMI 1 by enabling ADB and blindly navigating the menu like so: home, up, right, right, right, ok, ok.

This is the script I am using:

alias: Projector XGIMI - Switch to HDMI 1
description: >
  Navigates from the projector's Home screen to the HDMI input selection and
  selects HDMI 1 as the active input.
mode: single
sequence:
  - data:
      command: input keyevent 3
    target:
      entity_id: media_player.android_tv_adb_projector
    action: androidtv.adb_command
  - delay: "00:00:00.5"
  - data:
      command: input keyevent 19
    target:
      entity_id: media_player.android_tv_adb_projector
    action: androidtv.adb_command
  - delay: "00:00:00.5"
  - repeat:
      count: 3
      sequence:
        - data:
            command: input keyevent 22
          target:
            entity_id: media_player.android_tv_adb_projector
          action: androidtv.adb_command
        - delay: "00:00:00.5"
  - data:
      command: input keyevent 23
    target:
      entity_id: media_player.android_tv_adb_projector
    action: androidtv.adb_command
  - delay: "00:00:00.5"
  - data:
      command: input keyevent 23
    target:
      entity_id: media_player.android_tv_adb_projector
    action: androidtv.adb_command

Hi,
Thank you for this amazing work that allowed me to quickly find the solution to switch HDMI ports.

I have a XGIMI Aura 2 and i manage to change to HDMI 1 with the command :

adb shell am start -a android.intent.action.VIEW -d content://android.media.tv/passthrough/com.xgimi.tvinput%2F.inputservice.Hdmi1TvInputService%2FHW1 -n com.xgimi.xhplayer/com.xgimi.xhplayer.InputActivity -f 0x10000000

Many thanks - Shame its not a simple command rather thana script - but the above helped get the same result - just more complex

You sir are a KING ! this worked for me on Xgimi Horizon S Max after many fails with chatgpt (altho I was getting close…). How did you find the exact code? Just out of curiosity

1 Like

Thank you, I’m glad this can help others too :slight_smile:
Yes, of course! Here’s how I proceeded to find the right command (thanks to the help from the previous comments ^^).

First, I needed to find the command line to switch the HDMI source.
So, I connected via ADB :
adb connect xxx.xxx.xxx.xxx:5555
connected to xxx.xxx.xxx.xxx:5555
then I ran the following command adb logcat | grep InputService to get the logs, and I changed the HDMI source using the remote control.

In the log file, I found the following line:

 ActivityTaskManager: START u0 {act=android.intent.action.VIEW dat=content://android.media.tv/passthrough/com.xgimi.tvinput/.inputservice.Hdmi1TvInputService/HW1 flg=0x10000000 cmp=org.droidtv.playtv/.PlayTvActivity} from uid 2000

So I tried the following command:

adb shell am start -a android.intent.action.VIEW -d content://android.media.tv/passthrough/com.xgimi.tvinput%2F.inputservice.Hdmi1TvInputService%2FHW1

But I got the following error:

Error: Activity not started, unable to resolve Intent { act=android.intent.action.VIEW dat=content://android.media.tv/passthrough/com.xgimi.tvinput/.inputservice.Hdmi1TvInputService/HW1 flg=0x10000000 }

So I figured I needed to find the activity related to that command. I repeated the process, but this time I didn’t filter on InputService in the adb logcat, and then I searched for “activity” in the log. That’s when I found this line:

ActivityManager: Start proc 22838:com.xgimi.xhplayer/1000 for pre-top-activity {com.xgimi.xhplayer/com.xgimi.xhplayer.InputActivity}

So I tried the following command:

adb shell am start -a android.intent.action.VIEW -d content://android.media.tv/passthrough/com.xgimi.tvinput%2F.inputservice.Hdmi1TvInputService%2FHW1 -n com.xgimi.xhplayer/com.xgimi.xhplayer.InputActivity -f 0x10000000

And it worked :slight_smile:

Awesome !! I was looking for the solution for months ! It works perfectly on my Xgimi Horizon Ultra.
Thanks a lot !

1 Like

Continuing the discussion from Android TV HDMI:

I’ve not read the thread but got here by googling for a solution for my Xgimi projector so maybe I’ll help someone else.

I managed to switch to HDMI (on Xgimi Horizon 1080p) by firing this ADB command:

am start -n com.xgimi.xhplayer/.InputActivity

:fr:

Change HDMI Source Input via ADB (Android Debug Bridge) on Philips Android TV (908 OLED+)

Hi everyone,

Reviving this topic because I ran into some odd behavior with my Philips Android TV (908 OLED+). I couldn’t find a page that matched my situation exactly, especially since Philips uses HWx input IDs, but doesn’t fully follow standard Android TV conventions.

Switch to HDMI 3 using ADB.

If you’re not using a custom launcher, this worked for me :

adb shell am start -a android.intent.action.VIEW -d content://android.media.tv/passthrough/com.mediatek.tis%2F.HdmiInputService%2FHDMI3 -n org.droidtv.playtv/.PlayTvActivity

Make sure to encode the forward slashes as %2F like above (not all of them). That was one mistake I made at first.

Also, this common variant seemed correct (but is not):

adb shell am start -a android.intent.action.VIEW -d content://android.media.tv/passthrough/com.mediatek.tvinput%2F.hdmi.HDMIInputService%2FHDMI3 -n org.droidtv.playtv/.PlayTvActivity

but doesn’t bind any active video stream to the screen, it only switches the correct input label , no image, just a black and blank screen.

If you’re using Projectivity Launcher, this is the right command (which I spotted easily from logcat/dumpsys) :

adb shell am start -n com.spocky.projengmenu/.ui.guidedActions.activities.input.SourceHDMI3Activity

This worked flawlessly.

1 Like