braviaproapi.bravia.AppControl

class braviaproapi.bravia.AppControl(bravia_client, http_client)

Bases: object

Provides functionality for interacting with applications on the target device.

Parameters:
  • bravia_client – The parent BraviaClient instance.
  • http_client – The Http instance associated with the parent client.
get_application_feature_status()

Determines which features are supported by the currently running application on the target device.

Raises:ApiError – The request to the target device failed.
Returns:A dict with the following keys with boolean values:
  • textInput (bool): True if the application currently has a text input focused.
  • cursorDisplay (bool): True if the application currently has an interactive cursor.
  • webBrowse (bool): True if the application currently has a web browser displayed.
Return type:dict
get_application_list(exclude_builtin=False)

Retrieves a list of applications installed on the target device.

Parameters:

exclude_builtin (bool) – If True, excludes built-in Sony applications which are not exposed on the home screen.

Raises:
  • TypeError – One or more arguments is the incorrect type.
  • ApiError – The request to the target device failed.
Returns:

A list of dicts containing the following properties:

  • name (str or None): The display name of the application.
  • uri (str or None): The internal URI at which the application can be accessed, used when referring to the app from other functions.
  • icon (str or None): A network URL pointing to the application’s icon image.

Return type:

list(dict)

get_text_form()

Decrypts and returns the contents of the text field focused on the target device.

Raises:
  • InternalError – The target device was unable to encrypt the text.
  • ApiError – The request to the target device failed.
  • EncryptionError – The target device could not provide a valid encryption key.
Returns:

The text, or None if no text field is currently focused.

Return type:

str or None

get_web_app_status()

Returns information about the web application currently in use on the target device.

Raises:ApiError – The request to the target device failed.
Returns:A dict containing the following keys:
  • active (bool): True if there is currently a web application running on the target device.
  • url (str or None): The URL of the application currently running, None if no such app is running.
Return type:dict
set_active_app(uri)

Opens the specified app on the target device.

Parameters:

uri (str) – The URI of the application to open (acquired using get_application_list())

Raises:
  • TypeError – One or more arguments is the incorrect type.
  • AppLaunchError – The application could not be opened.
  • ApiError – The request to the target device failed.
set_text_form(text)

Enters the specified text in the focused text field on the target device. Text is encrypted before being sent to the device.

Parameters:

text (str) – The text to input.

Raises:
  • TypeError – One or more arguments is the incorrect type.
  • ApiError – The request to the device failed.
  • EncryptionError – The target device could not provide a valid encryption key.
  • NoFocusedTextFieldError – There is no text field to input text to on the target device.
  • InternalError – The target device failed to decrypt the text.
terminate_all_apps()

Instructs the target device to terminate all running applications.

Raises:ApiError – The request to the target device failed.
class braviaproapi.bravia.AppFeature

Bases: enum.Enum

Describes which features are supported by the current app.

UNKNOWN

The app feature was not recognized.

TEXT_INPUT

The app has a text field focused.

CURSOR_DISPLAY

The app has a cursor displayed.

WEB_BROWSE

The app is using an embedded web browser.