Nividia Shield TV - integration options?

Hi, I’m a new user to Home Assistant.
What options do I have to control an Android TV device namely the Nvidia Shield TV.
the sorts of functionality I’m looking for is basic power control and some feedback response as to the power/standby state and preferably what the primary foreground window app is doing (to determine if the box is gamestreaming/in Kodi/live channels etc.

I don’t want to go down the Pulse8 CEC/IP to IR bridge etc just to control this thing so wonder what the alternatives are without rooting the ShieldTV.


1 Like

Using a nVidia Shield TV too, the only solution I found yet is using two different components: Google Cast and Kodi. That’s incomplete, though: no power control, and no generic application detection. But I’m pretty sure those information are not exposed by the Shield TV itself…

I would be interested as well with how to integrate Android TV.

I’m currently using a super hacky way. I’m using a Nexus TV so should be possible with the Shield too.

My HASS runs on a Rapi which is connected with a usb cable to the Nexus TV. I then compiled a ADB binary file for the Rapi. I can then execute adb commands on the rapi with command line switches/binary_sensors/sensors:

For example playback and wake up (just emulating keypresses):

- platform: command_line
      command_on: "sudo python /usr/bin/ shell input keyevent 85"
      command_off: "sudo python /usr/bin/ shell input keyevent 85"
- platform: command_line
      command_on: 'sudo python /usr/bin/ shell input keyevent 26'
      command_off: 'sudo python /usr/bin/ shell input keyevent 26'

and standby on or off:

- platform: command_line
  command: if [ -z "$(sudo python /usr/bin/ shell dumpsys power | grep Display\ Power:\ state=ON)" ]; then echo off; else echo on; fi
  name: 'Nexus TV Display'
  sensor_class: power
  payload_on: "on"
  payload_off: "off"

or a more complex version:

- platform: command_line
  command: if [ -n "$(sudo python /usr/bin/ shell dumpsys power | grep mWakefulness=Dreaming)" ]; then echo screensaver; elif [ -n "$(sudo python /usr/bin/ shell dumpsys power | grep mWakefulness=Awake)" ]; then echo awake; else echo sleeping; fi

Detecting playback and pause is another story. Netflix for example doesn’t really use the correct API. Plex neither. I havn’t tested Kodi but I guess they’re not calling it either. Youtube does (as expected).

Here is my current version:

- platform: command_line
  command: if [ "$(sudo python /usr/bin/ shell dumpsys power | grep Wake\ Locks:\ size | sed s/Wake\ Locks:\ size=//)" -gt "2" ]; then echo play; else echo pause; fi
  name: 'Nexus TV Playback'
  payload_on: "play"
  payload_off: "pause"

As ugly as it is: it works quite well even without routing. You just need to enable ADB Debugging.

1 Like

Wow, that’s beautiful. I’ll definitely have to try that - with adb via TCP, for more challenge! :slight_smile:

@Mark_Boss So Netflix doesn’t work but what about hulu, live channels etc Have you tested. Kodi and Plex even if it is not working you can always use the ha components.

@kernald Did you tried that? Any luck to get that working with TCP? It would be great if you can write a step by step guide for that.

I didn’t had time yet. I’ll update here when I do, probably this week-end.

@kernald Nice, let me know if I can help somehow. I can test on my Nvidia Shield too :slight_smile:

@dimmanramone Can’t talk about Hulu as I’m from germany and Hulu isn’t available here. It really depends on if they implemented the correct API. You could however use ps with a grep. Then you would need to create a sensor for every app or expand the if statement. Another way would be to use

adb shell dumpsys window windows | grep -E 'mCurrentFocus|mFocusedApp'

and then wrapping it in if statements like I did above. However I haven’t tested it myself.

@kernald Yeah adb over TCP is possible. However you would need to root your device. ADB over TCP isn’t enabled by default. You can enable it via ADB temporarily. A reboot would reset it. If you want you need to change the build.prop file and set


However be careful not to expose the port.

Well, I don’t really turn off my Shield, only put in sleep mode. It may be enough anyway :slight_smile:

Tried the same some time ago. However it failed because Android tends to reboot itself if some stuff is going wrong. I needed to fix this again and again by hooking up my laptop to my nexus tv, because I was too lazy rooting it (Root means wipe). So I created this franken setup :D. So my advice is either root and permanent adb over TCP enabled or sticking with a usb cable. The ADB over TCP option is nicer but requires root to be useful.

If it doesn’t work reliably (I never saw my Shield TV reboot by itself, but it might be discreet :-p), it would be a reason to dig a Raspberry Pi from a drawer :slight_smile:

@Mark_Boss @kernald Well root just for that doesn’t seem to be something that I will do (too lazy configuring everything again) So maybe I can put in use my rpi zero instead and making the scripts from rpi 3 (HA) to communicate with the rpi zero.

The best solution though would be if Tasker could do everything instead and use the HA REST API.

@Mark_Boss I have to make probably a stupid question but is it your ADB binary and if yes how do I make one? or is it possible to share?

The is a python implementation of ADB by google (Github Python ADB). Currently testing the python implementation. However I previously compiled a adb binary from the AOSP source code for the rapi. Somewhere in this thread there is a fairly recent adb binary. The one in the OP is outdated and won’t work.

1 Like

I used Automagic (paid Android app, but free trial available to be able to start specific apps on the Shield from my Harmony remote. It runs as a background service and allows all kinds of automations that can be triggered, among others, using a HTTP Request. The actions are quite comprehensive, but I’m not sure if you can find out which app is in the foreground and what state it is in. Maybe ask on their forums.


@janw might you be able to go into more detail… Automagic looks like Tasker, but I’m not 100% sure either. I’m wanting to do similar things as you described, e.g., tell alexa to start/play/turn-on Vudu, which would be a harmony hub/remote activity that is able to, at the very least, launch the Vudu app on my nVidia SHIELD TV.

Would you mind going into a little more setup detail on configuring your Shield + Harmony Remote activities to achieve that achieve that?

Thanks much!

I never integrated it into my home assistant setup, but a nice information: ADB over TCP doesn’t disable itself anymore after a reboot on the Shield TV.

One thing ive noticed with the Nvidia Shield is that you can enable network debugging in the developer settings. Once you enable usb debugging then you can access network debugging and it assigns your address for you (“localaddress”:5555) I made sure that my 5555 port wasn’t exposed to the outside world so im not too worried about having it on.

I did learn that ADB doesnt seem to like multiple sessions for some reason (or im doing something wrong) I use ADB locally on the shield and it works but then ill start using it on my HASS VM and I can confirm its connected but it constantly says device is offline. I can kill the ADB session and restart successfully but until I retoggle the “network USB” setting

I have a little experience with adb but mostly just for rooting and installing apps. It seems you can do a lot in regarding to activating things. Im going to create a QUICK how to after this post of what I have set up so far.

quick tutorial for how Im dealing the shield. Thanks for all the ideas guys