Sony Devices Binding

Tags: #<Tag:0x00007f1826495d50>

(Tim Roberts) #421


Either the discovery messages from the devices can’t make it to the device openHAB is running on (ie firewall/network issue) or more than likely you’re running on 2.2 and the binding doesn’t work on 2.2 because of the apache client being used. You can look in the log and see if it says something like #386 - if it does, that’s the 2.2 issue I have.

Next version of the binding - which I’m still working on, will replace it with a good client and eliminate that issue.,


(AH) #422

Hi Tim,

Posted above but have a little more information in case there’s anything obvious I’m missing, or something on this old device that’s obviously different from your code. Any suggestions would be extremely welcome.

TV: bravia KDL-32CX523 (old! c.2011)
Problem: All commands are working find apart from:

  • Power On - through there doesn’t seem to be WOL on this, or at least it doesn’t work, so maybe this won’t either

  • Power Off - this is the one I really want and isn’t working with the commands from the .map file (I’ve tried replacing the %3d with = as well. No Dice.


Looking into it a bit further…

<header version="01">
<product id="DTV">

<scpd xmlns="urn:schemas-upnp-org:service-1-0">
<stateVariable sendEvents="no">
<stateVariable sendEvents="no">
<stateVariable sendEvents="no">
<stateVariable sendEvents="no">

<action name="register" mode="2" url=""/>
<action name="getText" url=""/>
<action name="sendText" url=""/>
<action name="getSystemInformation" url=""/>
<action name="getRemoteCommandList" url=""/>
<action name="getStatus" url=""/>
<action name="BgmSearch::search" url=""/>

<root xmlns="urn:schemas-upnp-org:device-1-0" xmlns:pnpx="" xmlns:df="">
<friendlyName>BRAVIA KDL-32CX523</friendlyName>
<manufacturer>Sony Corporation</manufacturer>
<dlna:X_DLNADOC xmlns:dlna="urn:schemas-dlna-org:device-1-0">DMR-1.50</dlna:X_DLNADOC>
<av:X_MaxBGMCount xmlns:av="urn:schemas-sony-com:av">64</av:X_MaxBGMCount>
<av:X_StandardDMR xmlns:av="urn:schemas-sony-com:av">1.1</av:X_StandardDMR>
<av:X_IRCCCodeList xmlns:av="urn:schemas-sony-com:av">
<av:X_IRCCCode command="Power">AAAAAQAAAAEAAAAVAw==</av:X_IRCCCode>
<av:X_IRCCCode command="Power ON">AAAAAQAAAAEAAAAuAw==</av:X_IRCCCode>
<av:X_IRCCCode command="Power OFF">AAAAAQAAAAEAAAAvAw==</av:X_IRCCCode>
<df:X_deviceCategory>Display.TV Multimedia.DMR</df:X_deviceCategory>
<av:X_IRCC_DeviceInfo xmlns:av="urn:schemas-sony-com:av">
<av:X_UNR_DeviceInfo xmlns:av="urn:schemas-sony-com:av">
<av:X_S2MTV_DeviceInfo xmlns:av="urn:schemas-sony-com:av">


Well, I suspect it’s not your code as this has the same problem…


set -e

#if [ "$1" = "" ] || [ "$2" = "" ]; then
#  echo "Usage: $0 <TV_IP> <IRCC_COMMAND>"
#  exit 1

cmd="<?xml version=\"1.0\"?><s:Envelope xmlns:s=\"\" s:encodingStyle=\"\"><s:Body><u:X_SendIRCC xmlns:u=\"urn:schemas-sony-com:service:IRCC:1\"><IRCCCode>$2</IRCCCode></u:X_SendIRCC></s:Body></s:Envelope>"

code=$(curl -w "%{http_code}" --silent -XPOST http://$1/IRCC -d "$cmd" -H 'Content-Type: text/xml; charset=UTF-8' -H 'SOAPACTION: "urn:schemas-sony-com:service:IRCC:1#X_SendIRCC"' -H "X-Auth-PSK: 0000" -o /dev/null )

if [ "$code" = "200" ]; then
  echo "✓"
  echo "Command failed (HTTP_CODE: $code, try running it in a console)"
  exit 1

(ThomasK) #423

I got my Sony KD65XD8577 working with the latest version as a scalar device. Great Job from you!
Now I would like to realize a Switch in the basic UI, which allows switching

  • some (very few) named channels
  • HDMI 3
  • Kodi (installed App)
  • and maybe other Apps (as the Sony has a really weird interface IMHO).

However, I do not get the point how to interpret the things it found. I have in the Paper UI:
App Kodi Status
from which I made an Item

Switch TV_Kodi          "TV Kodi"           {channel="sony:scalar:a2686999-8d9f-48f1-b37c-bc558eebf92a:appControl-com__0sony__0dtv__0org__0xbmc__0kodi__0org__0xbmc__0kodi__0Splash-appstatus"}

Well it kind of works: If I switch the Item to ON, Kodi starts! Great. But the name ‘appstatus’ implicates that it would also show ON when KODI is running, what it doesn’t. But thats not so important.
I can also find more things, like for HDMI. What needs to be done now to bring them together as a selection box? I think I need some thing like an ‘input selector’, but I cannot find sth alike. Can you suggest sth?

(Tim Roberts) #424

Power commands on all sony devices are flaky at best. From your actionList - do the getRemoteCommandList URL and double check the power like commands in it (although that’s how the binding get’s the commands for the map file). I have a feeling yours just ignores them - but I’d give a few versions a try (note: don’t replace the %3D with equals in the map file - those are encoded and decoded on purpose).

(Tim Roberts) #425


The binding makes a best effort to determine the appstatus but it depends on whether the TV has implemented a specific API (which many do not). If yours is not being set, then the TV likely doesn’t implement that feature. Likewise, making it a switch generally won’t work for the ‘OFF’ side (I’ve yet to see Sony implement the ‘turn off an app’ properly) - you’re better off just making it a button to turn it on (and going to something else turns it off).

I hate to say - I use NEEO and/or habpanel almost exclusively now and can’t really make a suggestion on doing a selector in the sitemap - maybe someone with more experience there can help you.


(AH) #426

Thanks for the speedy answer and help Tim, and for the binding. The rest works brilliantly.

I suspect you’re right about this TV, it’s old and I’ll go down the IR remote for power instead. The map file has the same IRCC as (and most other sources I can find on the web).

Out of interest, should I be doing some sort of http post or curl/ query for the getremotecommandslist? All a bit new to me but learning as quick as I can.

Noted on the subsitution, cheers for clearing that up.

(Tim Roberts) #427

You can just plug it into your browser URL bar - it’s a get command that the browser handles fine. The only issue is whether you’d need authentication to do it or not (depends if the TV considers it a protected API [some do, some don’t]) - if it returns a 403 - then you won’t be able to do it (atleast not without going through the whole registration process - which is a pain)

(ThomasK) #428

Hi Tim,
well the selector is not the thing. I have one for my Denon working, like this

Selection label="Input" item=DenonInput mappings=[CD="CD", BD="BluRay", Internetradio="Internetradio", TV="TV"] 

The only thing is: what do I need instead of item=DenonInput? I think sth that receives inputs like the one from above, where I have KODI put.

Maybe someone has found some suitable thing in his/her Bravia TV?

(Tim Roberts) #429

Actually - you can help me out if you would. Go to the web browser on your TV and go to “” - then make sure the cursor is in the input field.

Now go to the debug log file - I’m looking for the results of two different calls in the log:

  1. The results of the ‘getText’ call (should see somewhere in the resulting XML)
  2. Try to find a call to ‘getContentUrl’ - doesn’t look like your’s defines that but see if you see it in the log file - I’d like to see the resulting XML

(Scott Rushworth) #430

@tmrobert8, did this post get passed you? I doubt you will be doing anything for these speakers or HomeShare, but I wanted to be sure before I put more time into it.

(Tim Roberts) #431

Maybe @freke can comment on whether they would be compatible with the sony audio api. If not, post your scripts and I can take a look at them

(ThomasK) #432

I managed by myself.
If anybody is interested: Switching Input on the Bravia works like this.
Precondition: you have a discovered scalar Bravia TV. You have Things. You need:
Items (the strings need to be found in the transform folder in file scalar…

String TV_Switch        "Umschalten"

Switch TV_Kodi          "Kodi"           { channel="sony:scalar:a2686999-8d9f-48f1-b37c-bc558eebf92a:appControl-com__0sony__0dtv__0org__0xbmc__0kodi__0org__0xbmc__0kodi__0Splash-appstatus"}
Switch TV_HDMI3         "HDMI Sky"       { channel="sony:scalar:a2686999-8d9f-48f1-b37c-bc558eebf92a:avContent-content-extInput-extInput__3hdmi-0002-cn_status"}
Switch TV_ARD           "ARD"            { channel="sony:scalar:a2686999-8d9f-48f1-b37c-bc558eebf92a:avContent-content-tv-tv__3dvbs-0000-cn_status"}
Switch TV_ZDF           "ZDF"            { channel="sony:scalar:a2686999-8d9f-48f1-b37c-bc558eebf92a:avContent-content-tv-tv__3dvbs-0002-cn_status"}


		    Selection label="Switch to" item=TV_Switch mappings=[TV_KODI="Kodi", TV_HDMI3="Sky HDMI", TV_ARD="ARD", TV_ZDF="ZDF"] 


rule "Switch TV Input"
    Item TV_Switch received update
    logInfo(" TV_Switch is:", TV_Switch.state.toString)
    if (TV_Switch.state.toString == "TV_Kodi") {
    if (TV_Switch.state.toString == "TV_HDMI3") {
    if (TV_Switch.state.toString == "TV_ARD") {
    if (TV_Switch.state.toString == "TV_ZDF") {

So the Selection in the Sitemap does nothing but set some string. A rule evaluates this and sends an ‘ON’ Command. This worked for me.
Only Drawback: The Item TV_Switch will always keep its last value as set in the openhab UI, no matter what you do with your real TV remote…

(David Åberg) #433

@tmrobert8 @5iver
Unfortunately I believe that SA-NS300 and SA-NS400 pre dates the Audio API, the earliest products from Sony that uses the Audio API is from 2013 (I believe SA-NS300 and SA-NS400 are from 2011). It uses DLNA to play and select music same as newer models but the control API is something else.

(AH) #434

No problem helping but it’s pretty painful to use - It’s geological in speed, doesn’t recognise a usb keyboard though so I’m limited to the remote and currently can’t even see how to enter in a url to it, no address bar

I’ll keep trying though.

If I can work that out, how do I get the debug log file up? Are we still talking about the TV’s browser?

EDIT: Tried two keyboards now (and HP and a logitech) and neither work
I’ve come to the conclusion, having battled with the browser, that it’s powered by a potato.

Also, just been chatting with someone this guy, in case it’s useful as a resource at all

(Tim Roberts) #435

From the openhab console - type “log:set debug” - then you’ll have some debug messages for the sony binding in your log file

(AH) #436


Logs set after some reading (didn’t know about console to give you an idea of what you’re dealing with here). But the browser on the TV is, I’m afraid, unusable, it just pretty much hangs.

Is there anything I can do from here. log:tail is showing a lot of information but I’m in a strange world in the console. What language is this?

Can I just check I’m doing log:set default once I’m done here?

(Tim Roberts) #437

Ok - don’t worry about it then (was more of a nice to have). As for the sonyapilib - I looked at that in the very beginning and am waaaay past what the lib does/supports and support a ton more devices (the sonyapilib does do a few things in APIs I don’t support - but that’s mainly because the binding can control them in other ways).

(AH) #438

Cheers for all the help Tim, do ask in future if there’s anything I can test for you.

Just to round this off for someone else reading it - Kirk, who wrote the Sony API mentioned kindly tested his TV and confirmed none of the power commands are working on either TV (his is a different model but similar age)

So I’ve gone the IR remote, building a board controlled from a Rasberry PI.

(stu) #439

Hi Tim,

I’m purchasing a few tv’s soon. Would you recommend Sony over other brands if openhab integration is required? Are there some current models that work reliably with the scalar binding that youre working on. Sony have a history of making features available and then removing them in firmware updates. Is this likely to be the case with scalar?

(Wexy101) #440

Total nube here! Simple Question, is there a user guide for this binding? I’ve read everything and everyone get connected etc, i try and cant get past the The Commands Map File being required, which i cant find a mention of any where and havent a clue what to put in this field. A guide would be helpful.