Native support for Android TV / Android devices

Thanks will try it.

My Shield goes into sleep mode (or whatever it is, the green led lights go to off), whenever I turn off my TV/Receiver (I guess its the CEC function?).

Will I still be able to send a command (turn on Netflix) that wakes up the Shield and runs the app Netflix?

Yeah, it still stays connected when asleep. However, I am not sure if app launching has been integrated yet.

Not sure if this can be usefull for @a1ex4 but there is an amazing plugin for Jeedom on github: https://github.com/Jeedom-Plugins-Extra/plugin-AndroidRemoteControl

This plugin also uses ADB Server and got a lot of nice features that would be awesome if added to your plugin :slight_smile:

Oh and btw, they’re also french, it seems that we’re the only one using AndroidTV with home automations :smiley:

Hello,
my HA is installed on Raspbian in Docker, I tried:
apk --update-cache --repository http://dl-3.alpinelinux.org/alpine/edge/testing/ add android-tools

but can’t add this package, I got:

BlockquoteERROR: unsatisfiable constraints:
android-tools (missing):
required by: world[android-tools]

At the very moment there is no android-tools package in the Alpine for armhf architecture (i.e. Raspberry Pi 3). The available packages are for x86 systems: https://pkgs.alpinelinux.org/packages?name=android-tools&branch=edge&repo=testing

Until the armhf android-tools package is available (again?) you may use a ready Docker image for armhf with adb installed. This one might work: https://hub.docker.com/r/sorccu/adb

For the Hassio users in here:

Topic: https://community.home-assistant.io/t/community-hass-io-add-on-adb-android-debug-bridge/96375

2 Likes

Anything special to think of if I want to switch to the Frenck addon instead of @noedelvreter addon? Will everything blow up. Anyone switched?

@frenck Thanks for the add-on, working great

@M203 Nope, just uninstall mine and then install frenck’s version. And then accept the dialog on all your devices.

How do I find out what the apps I use are called to write it in the config ?

I’m running this on a Shield TV and have the following issues:

  • Once I launch an app the status switches to playing even if i’m not playing any media within that app.
  • The lag time between opening an app and that change propogating back to HAss can be quite significant.

My use case is to dim lights when I start playing a show on Netflix but both of these issues are blockers for me doing that at the moment.
Anyone else having these problems?

Great, thanks.

Did you use this https://github.com/hassio-addons/addon-adb/blob/master/custom_components/media_player/androidtv.py or the one previously mentioned in this thread by jefflirion?

So, I switched all of it. Works but I feel that there is more of a lag than before. All in all, works just fine!

Hello, my dear. How to add button for launch app?

Hi,
could someone please tell me how I use the below as a script, as I would like to create a button that triggers an app or youtube video ect on my shield.

I’m currently on hassio and plan to install the newly created add-on

1 Like

I managed to get it working, using hass.io + shield combination! So far so good, just 2 questions:

  • there is a 5 second delay between state changes. Will this be better if I use docker or hassbian?
  • I have set up light automations based on the ‘playing’, ‘paused’ or ‘idle’ state. However, I want to excluse spotify from the automations. Is there anyway I can let it ignore Spotify? I don’t need the lights to dim when I play some music :sweat_smile:

@StimpyMGS can you share your automotion for light dimming based on media status?

scene:
  - name: playing
    entities:
      light.dining_1:
        state: off
        transition: 2
      light.dining_2: 
        state: off
        transition: 2
      light.dining_3:
        state: off
        transition: 2
      light.living_1:
        state: on
        transition: 2
        brightness_pct: 3
      light.living_2: 
        state: on
        transition: 2
        brightness_pct: 3     
      light.living_3:
        state: on
        transition: 2
        brightness_pct: 3 
      light.living_penguin:
        state: on
        transition: 2
        brightness_pct: 3
      light.hallway_main:
        state: off
        transition: 3        
  - name: paused
    entities:
      light.living_1:
        state: on
        transition: 2
        brightness_pct: 35
      light.living_2: 
        state: on
        transition: 2
        brightness_pct: 35     
      light.living_3:
        state: on
        transition: 2
        brightness_pct: 35 
      light.living_penguin:
        state: on
        transition: 2
        brightness_pct: 60
      light.dining_1:
        state: on
        transition: 2
        brightness_pct: 35         
      light.dining_2: 
        state: on    
        transition: 2
        brightness_pct: 35         
      light.dining_3:
        state: on  
        transition: 2
        brightness_pct: 35        

And the automation:

  - alias: "Media player paused/stopped"
    initial_state: true
    trigger:
      - platform: state
        entity_id:  media_player.shieldtv
        from: 'playing'
        to: 'paused'
      - platform: state
        entity_id:  media_player.shieldtv
        from: 'playing'
        to: 'idle'       
      - platform: state
        entity_id:  media_player.shieldtv
        from: 'playing'
        to: 'off'        
    condition:  
       condition: and
       conditions:
         - condition: template
           value_template: "{{ states.sun.sun.attributes.elevation  | int < 3 }}"
    action:
        service: scene.turn_on
        entity_id: scene.paused

  - alias: "Media player playing"
    initial_state: true  
    trigger:
      - platform: state
        entity_id:  media_player.shieldtv
        from: 'paused'        
        to: 'playing'
      - platform: state
        entity_id:  media_player.shieldtv
        from: 'idle'        
        to: 'playing' 
      - platform: state
        entity_id:  media_player.shieldtv
        from: 'off'        
        to: 'playing'        
    condition:  
       condition: and
       conditions:
         - condition: template
           value_template: "{{ states.sun.sun.attributes.elevation  | int < 3 }}"
    action:
        service: scene.turn_on
        entity_id: scene.playing

Hi @phairplay, I’ve been working on something similar to what you requested. Here’s a screen shot of my Picture Elements Card: -

I drew the image in Powerpoint and then I’ve placed some invisible buttons over the images, so they behave like buttons. I’ve followed the documentation from adb addon and then the code for one of the buttons looks like this: -

  - entity: input_boolean.androidtv
    image: /local/RemoteButtonClear.png
    style:
      height: 22%
      left: 17%
      top: 15%
      width: 10%
    tap_action:
      action: call-service
      service: media_player.androidtv_key
      service_data:
        entity_id: media_player.android_tv
        key: KEYCODE_DPAD_UP
    type: image

I found this: -


from @mcfrojd really helpful. Most of the Key commands work but I had to find out the specific intents from my device to get it working.

Hope it helps

3 Likes

This is so cool! Do you have your config on github or are you willing to share the lovelace yaml code used to make this?

Hi bobokun,
There’s really not much going on with code. Each button is basically the same. I’ve drawn the entire picture in Powerpoint and then saved it as a png. I’ve found Powerpoint to be useful because of all the built in icons and the alignment tools are very useful. I created a coloured button (RemoteButton.png), which is just a square shape that I saved as its own png file, and then positioned that over each of the icons. When I was happy with the placement I swapped the coloured button for an invisible one (RemoteButtonClear.png). When I say invisible, I just changed the shape in Powerpoint, so it had no outline or fill, then saved that as a png file. All these images are in the www folder in config. The DPAD cursor type buttons use the code I shared above and the intent buttons (for apps etc) use this code: -

      - entity: input_boolean.androidtv
        image: /local/RemoteButtonClear.png
        style:
          height: 22%
          left: 41%
          top: 34%
          width: 10%
        tap_action:
          action: call-service
          service: media_player.androidtv_intent
          service_data:
            entity_id: media_player.android_tv
            intent: '-n org.xbmc.kodi/.Splash'

The difference is the type of service that is called and ‘key’ is replaced with ‘intent’. You need to follow all the steps of adding the adb addon: -


You also have to add the androidtv.py file to the relevant location and create the media_player entity.

The input_boolean entity is a dummy that allows you to have an element on this card. Everything is actually controlled from the service calls.

Hope that helps.