Skip to main content

Python async library for remote control of Sony Bravia TVs 2013 and newer.

Project description

pybravia

PyPi release GitHub Workflow Status MIT License Code style

Python Bravia provides an easy-to-use async interface for controlling of Sony Bravia TVs 2013 and newer.

This library primarily being developed with the intent of supporting Home Assistant.

For more information, take a look at BRAVIA Professional Display Knowledge Center.

Requirements

This library supports Python 3.8 and higher.

Installation

pip install pybravia

Connect and API usage

With PSK (recommended)

import asyncio
import logging

from pybravia import BraviaClient, BraviaError

HOST = "192.168.1.20"
PSK = "sony"

logging.basicConfig(level=logging.DEBUG)


async def main():
    """Example of connect with PSK."""
    async with BraviaClient(HOST) as client:
        try:
            connected = await client.connect(psk=PSK)
            info = await client.get_system_info()

            print(info)

            await client.volume_up()
        except BraviaError:
            print("Could not connect")


loop = asyncio.new_event_loop()
loop.run_until_complete(main())
loop.close()

With PIN code

Start pairing process and display PIN on the TV

import asyncio
import logging

from pybravia import BraviaClient, BraviaError

HOST = "192.168.1.20"
CLIENTID = "MyClientID"
NICKNAME = "MyNicknameID"

logging.basicConfig(level=logging.DEBUG)


async def main():
    """Pairing process initialization example."""
    async with BraviaClient(HOST) as client:
        try:
            await client.pair(CLIENTID, NICKNAME)
        except BraviaError:
            print("Could not connect")


loop = asyncio.new_event_loop()
loop.run_until_complete(main())
loop.close()

Connect and usage

import asyncio
import logging

from pybravia import BraviaClient, BraviaError

HOST = "192.168.1.20"
CLIENTID = "MyClientID"
NICKNAME = "MyNicknameID"
PIN = "2170"

logging.basicConfig(level=logging.DEBUG)


async def main():
    """Example of connect with PIN."""
    async with BraviaClient(HOST) as client:
        try:
            connected = await client.connect(pin=PIN, clientid=CLIENTID, nickname=NICKNAME)
            info = await client.get_system_info()

            print(info)

            await client.volume_up()
        except BraviaError:
            print("Could not connect")


loop = asyncio.new_event_loop()
loop.run_until_complete(main())
loop.close()

Contributing

See an issue? Have something to add? Issues and pull requests are accepted in this repository.

License

This project is released under the MIT License. Refer to the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pybravia-0.3.4.tar.gz (9.1 kB view details)

Uploaded Source

Built Distribution

pybravia-0.3.4-py3-none-any.whl (9.8 kB view details)

Uploaded Python 3

File details

Details for the file pybravia-0.3.4.tar.gz.

File metadata

  • Download URL: pybravia-0.3.4.tar.gz
  • Upload date:
  • Size: 9.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.19

File hashes

Hashes for pybravia-0.3.4.tar.gz
Algorithm Hash digest
SHA256 7bd4ede038d85c44cc0c74eb80353d18c34f29dc0bbcd1a3ea4a362996db708d
MD5 380c9b00b396a9f515369f0b641885d1
BLAKE2b-256 772a249ef769c02d62b9185da3f8f426a44a2745c6969411a6e973ba3fe94a3c

See more details on using hashes here.

File details

Details for the file pybravia-0.3.4-py3-none-any.whl.

File metadata

  • Download URL: pybravia-0.3.4-py3-none-any.whl
  • Upload date:
  • Size: 9.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.19

File hashes

Hashes for pybravia-0.3.4-py3-none-any.whl
Algorithm Hash digest
SHA256 4ef5ef6c9eabe2dc857c2dd19f7e249896550c3d1ac35a905d49c49e89846940
MD5 c824355bc380cb0f8d596011806f7cce
BLAKE2b-256 10b2f66bdb4a060a37f0173731ac4b00acf251a92b742b6b81672fb87d6d9525

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page