Sony Bravia TV component with Pre-Shared Key

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’

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.