unfoldedcircle / feature-and-bug-tracker

Feature and bug tracker repository for Unfolded Circle products
25 stars 0 forks source link

[bug] Android TV: Input Sources don't include HDMI #128

Open uvjim opened 1 year ago

uvjim commented 1 year ago

Is there an existing issue for this?

Description

As per the following screenshot. I am unable to select an HDMI input from the sources list for the "On Sequence". I'm not sure if this was previously possible as I still haven't been able to setup any parts of the remote as I would like.

image

How to Reproduce

  1. Add the Android TV integration
  2. Try to create an Activity that sets the source

Expected behavior

The ability to select an HDMI source.

System version

v1.4.2

What part of the system affected by the problem?

No response

Additional context

No response

kennymc-c commented 1 year ago

I can confirm this for my Sony XE9005. For me it was also never possible to set anything else than any of the installed apps instead of an actual input of the tv. There are also other missing tv function in the Android TV integrations: https://github.com/unfoldedcircle/feature-and-bug-tracker/issues/92

zehnm commented 1 year ago

The current input sources are a static list of well-known Android apps. Unfortunately, there's currently no way to retrieve all apps and physical inputs with the Android TV library we are using. User editing of the pre-defined apps is in the backlog.

However, quickly checking the library, there are key commands to switch inputs! https://github.com/tronikos/androidtvremote2/blob/v0.0.14/src/androidtvremote2/remotemessage.proto#L681-L731

We'll try this, if it works, we include all of them as input sources. Better too many non-existing inputs than none ;-)

zehnm commented 1 year ago

Release 1.4.5 contains a test mode in the REST API for the mentioned input keys. Unfortunatly we only have Android media players, but no access at the moment to real TVs running Android TV. Could someone please test this and report back?

If input switching works, we'll either integrate it in the available sources, or prioritize either the "special entity commands" for media-players or supporting a "remote-entity".

PUT /api/entities/:entityId/command

{
  "cmd_id": "select_source",
  "params": {
      "source": "HDMI 1"
  }
}

The following inputs are available, use the key as value in params.source:

KeyCode = {
    "HDMI 1": "KEYCODE_TV_INPUT_HDMI_1",
    "HDMI 2": "KEYCODE_TV_INPUT_HDMI_2",
    "HDMI 3": "KEYCODE_TV_INPUT_HDMI_3",
    "HDMI 4": "KEYCODE_TV_INPUT_HDMI_4",
    "Toggle Antenna / Cable": "KEYCODE_TV_ANTENNA_CABLE",
    "Toggle Network": "KEYCODE_TV_NETWORK",
    "Satellite": "KEYCODE_TV_SATELLITE",
    "Analog TV": "KEYCODE_TV_TERRESTRIAL_ANALOG",
    "Digital TV": "KEYCODE_TV_TERRESTRIAL_DIGITAL",
    "Composite 1": "KEYCODE_TV_INPUT_COMPOSITE_1",
    "Composite 2": "KEYCODE_TV_INPUT_COMPOSITE_2",
    "Component 1": "KEYCODE_TV_INPUT_COMPONENT_1",
    "Component 2": "KEYCODE_TV_INPUT_COMPONENT_2",
    "VGA 1": "KEYCODE_TV_INPUT_VGA_1",
}

curl example:

curl --request PUT http://$IP/api/entities/$ENTITY_ID/command \
--header 'Content-Type: application/json' \
--user web-configurator:$PIN \
--data '{
  "cmd_id": "select_source",
  "params": { "source": "HDMI 1" }
}'

Expected response: {"code":"OK","message":"Command executed"}

kennymc-c commented 1 year ago

Unfortunately, it doesn't seem to work on my Sony XE9005 with Android TV 9. I get a command executed as feedback but the input is not changed and nothing happens.

uvjim commented 1 year ago

Same here unfortunately. I've attempted a couple of HDMI sources, but nothing happened on the TV. The TV is a Sony KD-65XF9005

image

zehnm commented 1 year ago

Thanks for the feedback @kennymc-c @uvjim

To users with other Android TV models & brands: please add a comment if any of the inputs mentioned above work or not.

zehnm commented 1 year ago

It seems like a general issue, that the INPUT keys don't work: https://github.com/tronikos/androidtvremote2/discussions/10 Let's hope someone figures it out, until then, we can't do anything unfortunately. If companies would only release public APIs...

einfall commented 1 year ago

isn't working here too.

With adb its working: HDMI 1

adb shell am start -a android.intent.action.VIEW -d content://android.media.tv/passthrough/com.mediatek.tvinput%2F.hdmi.HDMIInputService%2FHDMI100004

HDMI 2 adb shell am start -a android.intent.action.VIEW -d content://android.media.tv/passthrough/com.mediatek.tvinput%2F.hdmi.HDMIInputService%2FHW6

HDMI 3 adb shell am start -a android.intent.action.VIEW -d content://android.media.tv/passthrough/com.mediatek.tvinput%2F.hdmi.HDMIInputService%2FHW7

HDMI 4

adb shell am start -a android.intent.action.VIEW -d content://android.media.tv/passthrough/com.mediatek.tvinput%2F.hdmi.HDMIInputService%2FHW8

einfall commented 1 year ago

you could do a trick over HA with ADB Bridge as Script. https://www.home-assistant.io/integrations/androidtv/

androidtv_ha_Script

uvjim commented 1 year ago

Whilst this may not help others... It's possible that once the HEOS integration is released I may not need to switch inputs using the Android TV integration. The HEOS may do that for me. Will need to test when it's released.

uvjim commented 8 months ago

I've come back to this again whilst trying again to configure the remote. Looking at the Bravia TV integration for Home Assistant, this is possible - well, at least for Bravia TVs. The media_player entity in Home Assistant exposes the available sources as a list that you can select from and switch. I have just tested and that seems to work on my TV without issue.

Is it possible to look at this and see if a similar method can be used in the UC Android TV integration? I already have Home Assistant running so I may need to switch to using that as a proxy for controlling the TV if not - I was hoping to minimise dependencies between systems though.

Kat-CeDe commented 4 months ago

I think HA uses adb like I do for switching input and in my case also switching audio output.

Change input with AndroidTV is also not possible with my Philips Android TV.

Ralf