IP control of Sony TV with HA

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.

Hi @shawly

Thank you very much for your input, I will set this up in my environment. I think after this I don’t even need the requested features!

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.

braviatv-Integration - support IRCC-IP :slight_smile:

Best regards

Pete

Hi @shawly
I set up the rest_command. I forgot the PIN I had to enter when I set up ADB, so I created a PSK which I think should work too?

I am trying to send

<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 comment="Home">AAAAAQAAAAEAAABgAw==</IRCCCode>
        </u:X_SendIRCC>
    </s:Body>
</s:Envelope>

with header

SOAPACTION:urn:schemas-sony-com:service:IRCC:1#X_SendIRCC
X-Auth-PSK:1717

But I am getting the following error:

<?xml version="1.0"?>
<s:Envelope
    xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"
    s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
    <s:Body>
        <s:Fault>
            <faultcode>s:Client</faultcode>
            <faultstring>UPnPError</faultstring>
            <detail>
                <UPnPError xmlns="urn:schemas-upnp-org:control-1-0">
                    <errorCode>401</errorCode>
                    <errorDescription>Invalid Action</errorDescription>
                </UPnPError>
            </detail>
        </s:Fault>
    </s:Body>
</s:Envelope>

Does this ring any bells for you?

@shawly
Never mind, I found it. The action in the header needs to be within quotation marks:

"urn:schemas-sony-com:service:IRCC:1#X_SendIRCC"

Oh alright. :smiley:

Great solution, i tried to implement it but im gettin error.Does anyone has any solution for this? what should i check. I also tired with ircc lowercase, same error.

Logger: homeassistant.components.rest_command
Source: components/rest_command/init.py:132
Integration: rest_command (documentation, issues)

Error. Url: http://xxx.xxx.xxx.xxx/sony/IRCC. Status code 500.