braviaproapi.bravia.Http

class braviaproapi.bravia.Http(host, psk)

Bases: object

Handles HTTP messaging to the API server.

Parameters:
  • host (str) – The HTTP hostname at which the server is running.
  • psk (str) – The pre-shared key configured on the server.
remote_request(remote_code)

Sends an HTTP request to the Sony API to execute an IRCC remote code.

Parameters:remote_code (str) – The base64-encoded IRCC code to send (see ButtonCode for examples).
Raises:HttpError – The HTTP call failed.
request(endpoint, method, params=None, version='1.0')

Sends a JSON-RPC request to the API server.

Parameters:
  • endpoint (str) – The API endpoint to send to.
  • method (str) – The RPC method to execute.
  • params (dict, optional) – Defaults to None. Parameters to send on the request.
  • version (str, optional) – Defaults to “1.0”. The version of the API endpoint to request.
Raises:

HttpError – The HTTP call failed. Refer to the error_code attribute for details.

Returns:

The Sony API returns a list of results. If only one result is returned (the majority of the time), this method extracts it and returns it alone. If more than one result is returned, this method returns the full list. If no results were found, this method returns None.

Return type:

list or None