Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

## SonyAPI

This is the initial release of a python connector for Sony Bravia generation 3 TV's.

The API is pretty simple. This API will automatically get the MAC address of the TV to create the WOL packet so you will be able to wake it from standby. It also automatically will get the FQDN of the computer running this lib and use that information to create a client id and nickname. This is done so the use of the same pin and hostname cannot be used to access the TV. This adds a little bit of extra security.

***Constructor:***

instance = SonyAPI(ip_address, pin=0000, psk=None, debug=None)

The constructor can be passed a pin number if you want to pair the TV to the API or it can be passed a personal access key which can also be set up on the TV.

If you do not have the TV paired you will need to pass 0000 for the pin number or simply do not specify one. If the TV requires pairing and you have initialized the constructor you will be prompted to enter the pin number and this will time out in 60 seconds and generate a SonyAPI.RegisterError exception.

I used rawinput to allow entry for the pin number and this can be overridden very easily if you are wanting to use a GUI control to allow entry for the pin number.

## Power

A couple of things about how the power works. With the Android based TV's they do have a power on command, and this command is tried first. if it does not suceed it will then check to see if wake on lan is enabled on the TV. If it is not it will enable the wake on lan then use that method to turn the TV on. There is no need to pass a mac address there is a mechanism in place that will acquire the mac address automatically.

***Power:***

* Get

state = instance.power

* Set

instance.power = True\False


## Volume

When changing the volume you will reference the device you want to control the volume for, This is found in the audio output settings of your TV.

***Volume:***
* Get

speaker_volume = int(instance.volume.speaker)
headphone_volume = int(instance.volume.headphone)

* Set

instance.volume.speaker = 50
instance.volume.headphone = 50

***Mute:***
* Get

speaker_mute = instance.volume.speaker.mute
headphone_mute = instance.volume.headphone.mute

* Set

instance.volume.speaker.mute = True/False
instance.volume.headphone.mute = True/False

***Minimum Volume:***

* Get

min_speaker = instance.volume.speaker.min_volume
min_headphone = instance.volume.headphone.min_volume
***Maximum Volume:***

* Get

max_speaker = instance.volume.speaker.max_volume
max_headphone = instance.volume.headphone.max_volume

***Volume Up:***

instance.volume.speaker.up()
instance.volume.headphone.up()


***Volume Down:***

instance.volume.speaker.down()
instance.volume.headphone.down()


I have also set this up to allow for the use of some of the rich comparison and augmented arithmetic operators += -= *= /= > < == >= <= !=

instance.volume.speaker += 1
instance.volume.headphone += 1

instance.volume.speaker -= 1
instance.volume.headphone -= 1
## Channels

Channels work the same way the volume does but without the speaker or headphone. There is also the property lineup which will return a list of ContentItem instances.





Release files for SonyAPI 0.1.1b2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for SonyAPI 0.1.1b2
File Size Uploaded
SonyAPI-0.1.1b2.tar.gz 21.3 kB Details

Release files / SonyAPI-0.1.1b2.tar.gz

Download URL SonyAPI-0.1.1b2.tar.gz
Size 21.3 kB
Tags Source
SHA-256 checksum
How to use checksums
48fc443dafa7983e325d85f786d2cf5f5b169676fd7a0adb9b1425bf8f42240f
BLAKE2b-256 checksum
How to use checksums
ac1562bcd4ca3e31ac6c4ba01f1ac059353ec6dbd7a7eba64af2cbcaf1963cb2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.1.1b2 This release

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page