Sony Bravia TV component with Pre-Shared Key

Hi as promised.
passing below cmd to sony/Android Tv you will have a list of commands related to apps instaled on device

> curl -H “Content-Type: application/json” -H “X-Auth-PSK: sony” -X POST -d ‘{“id”: 1, “method”: “getApplicationList”, “version”: “1.0”, “params”: [""]}’ http://host/sony/appControl

_> "title":"YouTube","uri":"com.sony.dtv.com.google.android.youtube.tv.com.google.android.apps.youtube.tv.activity.ShellActivity"
_> "title":"Music","uri":"com.sony.dtv.com.sony.dtv.osat.music.com.sonyericsson.music.MusicActivity"
_> "title":"Netflix","uri":"com.sony.dtv.com.netflix.ninja.com.netflix.ninja.MainActivity"
_> "title":"Kodi","uri":"com.sony.dtv.org.xbmc.kodi.org.xbmc.kodi.Splash"

and others…

What command would one use to open given APP though? Is it possible?

OK, I have found how to do it in another post. Send a POST to request to http://IP/DIAL/apps/[app_id].

curl -H “Content-Type: application/json” -H “X-Auth-PSK: sony” -X POST http://192.168.2.4/DIAL/apps/com.sony.dtv.com.google.android.youtube.tv.com.google.android.apps.youtube.tv.activity.ShellActivity

Also found another way:

curl -H “Content-Type: application/json” -H “X-Auth-PSK: sony” -X POST -d ‘{“id”: 1, “method”: “setActiveApp”, “version”: “1.0”, params: [{“uri”: “com.sony.dtv.com.google.android.youtube.tv.com.google.android.apps.youtube.tv.activity.ShellActivity”}]}’ http://192.168.2.4/sony/appControl

Which seems a bit nicer API.

So my PR is not really useful for that as that one sends commands to /sony/IRCC. Both sony_bravia_ha and sony_bravia_psk packages would probably have to be extended to support that.

1 Like

Yep, fully agree.
Btw did you found any workable solution for volume_set problem. Both Bravia and Bravia-psk plug-ins do dot manage this function correctly

I have looked into that now and found a problem. The code was passing a float volume value while string int is expected. Created PR with a fix.

Hi thanks for that
Im not an expert with building *py packages. Can you share me a corected version of braviatv_psk.py or
guide me how I can rebuild fixed lib from local clone of repo pls. ?

Dzieki z góry:)

Edit , manually updated res files
~/homeassistant/lib/python3.6/site-packages/braviarc/braviarc.py
~/homeassistant/lib/python3.6/site-packages/braviapsk/sony_bravia_psk.py
indeed
a) volume_set works
b) volume app slider reflect changes
Thanks !

now I can focus on shell cmds to run kod/addin/incursion/ and integrate this with google home

Hi

What are you edit in hraviatv_psk.py
?
Thanks

You apply the changes from the pull request.

Thanks.
But in my file braviatv_psk.py from https://github.com/gerard33/home-assistant i don’t find the same line.
If i find similar line, i have line 276 :
def set_volume_level(self, volume):
“”“Set volume level, range 0…1.”""
self._braviarc.set_volume_level(volume)

Can you tell me what to modify on these lines, if it’s good?
thanks in advance

You would have to modify the sony_bravia_psk.py file instead, which is a dependency of braviatv_psk.py.

I’m not sure where you can find it in your installation. For me it’s in /usr/share/hassio/homeassistant/deps/lib/python3.6/site-packages/braviapsk/(I’m running Hassio in docker container).

It would of course be much simpler if @gerard33 would merge the pull request and release new versions :slight_smile:

I checked in SSH i can’t find /usr/share/hassio directory

In Home Assistant log interface i see "
/usr/local/lib/python3.6/xxxxxxxxxxxxxxxxxxxxxxxx" but same in SSH i can’t find the directory:thinking:

I’m running HassIO on RPI3, build from July 2018.

If anyone knows where I can find the directory, I’m interested :slight_smile:

Maybe SSH to RPI and try to find it with:

find / -name sony_bravia_psk.py 2>/dev/null

You should find it somewhere unless the file is in a docker container but if you are running RPI with Hassio as your distro then I think files should not be in a container.

Oh thanks :slight_smile: all works fine !
And I can control now volume of the TVs by Google Home :slight_smile:

For information :
/config/deps/lib/python3.6/site-packages/sony_bravia_psk/sony_bravia_psk.py
/config/deps/lib/python3.6/site-packages/braviapsk/sony_bravia_psk.py

Ok so volume_set works for 2 Sony Android TV without sound bar
But on my main TV with sound bar connect in HDMI Arc, volume_set not changing the sound level.
But Volume_up and volume_down works

does anyone know how to make volume_set work with the soundbar? Or there isn’t really solution. thank you

volume_set works only for builtin speakers.
play a bit around using SPDIF ( digital I/O) then it is easy

Did this component break with the .75 release?

@rchl thanks for your PRs. Will have a look at those asap and will release new versions after merging.

Hi thanks :slight_smile:

But when I look at your script, your soundbar is managed directly in Home Assistant?

Because me my bar Samsung K450 is not wifi. Only HDMI ARC, Optical and Bluetooth. So I can not control it I think by TV and not by Home Assistant. So in this case, unless I’m mistaken, I can not apply your script?

A new version of the component with the PRs from @rchl is available.
Please let me know if it’s working as expected.

Edit: found a small error in the previous version. It’s fixed now with pySonyBraviaPSK==0.1.7.
Below version is working as expected now.

Thanks, works fine with 0.76.2 on Tinker Board S HassIO :slight_smile:

1 Like