Support for Bravia Smart TV (2013+)

You can put in the ~/.homeassistant/custom_components/bravia.py

So, i added autodiscovery but in order to use it you need to modify quite a few places :-/
I am too lazy to add PSK tonight plus i don’t need it. Plus i asume there is only one device.
Plus you need netdisco==0.6.5 (unless you also want to edit that).

Anyone adventurous enough?

Code and steps in description are up at https://github.com/dominiquevocat/ha-bravia/commits/master/bravia.py

Auto discovery would be great, I have two devices though.

What changes would i need to do for the v0.3 to get it to work?

@kophinos i only have a tv so i probably cannot help much.
I do have a ps4 but there seems to be no uPNP there.

If you want you could get me the output of
python -m netdisco dump

um its in the description of the version 0.3

for your convenience:

Update bravia.py
Supports discovery. Needs modifications in several places :frowning:
in /homeassistant/components/media_player/init.py: line 38 add a coma and
discovery.SERVICE_BRAVIA: 'bravia'
in /homeassistant/components/discovery.py: in line 40 add a coma and
SERVICE_BRAVIA: 'media_player'

create a file with content: /netdisco/discoverables/bravia.py
“”" Discovers Bravia TV devices. “”"

from netdisco.util import urlparse
from . import SSDPDiscoverable


# pylint: disable=too-few-public-methods
class Discoverable(SSDPDiscoverable):
    """ Adds support for discovering Bravia TV devices. """

    def info_from_entry(self, entry):
        """ Returns the most important info from a uPnP entry. """
        device = entry.description['device']
        hostname = urlparse(entry.values['location']).hostname
        mac = str(device['UDN'].split('-')[4])
        #print("we found a device with info: " + device['friendlyName'] + " " + hostname + " " + mac)
        return (device['friendlyName'], hostname, mac)

    def get_entries(self):
        """ Get all the Bravia TV device uPnP entries. """
        return self.find_by_device_description({
            "manufacturer": "Sony Corporation",
            "deviceType": "urn:schemas-upnp-org:device:MediaRenderer:1"
        })

I think this was missing

Also in /netdisco/const.py add

BRAVIA = ‘bravia’

New Version 0.4 - ready for v.18 includes source list though for channel selection:

reads a file channel_list.txt in the config folder with the content being a simple list like this:
1 abc
2 def

select the channel from the source and it will dial the number in the beginning of the line.

The top few lines of mine look like this:
1 SRF 1 HD
2 SRF zwei HD
3 SRF info HD
4 3+ HD
5 TV24 HD
6 S1 HD
7 Star TV HD
8 Tele Züri HD
9 Vorschau HD
10 Das Erste HD
11 ZDF HD
12 ORF eins HD
13 ORF 2 HD
14 RTL HD1*
15 Sat.1 HD2*
16 ProSieben HD2*
17 RTL 2 HD1*
18 4+ HD

Can we get some clearer instructions on how to set this up?

  1. I put the bravia.py in the custom_components folder located in the /homeassistant root directory.
  2. I modified /netdisco/const.py.
  3. I have no /homeassistant/components/media_player/init.py, I am running the 18.2 production version, not dev, is that a problem? I assume by components, you mean /deps, but there is no media_player directory in there either.
  4. I also don’t have a discovery.py in my /deps directory either.
  5. If i call the platform: brava to the configuration.yaml, the hass log returns the error: unable to locate component bravia.

I would love to get this thing working, as I have two Bravia TVs, and this looks like it would be really awesome.

Hi @kophinos
all file placements are not under the config directory but the folder where you have the distribution installed. So where you have your python3 under Lib/site-packages (depending what OS etc).
Also be aware that i do not have more then one Bravia so i don’t know how it behaves and i would like to see the output of python -m netdisco dump after making all the modifications in your /homeassistant/ not /.homeassistant/ !

I’m unable to get this working on 19.4 when following your directions to the best of my ability. I get the following:

May 16 15:22:14 hass[3420]: File “/srv/hass/lib/python3.4/site-packages/homeassistant/components/scene/init.py”, line 17, in
May 16 15:22:14 hass[3420]: from homeassistant.helpers.entity_component import EntityComponent
May 16 15:22:14 hass[3420]: File “/srv/hass/lib/python3.4/site-packages/homeassistant/helpers/entity_component.py”, line 5, in
May 16 15:22:14 hass[3420]: from homeassistant.components import discovery, group
May 16 15:22:14 hass[3420]: File “/srv/hass/lib/python3.4/site-packages/homeassistant/components/discovery.py”, line 40, in
May 16 15:22:14 hass[3420]: SERVICE_BRAVIA: ‘media_player’,
May 16 15:22:14 hass[3420]: NameError: name ‘SERVICE_BRAVIA’ is not defined
May 16 15:22:15 systemd[1]: [email protected]: main process exited, code=exited, status=1/FAILURE
May 16 15:22:15 systemd[1]: Unit [email protected] entered failed state.

Um, that sucks. I have a little time and i added the stuff to use settings in the .conf so i can pass it to you if want to try it out. I do need to find out how to proceed with some of the stuff before i can reasonably try to have it included in the hass :frowning: bit i am slowly getting there. Stuff like pin code enrolement and reading tv channels from the tv’s api and so on… hopefuly i have some time… you on gitter sometime i can be arround? My timezone is gmt+2

Version 0.5 work in progress…
getting the channels from the tv sucks so for now, file…
reading the currently playing channel etc works and i am doing the groundwork for getting the cookie needed so i hope to clean it a bit and maybe finally work towards including it…
(play prev, play next is mapped to channel up/down since i do not use other features right now).
The tv integration stuff is basic so far so not sure if i am working in the wrong direction… :-/

preview :slight_smile:

current channel and whats’ on.

select channel from list (important, channel number in front of the name for it will send the ir codes till the first whitespace).

Do the Bravias have a notification system? My main TV is a Bravia but my secondary is webOS and the notification setup on it is awesome with HA!

If your Bravia has Android TV , then Push-bullet app can be used maybe

Sadly not Android TV. I’ll keep searching for something.

Bravia TVs from year 2015 and later has Android TV, however in my nVidia Shield Android TV (SATV), I tried searching PushBullet and it’s not available. I went to play.google.com and it is available for my SATV, however I cannot get it to install in my Shield TV, as if Google Play does not push apps to nVidia Shield. The same thing could happen to Bravia TV running Android TV. You can install apps within Android TV’s Google Play Store, but installing apps from play.google.com does not get downloaded and installed in your 2015+ Bravia TV.

As this thread is about 2013 model Bravia TVs, I’m going way off-topic here and none of the forums are a fit to discuss my issues with Android TV at hand.

Did you try manually installing the APK? that might work.

Is this the component that is now in use? braviatv.py & braviarc.py?

This component is now flooding the log with trying to connect every 10 secs and if TV is off, it prints a error. If TV is not on, it should not be an error…

You can make a quick fix in /home/pi/.homeassistant/deps/braviarc/braviarc.py, line 71
change line:
_LOGGER.error(json.dumps(response.json(), indent=4))
to
_LOGGER.info(json.dumps(response.json(), indent=4))

Or you can change ‘info’ also to ‘debug’.

nope, sorry.