braviaproapi.bravia.Audio

class braviaproapi.bravia.Audio(bravia_client, http_client)

Bases: object

Provides functionality for controlling audio on the target device.

Parameters:
  • bravia_client – The parent BraviaClient instance.
  • http_client – The Http instance associated with the parent client.
decrease_volume(decrease_by=1, show_ui=True, device=None)

Decreases volume level of the specified audio output device on the target device.

Parameters:
  • decrease_by (int, optional) – Defaults to 1. How many units to decrease the volume on the target device.
  • show_ui (bool, optional) – Defaults to True. Whether to display the volume UI on the target device when changing volume.
  • device (VolumeDevice, optional) – Defaults to None. Specifies which audio device to change the volume of. If not specified, affects all audio devices. May not be VolumeDevice.UNKNOWN.
Raises:
  • TypeError – One or more arguments is the incorrect type.
  • ValueError – One or more arguments is invalid.
  • ApiError – The request to the target device failed.
  • VolumeOutOfRangeError – The specified volume is out of range for the target device.
  • TargetNotSupportedError – The specified audio device is not supported by the target device.
  • InternalError – An internal error occurred.
get_output_device()

Returns the current audio output device on the target device.

Raises:ApiError – The request to the target device failed.
Returns:The current output device.
Return type:AudioOutput
get_speaker_settings()

Returns the current audio settings for the target device.

Raises:ApiError – The request to the target device failed.
Returns:A dict with the following SpeakerSetting keys. Each key’s value may be None if the target device does not provide that setting.
  • SpeakerSetting.TV_POSITION (TvPosition): The physical location of the device.
  • SpeakerSetting.SUBWOOFER_LEVEL (int): The configured volume of the subwoofer.
  • SpeakerSetting.SUBWOOFER_PHASE (SubwooferPhase): The phase setting of the subwoofer.
  • SpeakerSetting.SUBWOOFER_FREQUENCY (int): The confiugred frequency at which the subwoofer activates.
  • SpeakerSetting.SUBWOOFER_POWER (bool): whether the subwoofer is powered on or not.
Return type:dict
get_volume_information()

Returns the current volume information of each audio output device on the target device.

Raises:ApiError – The request to the target device failed.
Returns:A list of dicts containing the following properties:
  • min_volume (int): The minimum volume setting for the audio device.
  • max_volume (int): The maximum volume setting for the audio device.
  • muted (bool): whether the audio device is muted.
  • type (VolumeDevice): The audio device represented by this entry.
  • volume (int): The current volume of the audio device.
Return type:list(dict)
increase_volume(increase_by=1, show_ui=True, device=None)

Increases volume level of the specified audio output device on the target device.

Parameters:
  • increase_by (int, optional) – Defaults to 1. How many units to increase the volume on the target device.
  • show_ui (bool, optional) – Defaults to True. Whether to display the volume UI on the target device when changing volume.
  • device (VolumeDevice, optional) – Defaults to None. Specifies which audio device to change the volume of. If not specified, affects all audio devices. May not be VolumeDevice.UNKNOWN.
Raises:
  • TypeError – One or more arguments is the incorrect type.
  • ValueError – One or more arguments is invalid.
  • ApiError – The request to the target device failed.
  • VolumeOutOfRangeError – The specified volume is out of range for the target device.
  • TargetNotSupportedError – The specified audio device is not supported by the target device.
  • InternalError – An internal error occurred.
mute()

Mutes the current audio output device on the target device.

Raises:ApiError – The request to the target device failed.
set_mute(mute)

Mutes or unmutes the current audio output device on the target device.

Parameters:

mute (bool) – If True, mutes the device. Otherwise, unmutes the device.

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

Sets which audio output device the target device should use.

Parameters:

output_device (AudioOutput) – The output device to use. May not be AudioOutput.UNKNOWN.

Raises:
  • TypeError – One or more arguments is the incorrect type.
  • ValueError – One or more arguments is invalid.
  • ApiError – The request to the target device failed.
  • InternalError – An internal error occurred.
set_speaker_settings(settings)

Configures the settings relating to speakers on the target device.

Parameters:

settings (dict) –

Must contain one or more of the following SpeakerSetting keys.

  • SpeakerSetting.TV_POSITION (TvPosition): The physical location of the device. May not be TvPosition.UNKNOWN.
  • SpeakerSetting.SUBWOOFER_LEVEL (int): The configured volume of the subwoofer. Generally a value between 0 and 24, but may vary by device.
  • SpeakerSetting.SUBWOOFER_PHASE (SubwooferPhase): The phase setting of the subwoofer. May not be SubwooferPhase.UNKNOWN.
  • SpeakerSetting.SUBWOOFER_FREQUENCY (int): The confiugred frequency at which the subwoofer activates. Generally a value between 0 and 30, but may vary by device.
  • SpeakerSetting.SUBWOOFER_POWER (bool): whether the subwoofer is powered on or not.

Raises:
  • TypeError – One or more members of the dict is the incorrect type.
  • ValueError – One or more members of the dict is invalid.
  • ApiError – The request to the target device failed.
  • InternalError – An internal error occurred.
set_volume_level(volume, show_ui=True, device=None)

Sets the volume level of the specified audio output device on the target device.

Parameters:
  • volume (int) – The volume to set on the target device. Generally this is on a scale from 0 to 100, but this may vary by device.
  • show_ui (bool, optional) – Defaults to True. Whether to display the volume UI on the target device when changing volume.
  • device (VolumeDevice, optional) – Defaults to None. Specifies which audio device to change the volume of. If not specified, affects all audio devices. May not be VolumeDevice.UNKNOWN.
Raises:
  • TypeError – One or more arguments is the incorrect type.
  • ValueError – One or more arguments is invalid.
  • ApiError – The request to the target device failed.
  • VolumeOutOfRangeError – The specified volume is out of range for the target device.
  • TargetNotSupportedError – The specified audio device is not supported by the target device.
  • InternalError – An internal error occurred.
unmute()

Unmutes the current audio output device on the target device.

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

Bases: enum.Enum

Describes the audio output device used by the target device.

UNKNOWN

The audio output was not recognized.

SPEAKER

An external speaker.

SPEAKER_HDMI

An external HDMI-connected speaker.

HDMI

HDMI audio output.

AUDIO_SYSTEM

Internal speakers.

class braviaproapi.bravia.TvPosition

Bases: enum.Enum

Describes the mounting position of the device.

UNKNOWN

The TV position was not recognized.

TABLE_TOP

The TV is standing on a table.

WALL_MOUNT

The TV is mounted on a wall.

class braviaproapi.bravia.SubwooferPhase

Bases: enum.Enum

Describes the phase polarity setting of the wireless subwoofer.

UNKNOWN

The subwoofer phase was not recognized.

NORMAL

The subwoofer is using normal polarity.

REVERSE

The subwoofer is using reverse polarity.

class braviaproapi.bravia.VolumeDevice

Bases: enum.Enum

Describes the output device that the volume level is applied to.

UNKNOWN

The volume device was not recognized.

SPEAKERS

The speaker output.

HEADPHONES

The headphone output.

class braviaproapi.bravia.SpeakerSetting

Bases: enum.Enum

Describes available settings relating to audio.

UNKNOWN

The SpeakerSetting was not recognized.

TV_POSITION

The mounting position of the device.

SUBWOOFER_LEVEL

The volume level of the wireless subwoofer.

SUBWOOFER_FREQUENCY

The frequency setting of the wireless subwoofer.

SUBWOOFER_PHASE

The phase polarity of the wireless subwoofer.

SUBWOOFER_POWER

Whether the wireless subwoofer is powered on or not.