androidtv.basetv module
Communicate with an Android TV or Amazon Fire TV device via ADB over a network.
ADB Debugging must be enabled.
-
class
androidtv.basetv.BaseTV(host, adbkey='', adb_server_ip='', adb_server_port=5037)[source]
Bases: object
Base class for representing an Android TV / Fire TV device.
-
available
Check whether the ADB connection is intact.
| Returns: | Whether or not the ADB connection is intact |
| Return type: | bool |
-
awake
Check if the device is awake (screensaver is not running).
| Returns: | Whether or not the device is awake (screensaver is not running) |
| Return type: | bool |
-
back()[source]
Send back action.
-
connect(always_log_errors=True)[source]
Connect to an Android TV / Fire TV device.
| Parameters: | always_log_errors (bool) – If True, errors will always be logged; otherwise, errors will only be logged on the first failed reconnect attempt |
| Returns: | Whether or not the connection was successfully established and the device is available |
| Return type: | bool |
-
current_app
Return the current app.
| Returns: | A dictionary with keys 'package' and 'activity' if the current app was found; otherwise, None |
| Return type: | dict |
-
down()[source]
Send down action.
-
enter()[source]
Send enter action.
-
home()[source]
Send home action.
-
key_0()[source]
Send 0 keypress.
-
key_1()[source]
Send 1 keypress.
-
key_2()[source]
Send 2 keypress.
-
key_3()[source]
Send 3 keypress.
-
key_4()[source]
Send 4 keypress.
-
key_5()[source]
Send 5 keypress.
-
key_6()[source]
Send 6 keypress.
-
key_7()[source]
Send 7 keypress.
-
key_8()[source]
Send 8 keypress.
-
key_9()[source]
Send 9 keypress.
-
key_a()[source]
Send a keypress.
-
key_b()[source]
Send b keypress.
-
key_c()[source]
Send c keypress.
-
key_d()[source]
Send d keypress.
-
key_e()[source]
Send e keypress.
-
key_f()[source]
Send f keypress.
-
key_g()[source]
Send g keypress.
-
key_h()[source]
Send h keypress.
-
key_i()[source]
Send i keypress.
-
key_j()[source]
Send j keypress.
-
key_k()[source]
Send k keypress.
-
key_l()[source]
Send l keypress.
-
key_m()[source]
Send m keypress.
-
key_n()[source]
Send n keypress.
-
key_o()[source]
Send o keypress.
-
key_p()[source]
Send p keypress.
-
key_q()[source]
Send q keypress.
-
key_r()[source]
Send r keypress.
-
key_s()[source]
Send s keypress.
-
key_t()[source]
Send t keypress.
-
key_u()[source]
Send u keypress.
-
key_v()[source]
Send v keypress.
-
key_w()[source]
Send w keypress.
-
key_x()[source]
Send x keypress.
-
key_y()[source]
Send y keypress.
-
key_z()[source]
Send z keypress.
-
left()[source]
Send left action.
-
manufacturer
Get the ‘manufacturer’ property from the device.
| Returns: | The manufacturer of the device |
| Return type: | str, None |
-
media_next()[source]
Send media next action (results in fast-forward).
-
media_pause()[source]
Send media pause action.
-
media_play()[source]
Send media play action.
-
media_play_pause()[source]
Send media play/pause action.
-
media_previous()[source]
Send media previous action (results in rewind).
-
media_session_state
Get the state from the output of dumpsys media_session.
| Returns: | The state from the output of the ADB shell command dumpsys media_session, or None if it could not be determined |
| Return type: | int, None |
-
media_stop()[source]
Send media stop action.
-
menu()[source]
Send menu action.
-
mute_volume()[source]
Mute the volume.
-
power()[source]
Send power action.
-
right()[source]
Send right action.
-
screen_on
Check if the screen is on.
| Returns: | Whether or not the device is on |
| Return type: | bool |
-
sleep()[source]
Send sleep action.
-
space()[source]
Send space keypress.
-
up()[source]
Send up action.
-
volume_down()[source]
Send volume down action.
-
volume_up()[source]
Send volume up action.
-
wake_lock
Check for wake locks (device is playing).
| Returns: | Whether or not the wake_lock_size property is equal to 1. |
| Return type: | bool |
-
wake_lock_size
Get the size of the current wake lock.
| Returns: | The size of the current wake lock, or None if it could not be determined |
| Return type: | int, None |