Skip to content

Python class for controlling an Nvidia Shield over a network

Notifications You must be signed in to change notification settings

stefan-sherwood/nvidia_shield_remote

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 

Repository files navigation

nvidia_shield_remote

Python class for controlling and querying Nvidia Shield over a network

Prerequisites

Python 3.6 or higher with python-adb installed
    Install Python

    Download and install Python from here

    Install python-adb
    pip install adb

Android Debug Bridge (adb) installed on your computer
    Download the install for ADB here.
Nvidia Shield in Developer Mode with Network Debugging turned on
    Turn on developer mode
    Settings → About → Build (click Build 7 times - "You are now a developer" message will pop up)

    Turn on Network debugging
    Settings → Developer Options → Network debugging

The DNS name (recommended) or IP address and the debug port of your Nvidia Shield
    Get the DNS name
    The DNS name is usually just the Device name of your Shield. Unless you have changed it, it is SHIELD.
    The device name is found at Settings → About → Device name

    Get the IP address and debug port
    Settings → Developer Options → Network debugging
    When you select this option the IP address and port will be shown
Public and private adb keys
    adb connect SHIELD:5555 # use the DNS name (or IP address) and Port from the previous step

    A message will pop up on your Shield asking you to confirm the connection.
    Files adbkey and adbkey.pub will be added to the .android directory of your home folder

        Linux/Mac: ~/.android
        Windows: /users/<username>/.android

    Copy these two files to the directory containing nvidia.py

Sample code

import nvidia
device = nvidia.shield( 'SHIELD:5555' ) # device name (or IP address) and port

if device.get_power() == 'Asleep':
	device.press( 'power' ) # wake the Shield
device.press( 'home' ) # press the home button
device.launch( 'hbo' ) # launch HBO Now app
	
device.get_current_app()
#	 -------> ('com.zynga.boggle', 'com.zynga.scramble.ui.game.ScrambleGameActivity', None)
device.add_app( 'boggle', 'com.zynga.boggle' )
device.launch( 'boggle' )
device.get_current_app()
#	 -------> ('com.zynga.boggle', 'com.zynga.scramble.ui.game.ScrambleGameActivity', 'boggle')

Usage

nvidia.shield has the following methods:

Press a remote control button

press( button )

    button is one of: power, sleep, wake, home, back, search, up, down, left, right, center, volume up, volume down, rewind, ff, play/pause, previous, next

Launch an app (or switch to it if it's already running)

launch( app )

    app is one of: hbo, prime, music, youtube, ted, games, hulu, netflix, youtubetv, disney, twitch, plex, kodi, cbs, pbs, amazonmusic, spotify, pandora or any app added with add_app()

Get the current power state of the device

get_power()

    Returns the current power state, usually Awake or Asleep

Get the currently running app

get_current_app()

    Returns a tuple containing the package name, activity, and app pretty name of the current app

    Note: If the app is not a known app the app pretty name will be None. See launch() for a list of known apps.

Get installed app package names

get_packages()

    Returns a list of the package names of all installed apps

Add app to launchable apps

add_app( app, package )

    app is a string to be used in subsequent calls to launch
    package is the package name of the app, e.g. com.hbo.hbonow

    Note: You can get the current app's package name with get_current_app() or a list of package names with get_packages()

Type text (simulate a keyboard)

type( text )

    Type text into the current app or text field.

    Note: This presently only works in the top-level search, not in any apps, so it is of very limited use.


Questions, feedback, bug reports, and feature requests are all welcome.

About

Python class for controlling an Nvidia Shield over a network

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published