IP control of Sony TV with HA

To install and try you need to ssh into your Pi, probably the same way you installed HA.

These are the command to type, you need to setup your TV as below.

git clone https://github.com/breunigs/bravia-auth-and-remote
cd bravia-auth-and-remote
./send_command.sh 192.168.2.112 AAAAAgAAABoAAAB8Aw==

Setup TV

You need to set your TV to use a pre-shared key.

Navigate to: [Settings] → [Network] → [Home Network Setup] → [IP Control]

Set [Authentication] to [Normal and Pre-Shared Key]

There should be a new menu entry [Pre-Shared Key]. Set it to 0000. If you choose
anything else, you need to change the PSK in the send_command.sh script.

Hey RobDYI, I feel stupid right now. Sorry :-). I installed home assistant with this video https://youtu.be/c2IUIUnxjUY. So I am not sure what you mean by ssh. Is there a video or some thing that shows me the way? Thanks a lot! Greetings

I don’t think you can install this program on your installation. I think you have hass.io installed which I don’t.

I’m on hass.io with a 2013 bravia and I send commands like this (option button on the remote)

shell_command:
  sony_options: |-
    curl -H "Accept: application/json" -H "Content-type: application/json" -X POST -d '<?xml version="1.0" encoding="utf-8"?><s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><s:Body><u:X_SendIRCC xmlns:u="urn:schemas-sony-com:service:IRCC:1"><IRCCCode>AAAAAgAAAJcAAAA2Aw==</IRCCCode></u:X_SendIRCC></s:Body></s:Envelope>' http://10.0.1.4/sony/IRCC?

Hi @RobDYI, do you know how to install this script when running HA in a Docker container? Is this still the easiest way for full IP control over the Sony Bravia? Thanks for the help.

You can google for ip control bravia and their are several different github project that you can try. I would suggest using this custom components as it added some basis ip control like on and netflix but not all. I really only needed the numbers in ip control so I can program changing channels.

I found your script yesterday and I thought I would give it a try. While it was working, I now suddenly had this error coming up:

./send_command.sh 192.168.1.6 aaaaaqaaaaeaaabgaw==
Command failed (HTTP_CODE: 500, try running it in a console)

And I am running it in a console :stuck_out_tongue:

Perhaps your TV ip address changed. I set mine as static.

Mine is static too… And can also ping it.

is there an instruction for hassio? those run this run that are aliens to me :slight_smile:
or maybe can share their configs and scrips for me.

I would try this if it fits your needs.

thanks. I want to make use of the shell commands. but I am not sure how to find the path of where config folder is on hassio

Hi, can you explain this for me? I have a sony android tv and try to get this to work

I don’t use hass.io but I think its fairly tied down so you might no be able to run shell commands on the same machine as the hass.io.

You can try another computer on the network like here.

In my opinion, the braviatv-Integration should be extended with this commands (from the soap-interface I think?)

The REST API on which the integration is apparently based does not provide that much functions.

I need to simulate remote-input like arrow keys…

https://pro-bravia.sony.net/develop/integrate/ircc-ip/overview/index.html

I made a remote in the past and I am still using it. You can read all about it here:

This could be a workaround for you. It is for me…

Thank you, I stumbled over this while google-ing. I will have a look at it - as it is a native sony feature, I guess IRCC-IP is quite responsive.
I set up ADB and the androidtv integration, but this is laggy and input takes 2 seconds to happen on the TV…

The thing with the REST API of the Sony TVs is, that quite a few things aren’t documented. Depending on what you want to do there might even be an interface for that.

With this payload

{"method":"getMethodTypes","params":[""],"id":1,"version":"1.0"}

You can get all possible methods from an API endpoint. With this command I was able to find the method getSceneSetting from the /videoScreen endpoint to get all “Scenes” (picture modes) from my Bravia as well as the current one. With that I can now easily automate switching my TV into “game” mode when my AVR has a gaming console selected as source or “cinema” mode when watching Netflix since the picture mode enables or disables certain post processing effects which reduce input lag.

Building a REST command around the /ircc interface wouldn’t be so difficult. I gave it a try:
rest_commands.yml

  sony_bravia_tv_send_ircc_code:
    url: 'http://{{ host }}/sony/ircc'
    method: POST
    headers:
      Content-Type: 'text/xml; charset=UTF-8'
      SOAPACTION: 'urn:schemas-sony-com:service:IRCC:1#X_SendIRCC'
      X-Auth-PSK: '{{ psk }}'
    payload: >-
      <s:Envelope
          xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"
          s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
          <s:Body>
              <u:X_SendIRCC xmlns:u="urn:schemas-sony-com:service:IRCC:1">
                  <IRCCCode>{{ ircccode }}</IRCCCode>
              </u:X_SendIRCC>
          </s:Body>
      </s:Envelope>

And here is a simple button card which now sends the ‘AAAAAQAAAAEAAABgAw==’ IRCC code which maps to the home for my Bravia.

type: button
tap_action:
  action: call-service
  service: rest_command.sony_bravia_tv_send_ircc_code
  service_data:
    host: <your bravia ip>
    psk: <your private shared key>
    ircccode: AAAAAQAAAAEAAABgAw==
hold_action:
  action: more-info
show_icon: true
show_name: true
name: Home
icon: 'hass:home'

This works fine for my KDL-55W805B, you might have to change the URL path to /sony/IRCC instead of /sony/ircc in the rest_command as my older model seems to use /sony/IRCC where as the documentation from sony suggests /sony/ircc.

If you want a full list of IRCC commands that your TV supports just send the payload

{"method":"getRemoteControllerInfo","params":[""],"id":1,"version":"1.0"}

to the /sony/system endpoint

If you want to try out stuff just use a rest client for testing, like Advanced REST Client or Postman.

And about that, I’m afraid this won’t happen as the integration is a simple media_player entity and the media_player component only supports changing sound modes, sources, volume, media playback and media information. Adding functionality that is specific to Sony Bravias or other TVs would mean the devs had to extend the default media player entity to support that as well.

In my opinion we should have more specific components for TVs and AVRs, then the other devs who do integrations could add more features as well since they wouldn’t be bound by the available methods of media_player entity interface.

2 Likes

@shawly
Great, thanks a lot! :beers:
I created a feature request to extend the braviatv integration.

However, I will follow your example and build a rest bridge which I can utilize in the meantime (I am quite new to HA, but I think I see what you did there :slightly_smiling_face:).

I kickstartered for a YIO-remote (Touchscreen remote for HA) and in the end I want to be able to get rid of the ugly original sony remote and control everything with YIO.

Glad I could help.

Don’t get your hopes up too high for your feature request to go through though, but you might want to link it here so everybody can upvote it to increase the chance. :slight_smile:

The YIO-remote thingy looks pretty damn cool, thanks for sharing!

Edit Oh I forgot, the interfaces mentioned in the Sony documentation aren’t all available interfaces. But you can get all possible API endpoints by sending the following payload to the /sony/guide interface

{"method":"getServiceProtocols","params":[""],"id":1,"version":"1.0"}

Which will return an overview of all possible endpoints, then you can just crawl through every endpoint by sending the {"method":"getMethodTypes","params":[""],"id":1,"version":"1.0"} payload I mentioned before. With that you can map the complete API of your TV and use rest sensors and rest commands to control everything.