Sony Bravia TV component with Pre-Shared Key

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

Hi all

Thanks for the script !
I’m a newbie on Home Assistant because I just upgraded from Jeedom.

I synchronized Alexa and Google Home with Home Assistant and I can command with voice Somfy Cover etc etc, works fine ! without script, directly by addon.

But with this addons, I can just control by default switch on/off TV on Google Home. unless there are specific commands to tell Google that I do not know?
So I created one script per channel For example: Mets TF1 (to activate TF1, channel number 1), Mets France 2 (to activate France 2, channel number 2).
Is not it possible natively to tell Google to change the channel directly by taking the name of the channels of your addon in “sourcelist”, without having to create a script by channel?

Also, is there a way to put a number to the volume for example with set_volume? Because currently, it is necessary to press several times on “volumeup” or “volumedown” and thus to say several times to Google, Ok google, lower the volume for example. Which is not practical.

Many thanks :slight_smile:

trying to figure out whats wrong

Log Details (ERROR)
Sun Jul 29 2018 00:18:42 GMT-0400 (Eastern Daylight Time)

Error while setting up platform braviatv_psk
Traceback (most recent call last):
File “/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity_platform.py”, line 129, in _async_setup_platform
SLOW_SETUP_MAX_WAIT, loop=hass.loop)
File “/usr/local/lib/python3.6/asyncio/tasks.py”, line 358, in wait_for
return fut.result()
File “/usr/local/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 72, in setup_platform
[BraviaTVDevice(host, psk, mac, name, amp, android, source_filter)])
File “/config/custom_components/media_player/braviatv_psk.py”, line 81, in init
from braviapsk import sony_bravia_psk
ModuleNotFoundError: No module named ‘braviapsk’