Sony Bravia TV component with Pre-Shared Key

I deleted the BraviaTV stuff from the config.yaml file - rebooted the server and the Bravia TV app still shows on the dashboard, like it did upon the initial boot up. Where else would it get the config info from?

Hello, I’m using the normal sony bravia tv compontent and I can power on or off the tv. But I can’t do anything else. Is there a possibility to start the netflix app? Thank you in advance !

You can use this Media player - Home Assistant by making a script like this:

script:
  tv_npo1:
    sequence:
      - service: media_player.select_source
        data:
          entity_id: media_player.sony_bravia_tv
          source: 'NPO 1 HD'

That’s not yet possible, but I will have a look at this to see if I can add that option.

2 Likes

@gerard33 thank you very much for making this component. I’ve just installed on 0.63.3 and it works well on the first time.
By the way, after several minutes (with some testing like turn on, turn off, change channet etc.), this component doesn’t work any more. I got the following HA’s log:

No data received from TV. Error message is: time data '' does not match format '%Y-%m-%dT%H:%M:%S'
11:55 PM custom_components/media_player/braviatv_psk.py (ERROR)
No data received from TV. Error message is: time data '' does not match format '%Y-%m-%dT%H:%M:%S'
11:55 PM custom_components/media_player/braviatv_psk.py (ERROR)

Could you please suggest me the solution to fix?

You can try this version.

Then you can use the following script to start Netflix:

script:
  netflix_tv:
    sequence:
      - service: media_player.play_media
        data:
          entity_id: media_player.sony_bravia_tv
          media_content_type: tvshow
          media_content_id: Netflix

Can you also try the version in the link above?
I have changed some logic in the code that get’s the end time of the TV program that is playing as that is probably causing the issue you have seen in the logs.

Let me know if that works.

4 Likes

Bummer… my KDL-32W650A Bravia TV does’t have the psk option. IP Control menu option is missing from Home Network Setup.

Can you also try the version in the link above?
I have changed some logic in the code that get’s the end time of the TV program that is playing as that is probably causing the issue you have seen in the logs.

I’ve just test this version and I’ve not found the previous bug any more. Thank you.

1 Like

Hi, doesn’t work for my hassio for some reason. Added \config\custom_components\media_player\braviatv_psk.py and following config:

media_player:
  - platform: braviatv_psk
    name: sony_bravia_tv
    host: 192.168.1.7
    psk: sony
    mac: 2C:33:7A:66:XX:XX
    amp: True
    android: False
    sourcefilter:
      - ' HD'
      - HDMI 

Got error:

Error while setting up platform braviatv_psk
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/homeassistant/helpers/entity_platform.py", line 84, in async_setup
    SLOW_SETUP_MAX_WAIT, loop=hass.loop)
  File "/usr/lib/python3.6/asyncio/tasks.py", line 358, in wait_for
    return fut.result()
  File "/usr/lib/python3.6/asyncio/futures.py", line 245, in result
    raise self._exception
  File "/usr/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/media_player/braviatv_psk.py", line 70, in setup_platform
    [BraviaTVDevice(host, psk, mac, name, amp, android, source_filter)])
  File "/config/custom_components/media_player/braviatv_psk.py", line 79, in __init__
    from braviapsk import sony_bravia_psk
ModuleNotFoundError: No module named 'braviapsk'

Looks like it can’t download the module from PyPi which is needed for the actual connection with the TV.
I am running the component on hass.io as well so that’s not the issue.
Does your HA have connection to internet? And can you restart HA once more to see if that solves it?

Classic restart once again worked, again. Sorry that I didn’t test that first. Updated to 0.64 and after that boot it worked fine. Thanks.

1 Like

Dear Gérard33, Thank you. I will give it a try! Greetings

This is awesome! Thanks for your hard work on this! Is it possible to get it to pull stations from a HDHomerun? I share a HDHR tuner between several Bravia TVs in my house since support was added in the 7.0 update.

1 Like

Thanks!
The only stations that the API provides are those available in the built-in TV tuner (e.g. DBV-C).
Your HDHomerun will be connected via HDMI? Then that data is not available.

HDHomerun is a network (IP) tuner. Android 7 allows the TV to use the tuner as is if it was a built-in. However, I noticed that the API will not detect channels on my TVs on the build-in tuner either, despite setting - ‘HD’ in the config options.

1 Like

I also have a HDHomerun and would love to be able to pass a channel number. It is working to change the channel up and down if the TV starts on the correct source, but I can’t figure out how to pass a channel number or if I can?
Also, the Source “Channels” is not shown and no channel list is pulled.
The HDHomerun uses “Channels” which is Sony’s flavor of “Android Live Channels”. So if I change the source to “HDMI 1” I can’t get it back to view the HDHomerun.

1 Like

Currently the channels from the following sources are loaded

# tv:dvbc = via cable, tv:dvbt = via DTT, tv:dvbs = via satellite
if result['source'] in ['tv:dvbc', 'tv:dvbt', 'tv:dvbs']:
    original_content_list.extend(self.get_source(result['source']))

and

# physical inputs
if result['source'] in ('extInput:hdmi', 'extInput:composite', 'extInput:component'):
    resp = self.bravia_req_json("sony/avContent", self._jdata_build("getContentList", result))

So if you can discover how the HDHomerun is seen by the TV (maybe tv:ip of extInput:ip?) then I can add that to see if that works.

You can have a look at this post Sony Bravia TV component with Pre-Shared Key - #74 by gerard33.
You can replace Netflix in

media_content_id: Netflix

with Num1, Num2, Num3 (more channels not supported at the moment, but I can extend that).
Can you check if that works?

Should my TV report that it’s playing netflix in HA? When I’m watching Netflix the media player component reports “No info: TV resumed after pause.”

Using media_content_id: Num1 did work, but how do I enter multiple numbers? For example channel 232

Ah, now I see. Only Num1, Num2 and Num3 are setup. Num4 didn’t work.
I also set the media_content_type to channel. So 1 thru 3 did work, but I was only able to get 1 number at a time.