Android TV HDMI

Thanks for this, also how do use this as trigger?
I need to turn on my tivo 4k stick when hdmi 3 is selected

TCL 98P74 LCD

HDMI 1:

service: androidtv.adb_command
data:
  command: >-
    adb shell am start -a android.intent.action.VIEW -d
    content://android.media.tv/passthrough/com.tcl.tvinput%2F.TvPassThroughService%2FHW15
target:
  entity_id: media_player.android_tv
1 Like

hi. Thank you for sharing, Works great on my 848 as well.

This one changed my tcl c635 to tv program. So how do i find out the code to use for HDMI1 and HDMI2? thanks

Manage to find out myself. Post it here for those use TCL 43C635 TV
HDMI 1
adb shell am start -a android.intent.action.VIEW -d content://android.media.tv/passthrough/com.tcl.tvinput%2F.passthrough.TvPassThroughService%2FHW1413744128

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

I’m struggling with this. I have the TCL C805 and the codes I’ve tried here only allow me to switch to HDMI1 (this is despite changing the HW reference at the end of the command for the other HDMI inputs).

Does anyone have a solution for TCL C805 on how to change source to HDMI 2, 3 & 4?

EDIT: Solution for my TV in my follow up post here

1 Like

Hello again.
Now that this feature works nicely on my TV, I was wondering if I could implement one more with the help of ADB send command.
So, instead of using the remote control to go home_screen > Settings > System > Power & Energy > and lastly “Screen off”… could I just send a code?

This is what I see via the logcat, but I really don’t know how to convert this info into a command (if even possible):

02-24 09:59:44.687  1309 11400 D MtkLog  : 8
02-24 09:59:44.687  1628 11402 D MtkLog  : 8
02-24 09:59:44.688  1433 11403 D MtkLog  : 8
02-24 09:59:44.700  3315 11406 D MtkLog  : 8
02-24 09:59:44.806  1352  2070 D LogKeyEvent: : key=23,scan=353,src=3,sys=0
02-24 09:59:44.806  2073  3000 D TvPowerManagerService: scanCode = 353, src = 3
02-24 09:59:44.806  2073  3000 D TvInactivityTimer: mService android.os.Messenger@e873fb2
02-24 09:59:44.806  1352  2839 D DrvCustomNative: setInt
02-24 09:59:44.807  1352  2839 D DrvCustomNativeJni: <Java_org_droidtv_tv_drvcustom_DrvCustomNative_set:111> set: 2,1,1
02-24 09:59:44.806  1380  2676 D TPTvServiceAgent: ScreenOffGreenMute: false,false,23
02-24 09:59:44.807   546   546 D TPVDrvCustomService: <tpvdrvcust_hidl_set:44> type=2, value=1
02-24 09:59:44.807   546   546 D tpv_drv_cust_leds: <ir_blinking:132> ir_blinking called
02-24 09:59:44.807   546   809 D tpv_drv_cust_leds: <irLedService:40> irLedService IR blinking start...
02-24 09:59:44.808  2198  2198 D TvInactivitySvc: UserActivity
02-24 09:59:44.808  1352  2839 D DrvCustomNativeJni: <Java_org_droidtv_tv_drvcustom_DrvCustomNative_set:113> set: ret=0
02-24 09:59:44.808   546   809 D tpv_drv_cust_leds: <set:124> Set Leds ON/OFF. on_off=1
02-24 09:59:44.809  1681  1740 D candeebug.Gateway: Returning successfully for event: {"event-type":"unknown.15","boot-count":52,"standby-count":4,"kernel-time":47380912,"data":{"original-event-type":15,"device_name":1,"key_group":11,"rc_side":0,"ver":5}}
02-24 09:59:44.810   553   571 E FmsOledSaver: mark:0, logo:0, bmessage:0, #diff pix:  0, change:0, noClapse:   0, sSaving:0
02-24 09:59:44.810   553   571 E FmsOledSaver: sLevel:2, pMotion:0, bchange:0, noBClapse:   6, sDimming:0, ssFlag:0
02-24 09:59:44.909   546   809 D tpv_drv_cust_leds: <set:124> Set Leds ON/OFF. on_off=0
02-24 09:59:44.910   546   809 D tpv_drv_cust_leds: <set:124> Set Leds ON/OFF. on_off=0
02-24 09:59:44.910   546   809 D tpv_drv_cust_leds: <irLedService:56> irLedService IR blinking end...
02-24 09:59:44.918  1628  4305 I ImageStickingService: Amith keyCode23
02-24 09:59:44.918  1628  4305 D DreamerService: OnKeyPressed received:true
02-24 09:59:44.918  1628  4305 D DreamerService:  isScreenSaverTriggered=0globalosdcount:0forceTrigger:0gResetCounter0
02-24 09:59:44.918  1628  1628 E DreamerService: SSS:false:null:null:false
02-24 09:59:44.920  1433  1433 D TpvPowerAndEnergyFragment: onPreferenceTreeClick() key = screen_off
02-24 09:59:44.920  1433  1433 I TpvPowerAndEnergyFragment: enterScreenOff()
02-24 09:59:44.920  1433  1433 D KeyInputDevImpl: set: 6,1
02-24 09:59:44.920  1433  1433 D KeyInputDevN: setCustomValue: 6:1
02-24 09:59:44.920  1433  1433 D KeyInputDevN: Get ksvc
02-24 09:59:44.921  1380  2530 D TPTvServiceAgent: POWER_SCREEN_OFF_UI: 1,false,false
02-24 09:59:44.921  1804  1952 D UsbBreakinService: POWER_SCREEN_OFF_UI: 1,false,false
02-24 09:59:44.922  1433  1433 D GtvNotificationManager:  All GTV notifications are canceled
02-24 09:59:44.923   919  1073 W DevicePolicyManager: Unknown user type: UserInfo{10:new_user:1010}
02-24 09:59:44.929   919   919 I AlarmManager: Change Wakeup Alarm type to non Wakeup type, current type=[2] packageName = android statsTag = *walarm*:NotificationManagerService.TIMEOUT @91154029 and next wakeup alarm is @Sat Feb 24 20:41:02 GMT+01:00 2024

especially this part:

02-24 09:59:44.920  1433  1433 D TpvPowerAndEnergyFragment: onPreferenceTreeClick() key = screen_off
02-24 09:59:44.920  1433  1433 I TpvPowerAndEnergyFragment: enterScreenOff()

Any help/pointer is appreciated, thank you.

Hi all, I’ve worked out how to control HDMI Inputs and Home on TCL C805 TV (TCL 75C805 / TCL 75C805K in my case).

HDMI 1

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

HDMI 2

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

HDMI 3

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

HDMI 4

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

Home screen (Google TV Home screen)

am start -a android.intent.action.MAIN -c android.intent.category.HOME
1 Like

Anyone knows how to change to Cable or Antenna input from HDMI?

Thanks! Works for TCL 75C849

anyone get this to work for an xgimi? I have a horizon pro and I can get the hdmi to switch using the terminal from my pc, but not from homeassistant using that exact same command using androidtv_adb.command.

there is no error I can see using the dev tools for this service call.

this is what I am trying to use and I have verified that the home assistant machine has been allowed to run adb commands.

data:
  command: >-
    am start -a android.intent.action.VIEW -d content://android.media.tv/passthrough/com.xgimi.tvinput%2F.inputservice.Hdmi2TvInputService%2FHW2
target:
  entity_id: media_player.android_tv_192_168_20_166```

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.

работает на TCL 85P737. Спасибо!

action: androidtv.adb_command
data:
command: “am start -a android.intent.action.VIEW -d content://android.media.tv/passthrough/com.tcl.tvinput%2F.passthroughinput.TvPassThroughService%2FHW1413744128”
target:
entity_id: media_player.android_tv_192_168_199_11

HDMI1

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

HDMI2

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

HDMI3

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

HDMI4 - у меня нет

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!