Sony Bravia TV component with Pre-Shared Key

I will update the component so dvb-s is also supported and post it here once the new version is available (probably tomorrow).

1 Like

@kroebi, @sreokkyl, a new version of the component is available which includes the tv:dvbs option.
There were also some other small changes (way info is shown when TV is started via HASS and no info is available yet, swichting channels is now also possible when no program info of a channel is available).

Can you please test this version and let me know if it works as expected?
The latest version is available at https://github.com/gerard33/home-assistant/blob/master/braviatv_psk.py.

1 Like

It is working exactly as expected. Many thanks @gerard33! With channels filtering, you have all you need without deep technical knowledge thanks to your Sony Bravia TV component. Once again, great job!

Only 1 thing I realised now is that next & previous track buttons not working. Tried to restart HA, switchTV off and on but still same. This is only thing with problem.

Good to see it’s working!

Can you elaborate a bit more on the previous and next buttons? Can’t you switch channels when you are watching TV? And are you using the dvbs source in that case?

I use dvbc and can use these buttons to switch channels when watching TV. When not watching TV the buttons can be used for the regular previous and next commands, e.g. when an app is opened.

When I watching TV and click on previous and next buttons, nothing happen on TV but I can see info banner “Service media_player/media_next_track called” popped up on HA overview + details from “ui” below. I also tried to revert back to previous psk version. It is working, buttons are changing channels on my TV. So there is some difference between previous and new version. Btw, it is more comfortable for me to change channels from “source” as I have all my favourite channels filtered so not a big problem :slight_smile: but it took out the ability to ask Alexa to change channels (tracks - “Alexa next track on TV”) by voice commands. I’ll invest more time to the voice commands, that’s the future plan. Other than that, everything is working great. I’ll try to compare psk versions but my knowledge here is really poor, just starting with smart home currently.

On “haas open ui” is below for version with problematic next&previous buttons:
2018-01-14 21:15:49 INFO (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: domain=media_player, service=media_next_track, service_data=entity_id=media_player.tv, service_call_id=4522422056-9>
2018-01-14 21:15:49 INFO (MainThread) [homeassistant.core] Bus:Handling <Event service_executed[L]: service_call_id=4522422056-9>

I have also tested to send commands from https://github.com/breunigs/bravia-auth-and-remote. It is all working. So I can create scripts in HA, add them to the groups in Amazon Alexa and call groups. It will also work but your component have all in one place + added value of frontend with nice functions. Let me know if you need more info and thanks for your work!

1 Like

Another alternative if you can’t find needed commands.

I indeed made some changes in the way the next and previous are working when TV is being watched. I did this because another user (on Discord) mentioned that he could not change channels when no channel information was found (so an empty channel).

I have updated this in a new version which can be downloaded from here (other link than above).
Can you please try this and see if the switching of channels is working again?

Just came across this project and try to implement it. It kinda works but when i try to turn on the tv it turns on but i get this error and HA thinks the tv is off:
2018-01-15 00:50:52 ERROR (SyncWorker_9) [custom_components.media_player.braviatv_psk] No data received from TV, probably it has just been turned off. Error message is: ‘NoneType’ object is not subscriptable

Fixt it! Had a typo in my psk :sweat_smile:

1 Like

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?