Sony Bravia TV component with Pre-Shared Key

So then I should be able to to have this script look like this?
sequence:

data:
entity_id: media_player.sony_bravia_tv
source: tv:atsct
service: media_player.select_source

That would be great! I am mainly looking for Channel 4 and 9 if possible. Also, it seems that it will only switch from another input in the source list (HDMI). If Netflix, any other app or even the home screen is open, the script will not do anything. I was not able to get it to do a combination either.

I’ll give it a try! Thank you for your fast help :slight_smile:

Capturar

As you can see, my tv has these on and off moments… I know because I have a pushbullet notification every time the tv changes it states.

I have a wifi connection with the tv, is that the problem? How can I solve this? Sometime it takes minutos for the homeassistant to detect the tv is on, other times it takes seconds.

My main goal was to control my cable box using Broadlink RM Pro, when I power off the tv, the cable box goes off and a IR controled led strip goes off as well after 20 seconds, when I power on the tv de cable box goes on and the IR controled led strip goes on. These I could turn on and off the tv, the led strip and the cable box with just one remote :-/

Can you temporary try to connect the TV via an UTP cable to see if that fixes the issue?

And do you know when these state changes happen? Only when changing channel/input or also when you are just watching TV without changing anything?

You can download the version below. I’ve added support for tv:atsct so now the source list should be available.
You can also use the other channel numbers, the complete list of supported input is:

PLAY_MEDIA_OPTIONS = [
    'Num1', 'Num2', 'Num3', 'Num4', 'Num5', 'Num6', 'Num7', 'Num8', 'Num9',
    'Num0', 'Netflix', 'Display', 'ChannelUp', 'ChannelDown', 'Up', 'Down',
    'Left', 'Right', 'Confirm', 'Home', 'EPG', 'Return', 'Options', 'Exit'
]

Great work! So I have been playing around a bit and I still cannot select the tv:atsct source, nor does it even show in the source list. I was able to test out some the new supported inputs and can confirm that all of the channel numbers and “Confirm” are working.

While I can’t select tv:atsct directly, I can get around it by running a script that powers on the TV, switches to an HDMI source, sends the channel number, then sends “Confirm”. Here is the script:

alias: Sony Bravia Power On To Channel 4
sequence:

  • data:
    entity_id: media_player.sony_bravia_tv
    service: media_player.turn_on
  • data:
    entity_id: media_player.sony_bravia_tv
    source: HDMI 1
    service: media_player.select_source
  • data:
    entity_id: media_player.sony_bravia_tv
    media_content_id: Num4
    media_content_type: tvshow
    service: media_player.play_media
  • data:
    entity_id: media_player.sony_bravia_tv
    media_content_id: Confirm
    media_content_type: tvshow
    service: media_player.play_media

Good to hear the channels are working :grinning:

You can’t select the tv:atsct source with a script. I’ve added it in a way that the channels from that source should be visible in the source list. Then you should be able to select a source from that list with a script (e.g. ‘BBC One HD’).
I guess tv:atsct is part of the internal tuner? Or do you view that with an external device via HDMI1?

Yes, tv:atsct is the internal tuner, I have an antenna connected directly to the TV. The only sources that show in the list are still HDMI 1-4. The only way I can get it to switch to tv:atsct is by first going to HDMI then running the channel numbers. I am still able to do exactly what I need, there is just an extra step instead of going directly to the right source. On the TV menu the source for my antenna is listed as “Channels” if that helps? I did not choose that name it was the default name for that source.

After playing around a bit more I have a working morning automation now that gets it to channel 4:

  • action:
    • data:
      entity_id: group.bedroom
      service: homeassistant.turn_on
    • data:
      entity_id: media_player.sony_bravia_tv
      service: media_player.turn_on
    • data:
      entity_id: media_player.sony_bravia_tv
      source: HDMI 1
      service: media_player.select_source
    • delay: 00:00:03
    • data:
      entity_id: media_player.sony_bravia_tv
      media_content_id: Num4
      media_content_type: tvshow
      service: media_player.play_media
    • data:
      entity_id: media_player.sony_bravia_tv
      media_content_id: Confirm
      media_content_type: tvshow
      service: media_player.play_media
      alias: Morning Routine
      condition:
    • condition: time
      weekday:
      • mon
      • tue
      • wed
      • thu
      • fri
        id: ‘1516221926233’
        trigger:
    • at: 06:45:00
      platform: time

Have you tried or been able to enter multiple digits? I tried for awhile, but was never able to enter more than one digit.
I’d love to just create my own channel mapping to send the channel changes.

Can you make a PR for add this component inside HASS?
Regards.

1 Like

I’m apparently too new at this. I finally figured out how to get multiple numbers by just calling the service for each number. I was trying to get multiple digits in a single call to the service.

So now that that’s working… Back to getting “Channels” to work as a source. On all 3 of my TV’s “Channels” shows up as one of the inputs. I’ve also mapped (in the Sony settings on the TV) the “TV” button on the remote to “Channels”. I didn’t see TV as one of the PLAY_MEDIA_OPTIONS and I tried to add Channels as a source with no luck. But as seen above, I might be doing it wrong :smiley:

I am trying to use this and i am able to turn the TV on and off however I don’t see any source options for my TV and when I turn it on all it does is load the screen into a picture of Home Assistant. Is there something I am missing. Also when I turn my TV on it seems to be on the Cast device built into the TV in Home Assistant and not the actual TV device since the Android TV separates them out.

I am working on that. I already made a PR for the PSK version, but that was rejected as it was an extra component next to the existing Bravia (PIN version) component.
So I have now made a new version which combines both the PSK and existing PIN connection to one component. It’s available at:

As I want to be sure the current PIN version stays working correctly for people using that version, I am looking for some people to test that part. Currently it’s tested by one user, but some more would be better.

So if there are any other people willing to test that version to see if the PIN connection is still working then that would be great :grinning:

That new version should be put into custom_components/media_player? Or should I replace bravia component in the HA install? (I’ve got 2015 Android TV model if that matters)

So I’m running the latest version and now have it configured to 3 different Sony TVs. All are running with a different PSK and all seem to be working.
I can also report that ATSC is working, and the channels do show up as a Source and the program info displays correctly.

Is there a way I can manually add channels to the source list? The ATSC channels are in the same “Channels” app as the HD Homerun channels. Even though I’m not seeing them as a source, could I manually add a channel as source?

@NLJ you can indeed install it in custom_components/media_player. There is a sample config.yaml on my Github repo which you can use.

What is shown as source on the states page (dev tools) when you have selected a HD Homerun channel?
Maybe I can add that source just I did for tv:atsct.

Source isn’t listed when it’s on an HD Homerun channel. It does appear as “tv:atsc” when on one of the antenna channels.
However, the guide displayed on the TV integrates the Antenna (ATSC) and HD Homerun channels into one list. That’s why I was wondering if there was a way to force a channel into the source list to see if it would tune properly.

I just put that into my HA and got this in log:
2018-04-08 00:26:06 ERROR (MainThread) [homeassistant.setup] Error during setup of component media_player
Traceback (most recent call last):
File “/home/hassio/ha36/lib/python3.6/site-packages/homeassistant/setup.py”, line 145, in _async_setup_component
component.setup, hass, processed_config)
AttributeError: module ‘custom_components.media_player’ has no attribute ‘setup’

(latest version from your git repo)