Sony Bravia TV component with Pre-Shared Key

Can you share your config? Looks like you are using it as a sensor as the error says sensor.braviatv_psk not found. The component should be a mediaplayer.

See the working example below.

media_player:
  - platform: braviatv_psk
    host: 192.168.1.191
    psk: sony
    mac: AA:BB:CC:DD:EE:FF
    amp: True
    sourcefilter:
      - ' HD'
      - HDMI

Thanks for taking a look. My code is the same as this, other than the Mac and IP. Not getting the error anymore, but all it can do is turn the TV on and that is only if it is already off. Once it is on, it seems to lose control again if the cable box is on. Is it only for use with HA and not a cable box for example?

media_player:

  • platform: braviatv_psk
    host: 192.168.1.191
    psk: sony
    mac: AA:BB:CC:DD:EE:FF
    amp: True
    sourcefilter:
    • ’ HD’
    • HDMI

Are you sure you use the right IP address and/or psk? You can check these settings in your TV, see the opening post for more explanation.

Because it should work also with the cable box (will show HDMI1 probably).

Yes, MAC, psk and IP are correct. Psk config file is loaded in config folder as directed above

  • File braviatv_psk.py is placed in custom_components/media_player in your config folder?
  • Does your psk have a leading zero? Then place it between quotes.
  • Can you remove the braviatv platform to see if that fixes anything?
  • I gues you have an Android TV? Then add android: True to the config, although that’s only used for starting the TV.

Correct - the path is config/custom_components/media_player
psk is “sony” , no 0’s
what do you mean by remove the braviatv platform? as I mentioned, it was discovered as part of the LAN I assume, as it was in HA before I started digging into it.
I have tried android: True in the config, didn’t make any difference

Can you remove that platform? Not sure if it’s in the config file somewhere.

If not, please PM me your config.yaml file so I can have a closer look, because this should be working :grinning:

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