Sony Bravia TV component with Pre-Shared Key

Great work!!
The dvbs channels are even sorted like on TV.
channel prev/next is the same as sreokkyl.

By the way:
Do you know https://github.com/8none1/bravialib
with a rest API.
Couldnt get it working because of Python 2.x
This would be ideal for my purpose of implementing something like Sideview app with WebGrap++EPG.

1 Like

The channel switching is also not working with the latest version?

Then dvbs is working a bit different than dvbc and dvbt. I can make a version with some extra logging so see if I can fix this. If you or @sreokkyl are able to test that, just let me know.

I have seen that before, but didn’t use it. Maybe the post from @RobDYI is helpful?

Great that it works now! Already thought it had something to do with either the IP address or the PSK :wink:

1 Like

@gerard33 it is all working now! Prev/Next channels are back. Thank you again, great job! Voice commands via Alexa are also back. I am lazy to use remote control now which is only half meter away :slight_smile:

1 Like

LOL, I have not yet implemented my Alexa, but I am already looking forward to switch channels with a voice command :sunglasses:

Just found this and it is absolutely great! Thank you Gerard!

1 Like

i too just found this, many thanks for your work Gerard. I am having some issues though. Its detecting the tv, but no commands seem to work at all. PSK is setup, mac and IP are correct. A bit stumped.

Dave

1 Like

Can you share your config file and hass logs so I can have a look at it?

Edit: I had a chat with @dfiore via Discord and the issue was caused by using 0000 as PSK.
When changing the PSK to sony all worked fine. Will do some test with @dfiore to get a fix for it in my script (probably setting "0000" in the config file will fix this as well).

Works perfectly. Thank you Gerard!

1 Like

followed up with @gerard33 (awesome response time btw) and it was the leading 0. for now if your PSK doesnt start with 0 seems to be all well

Hi gerard33 - thanks for all of your effort with this
Could you help with the following problem please
I have set up HA as you suggest but get the following error

2018-01-21 14:02:16 ERROR (MainThread) [homeassistant.components.media_player] Error while setting up platform braviatv_psk
Traceback (most recent call last):
File “/usr/lib/python3.6/site-packages/homeassistant/helpers/entity_component.py”, line 171, in _async_setup_platform
SLOW_SETUP_MAX_WAIT, loop=self.hass.loop)
File “/usr/lib/python3.6/asyncio/tasks.py”, line 358, in wait_for
return fut.result()
File “/usr/lib/python3.6/asyncio/futures.py”, line 245, in result
raise self._exception
File “/usr/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 76, in setup_platform
add_devices([BraviaTVDevice(host, psk, mac, name, amp, android, source_filter)])
File “/config/custom_components/media_player/braviatv_psk.py”, line 84, in init
from braviarc import braviarc_psk
ImportError: cannot import name ‘braviarc_psk’

Does your HASS have access to the internet? The component needs to use a Python script from Github which does the actual connection to the TV. The error seems related that it can’t find that file.

And can you share your config part for the Bravia TV?

media_player:

  • platform: braviatv_psk
    host: 192.168.1.181
    name: MyBraviaTV
    psk: d625e24857
    mac: 10:4F:A8:D6:59:8B
    amp: True
    android: True

It’s running on a Pi which Hass has full control of. I have set up HTTPS access to the Pi for Alexa integration so there is definitely bi-directional comms there

Re-booted everything and miraculously it’s all working - superb - thank you once more

This is awesome work!

Is it possible to also get some sort of information on what is being played on the android variant?
For instance Now playing: Netflix - Tv Show Name or Now playing: Plex - Movie Name

1 Like

I am not sure about that. My TV doesn’t have Android, so I can’t test it. With my TV I can only check if an app is opened, but not which app and certainly not what is being played.

Maybe someone with an Android version and some Python knowledge can try?

I installed Ha Bridge as Add-on on Hassio.
Sony TV media player added as platform: braviatv_psk to Hassio, work perfect.
Using Ha Bridge as Hue Bridge for Alexa dot.
Configured Sony media player in Ha Bridge, tested on and off function good.
Added to Alexa. When ask Alexa to turn Sony TV on work perfect.
But when asking Alexa to turn Sony TV off got error:
Error executing service <ServiceCall media_player.turn_off: entity_id=[‘media_player.sony’]>
8:54 AM deps/lib/python3.6/site-packages/braviarc/braviarc_psk.py (ERROR)
++++++++++++++++++
Log Details (ERROR)

Sun Jan 28 2018 08:54:23 GMT-0500 (Eastern Standard Time)

Error executing service <ServiceCall media_player.turn_off: entity_id=[‘media_player.sony’]>

Traceback (most recent call last):
File “/usr/lib/python3.6/site-packages/homeassistant/core.py”, line 1010, in _event_to_service_call
yield from service_handler.func(service_call)
File “/usr/lib/python3.6/site-packages/homeassistant/components/media_player/init.py”, line 402, in async_service_handler
yield from getattr(player, method[‘method’])(**params)
File “/usr/lib/python3.6/asyncio/futures.py”, line 332, in iter
yield self # This tells Task to wait for completion.
File “/usr/lib/python3.6/asyncio/tasks.py”, line 250, in _wakeup
future.result()
File “/usr/lib/python3.6/asyncio/futures.py”, line 245, in result
raise self._exception
File “/usr/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 288, in turn_off
self._braviarc.turn_off()
File “/config/deps/lib/python3.6/site-packages/braviarc/braviarc_psk.py”, line 311, in turn_off
self.send_req_ircc(self.get_command_code(‘PowerOff’))
File “/config/deps/lib/python3.6/site-packages/braviarc/braviarc_psk.py”, line 252, in get_command_code
self._refresh_commands()
File “/config/deps/lib/python3.6/site-packages/braviarc/braviarc_psk.py”, line 245, in _refresh_commands
if not resp.get(‘error’):
AttributeError: ‘NoneType’ object has no attribute ‘get’
++++++++++++++++++
Can you PLEASE check braviarc_psk code and if possible fix it?

Will do and if I have a fix I will post it here.

1 Like

Can anyone help me with the syntax to change the source using a script? Goal is to make a script that changes the input source and expose it as a scene to alexa.

Keep running into the below issue on my XBR-55X850D, any ideas?

Failed config
General Errors:
- Platform not found: sensor.braviatv_psk

Successful config (partial)

I have everything setup according to the code, however, I did notice the Bravia was added (XBR-55X850D (media_player)) upon initial boot before I saw this project, so I am guessing there may be another file I need to adjust? I have a little bit of control, in that I can power it on and it shows the HA logo on the screen, but if the device is on already, it shows off and doesn’t control it. Full disclosure, I have ST Hub and Habitat on the network as well. ST uses the same credentials and works fine for full control.