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.