Sony Bravia TV component with Pre-Shared Key

Can you control your tv from the command prompt?

./send_command.sh 192.168.1.66 AAAAAgAAABoAAAB8Aw==

Yes. I can control via ssh. But when putting in shell_command. Do I have to put in with full directory where the send_command.sh is?

I have test send_command.sh via pi user which bravia folder is also in pi account. So I relocated the folder bravia to be in homeassistant folder to use shell_command.

If you can get it to run at the command prompt with the full directory, it should work as a shell command with the same command

/home/homeassistant/.homeassistant/bravia/./send_command.sh 192.168.1.66 AAAAAgAAABoAAAB8Aw==

you can try to change the permission on the file

sudo chown 777 /home/homeassistant/.homeassistant/bravia/send_command.sh

you can try the shell command in the dev.

image

1 Like

Thank you very much for your advice. I will try tonight.

sorry, change permission with below (chown is for ownership)

sudo chmod 777 /home/homeassistant/.homeassistant/bravia/send_command.sh

Thank you very much.

@Sunonline, @RobDYI
I have added a number of commands in the custom compoment which you can use to send to the TV.
See this and this post.

Advantage is that you can use this directly from the component.

That’s great, I already use your custom but didn’t know about this added functionality. When is your custom component going to be integrated into the HA builds?

1 Like

From your latest braviatv_psk.py, is it possible to add Num0, Num4 until Num9. Also App name like iFlix or Spotify.

# Some additional info to show specific for Sony Bravia TV
TV_WAIT = 'TV started, waiting for program info'
TV_APP_OPENED = 'App opened'
TV_NO_INFO = 'No info: TV resumed after pause'
PLAY_MEDIA_OPTIONS = ['Netflix', 'Display', 'Num1', 'Num2', 'Num3']

@gerard33

Thanks for your work. Unfortunately this does not seem to work properly for me with a Bravia model kdl-40w900a (2013 model). The TV has a “Wifi-direct” functionality which provides a SSID and a key for connecting to the TV, I have set such key as the pre-shared key.

Currently, all turn on/off, mute, etc service calls seem to work, but the media player entity state does not update and is stuck to off. I am also getting this error:

No data received from TV. Error message: ‘NoneType’ object is not subscriptable

Do you have any idea why this could be happening? Thanks!

Does your TV have the following option?

[Settings] => [Network] => [Home Network Setup] =>
[IP Control] => [Authentication] => [Normal and Pre-Shared Key]

Otherwise it doesn’t have the PSK and is not supported.

Hi, nice piece of work. I appreciate this, did you thought about KODI option to add as play_media component or Source ?

Hi, very nice work dude. I’m enjoying my Bravia TV more than ever. Thanks a lot!

Also, I know this may come a little late but for those of you who don’t seem to find the IP Control options in you TV, you may need to activate the pro mode for your device. I struggled with this for a while as well.

https://community.sony.co.uk/t5/android-tv/hotel-pro-mode/td-p/2416020

Cheers!

1 Like

Thanks! I don’t have a TV with Android TV, so I indeed didn’t add this. Do you know the Kodi command?
Then I can try to add it.

There is also this PR which makes custom commands possible. Will take a look at that as well.

Hi thanks for response

I will look for such one.

In the meantime if you still digging’ in your bravia plug … It looks that

volume_set

function do not work. even if slider react accordingly

Im using a script to decrease tv audio to 0.0 in order ro initiate sound bar output
the command in script looks as follows,

  • service: media_player.volume_set
    data_template:
    entity_id: media_player.sonytv
    volume_level: 0.0

also I checked the function using curl
curl -X POST -H "x-ha-access: APIPASSWORD" -H "Content-Type: application/json" -d '{"entity_id":"media_player.sonytv","volume_level":"0.2"}' -k https://hostname:port/api/services/media_player/volume_set

returns empty response, no reaction, nothing in log

any ideas ?

The volume_set and volume slider will only work for the built-in speakers.
Are you using the built-in speakers of the TV?

I have a receiver attached and can mute and change volume up and down in steps via the HA buttons, but not set it to a certain level.

Hi, yep Im trying this on built in speakers, to set volume to 0.0 once I initiate external amp.
and again when turning tv off set volume again to ~27 in scale so Iset up 0.3 on vol_set.

&& indeed volume_up/down works from HA and curl command,
so it looks like bad rutine for volume_set

now the question is . is this bug is imported from media_player template or from bravia.py ?

Will have a look at it. The volume slider is working for you?
And is a mute/unmute not working for your case?

no, definitely no slider do not work
so. to sum up .
when I execute ( I assume this is comparable to slider)

curl -X POST -H "x-ha-access: API_PASS” -H “Content-Type: application/json” -d ‘{“entity_id”:“media_player.sonytv”,“volume_level”:“0.4”}’ -k https://hostnam:port/api/services/media_player/volume_set

in return I see

curl: (3) Port number ended with ’ ’

and nothing happens

when I execute

curl -X POST -H “x-ha-access: API_PASS” -H “Content-Type: application/json” -d ‘{“entity_id”:“media_player.sonytv”}’ -k https://host:port/api/services/media_player/volume_down
in return I see

curl: (3) Port number ended with ’ ’
[{“attributes”: {“friendly_name”: “sonytv”, “is_volume_muted”: false, “media_content_id”: “HDMI 1”, “media_title”: “HDMI 1”, “source”: “extInput:hdmi”, “source_list”: [“HDMI 1”, “HDMI 2/MHL”, “HDMI 3”, “HDMI 4/ARC”], “supported_features”: 19901, “volume_level”: 0.22}, “entity_id”: “media_player.sonytv”, “last_changed”: “2018-07-24T21:05:20.644383+00:00”, “last_updated”: “2018-07-24T21:09:55.786140+00:00”, “state”: “on”}]

and volume goes down

mute/unmute works fien