Sony Bravia TV component with Pre-Shared Key

I tried your code with my tv Sony: kdl_50w800c (model 2015 with android tv) and I follow your tutorial for install and setup on my tv.
But I only get the entity of my tv show on my Hass. I cannot control any function on my tv. I’m running hassbian. Can you help me?
here is configuration code:

media_player:
  - platform: braviatv_psk
    name: myBraviaTV
    host: 192.168.1.98
    psk: xxxx
    mac: xxxxx
    amp: True
    android: True
    sourcefilter:
      - ' HD'
      - HDMI

and here is my Lovelace code:

- type: media-control
        entity: media_player.mybraviatv_2

can you help?

what needs to be done to get this to work in .88?

I have it fixed on my dev system. Indeed some changes in 0.88 which means the component needs to be updated.
Will release a new version this evening.

1 Like

This is very interesting for me. Few questions before trying this.

Does this work on hass.io?
Is it possible to make scripts to change;

  • inputs
  • channels
  • volume

So i can make ifttt webhooks with google assistant to change things on the tv. This would be awsome.

I can answer all your questions with yes. So just give it a try :grinning:
Please check the posts above for any details on the scripts.

Just a general thing. Components like this work on hassio as that is just Home Assistant combined with some tools. Please read here for more info an hassio vs Home Assistant. Only add-ons are specially developed for hassio and don’t work on other HA installation methods.

Version 0.2.5 is available. That works with HA 0.88, but is also backwards compatible (at least it should be :wink:).

1 Like

Awsome and thanks for the info

can you give me an example of a script of a channel, for example channel 1?

There are 2 options.

script:
  tv_channel_1:
    sequence:
      - service: media_player.play_media
        data:
          entity_id: media_player.sony_bravia_tv
          media_content_type: tvshow
          media_content_id: Num1

Where media_content_id is one of the items below.

PLAY_MEDIA_OPTIONS = [
    'Num1', 'Num2', 'Num3', 'Num4', 'Num5', 'Num6', 'Num7', 'Num8', 'Num9',
    'Num0', 'Num11', 'Num12', 'Netflix', 'Red', 'Green', 'Yellow', 'Blue',
    'ChannelUp', 'ChannelDown', 'Up', 'Down', 'Left', 'Right', 'Display', 'Tv',
    'Confirm', 'Home', 'EPG', 'Return', 'Options', 'Exit', 'Teletext', 'Input',
    'TvPause', 'Play', 'Pause', 'Stop'
]

Second option

script:
  tv_channel_name_1:
    sequence:
      - service: media_player.select_source
        data:
          entity_id: media_player.sony_bravia_tv
          source: "NPO 1 HD"

Here is source the name of your channel which can be found in the attributes of the media player entity.

Check this post as well.
I guess there is enough info to be found in this topic :sunglasses:

The component works great but i get this when i load it.

Integrations need to be in their own folder. Change media_player/braviatv_psk.py to braviatv_psk/media_player.py. This will stop working soon.

14:24 loader.py (WARNING) - message first occured at 14:23 and shows up 4 times

1 Like

Hey @sbobergje, just do what HA has suggested you - rename the folder and also the file…At least that’s what I’ve done and it works fine.

I did exactly that and I’m still getting:

Configuration invalid
Platform not found: media_player.braviatv_psk
Platform not found: media_player.braviatv_psk

configuration

  - platform: braviatv_psk
    name: Living Room TV
    host: ip goes here
    psk: psk goes here
    mac: mac goes here
    amp: True
    android: True

Folders and file names
custom_components --> braviatv_psk --> media_player.py

1 Like

I can not … I would like to make a script for each program … my are these: source_list: Canale5 HD, Rai 1 HD, Rete4 HD, Rai 2 HD, Italia1 HD, TELELOMBARDIA HD, Rai 3 HD

Thank you @ptdalen ! Using your explanation of path and filename solved my issues!

I’m setup exactly as you describe but it still returns the error I posted above.

Which HA version are you using? If HA 0.85 or older you have to use media_player/braviatv_psk.py. As of 0.86 you can use braviatv_psk/media_player.py.

1 Like

Did you try to use the second option from my post? Because that seems to be the exact example you would like to use.

Dear Gerard33, thank you very much for your work.

I use your custom component for a Sony smartTv (no-android) and everything works perfect.
When I try to set-up my second Sony Tv (android) the component is loaded, everything is shown in my lovelace but the commands doesn’t works and, for example, i can not turn on the tv.

Is there any misconfiguration ??
this is my configuration.yaml

  • platform: braviatv_psk
    name: SonySalotto
    host: 192.168.1.68
    psk: sony <- (this is the same of other Tv is it right ?
    mac: 10:4F:A8:D6:6F:73
    amp: False
    android: True

Try downloading the updated version (in addition to making the folder/file name changes):

https://github.com/gerard33/home-assistant