Nerwyn / android-tv-card

A completely customizable universal remote card for Home Assistant. Supports multiple platforms out of the box.
Apache License 2.0
254 stars 13 forks source link

androidtv/adb_command #19

Closed 1mfaasj closed 1 year ago

1mfaasj commented 1 year ago

Hi, I am trying to get the Search working that you describe here (https://github.com/Nerwyn/android-tv-card#google-assistant-search). When I just add "search" in my lovelace card I get this error:

Cannot call service androidtv/adb_command. must contain at least one of entity_id, device_id, area_id. so I have to work with custom keys I assume?

so I if I add the following:

    custom_keys:
      search:
        service: androidtv.adb_command
        service_data:
          entity_id: media_player.samsung_au7100_70_tv

I get this error:

Cannot call service androidtv/adb_command. required key not provided @ data['command']

so I need to add a command I guess, but when I put something like this it doesn't work. the text box doesnt appear:

    custom_keys:
      search:
        service: androidtv.adb_command
        service_data:
          entity_id: media_player.samsung_au7100_70_tv
          command: HOME

but that's strange because what I enter in the text box should be sent as a "command", right? -> image

or am I missing something here?

I have added Android Debug Bridge successfully in HA dus ABD is correctly configured on my TV.

Nerwyn commented 1 year ago

Please post your full config (I should update the issue template to say this). You should have the keyboard_id (formerly adb_id which also still works) option filled out with your Android TV ADB media player entity ID.

1mfaasj commented 1 year ago

my full config: I've set "keyboard_id" and "search" but the "search" is asking for the "command" like I described above.

type: vertical-stack
cards:
  - type: custom:mini-media-player
    entity: media_player.samsung_au7100_70_tv
    volume_stateless: false
  - type: media-control
    entity: media_player.chromecast_2
  - type: custom:android-tv-card
    remote_id: remote.chromecastwoonkamer
    media_player_id: media_player.samsung_au7100_70_tv
    keyboard_id: media_player.samsung_au7100_70_tv
    title: TVWoonkamer
    rows:
      - - back
        - power
        - home
        - search
      - - volume_down
        - volume_mute
        - volume_up
      - - navigation_buttons
      - - netflix
        - youtube
        - disney
        - spotify
      - - previous
        - rewind
        - play_pause
        - fast_forward
        - next
    custom_keys:
      volume_down:
        service: media_player.volume_down
        service_data:
          entity_id: media_player.samsung_au7100_70_tv
      volume_mute:
        service: media_player.volume_mute
        service_data:
          entity_id: media_player.samsung_au7100_70_tv
          is_volume_muted: true
      volume_up:
        service: media_player.volume_up
        service_data:
          entity_id: media_player.samsung_au7100_70_tv
      search:
        service: androidtv.adb_command
        service_data:
          entity_id: media_player.samsung_au7100_70_tv
          command: ???
Nerwyn commented 1 year ago

Don't create a custom key for search, doing so overrides the default behavior. It also looks like you set the keyboard_id to your Samsung TV instead of your Chromecast ADB media player entity?

1mfaasj commented 1 year ago

Hm when I set the keyboard id to the entity name of my tv (the one from the android bridge HA extention) and remove custom search it gives me this error

Cannot call service androidtv/adb_command. must contain at least one of entity_id, device_id, area_id

1mfaasj commented 1 year ago

Every entity of my tv gives the same error. So the chromecast, remote and media player, android bridge..

Nerwyn commented 1 year ago

If you're including adb/keyboard ID then that's really weird because that is the entity ID that gets included in the ADB command here in code. I wonder if it's a browser caching issue? Can you try clearing cache or pressing Ctrl + F5 on the page with the remote?

1mfaasj commented 1 year ago

It still doesn't work, unfortunately, I keep getting the message even when I clear the cache. Do you perhaps have other ideas? otherwise I'll leave it at that :-(

Nerwyn commented 1 year ago

What are the entity IDs of your Android TV remote, Android TV media player, Android ADB media player, and Samsung TV media player?

If you go to Developer tools > SERVICES and set the service to androidtv.adb_command, and call the command am start -a "android.search.action.GLOBAL_SEARCH" --es query "test" does it throw the same error?

1mfaasj commented 1 year ago

Yes the same error: image

the entities:

From the Android ADB media player integration:

From the Android TV Remote integration:

from the Samsung Smart TV integration:

When I choose the Android Bridge entity option here, it says Succceed but nothing happens on the TV. image

Nerwyn commented 1 year ago

media_player.android_tv_192_168_2_177 is the right entity ID to use for keyboard_id. From your second screenshot it looks like the command sends successfully when you use it but your Android TV isn't doing anything. I see that your language is set to Dutch. I wonder if this is a localization issue? Could you also try some other ADB commands and see if they work?

1mfaasj commented 1 year ago

Ok I've done some more testing and when I execute the command you send earlier it's working on the Chromecast TV. Also in the developer tools when I select the bridge entity ID.

This also works but I want to use your text box instead (the Search)

service: androidtv.adb_command
data:
  command: >-
    am start -a "android.search.action.GLOBAL_SEARCH" --es query "{{
    states('input_text.androidtv_adb_zolder') }}"
target:
  device_id: media_player.android_tv_192_168_2_177
enabled: true

Not 100 procent sure why it's working now I guess I had another view open in the chromecast, then commands doesn't work. Only the home page of google tv works apparently.

The Search doesn't work yet still complaining about the missing entity id

1mfaasj commented 1 year ago

Ok I cleared my cache and now the Search works Thanks for your time and patience!