Sony Devices Binding

@Mattrees007

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.,

Tim

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.

Power OFF=ircc:AAAAAQAAAAEAAAAvAw%3D%3D
Power ON=ircc:AAAAAQAAAAEAAAAuAw%3D%3D
Power=ircc:AAAAAQAAAAEAAAAVAw%3D%3D

Looking into it a bit further…
http://192.168.21.18/s2mtv/SSDgetDeviceInfo/

<response>
<header version="01">
<command>SSDgetDeviceInfo</command>
<code>0</code>
</header>
<sony>
<product id="DTV">
<referrer_id>F0BF977F643F</referrer_id>
<features>
<direct_url>true</direct_url>
</features>
<cers>
<x_unr_version>1.2</x_unr_version>
<x_cers_actionlist_url>http://192.168.21.18:80/cers/ActionList.xml</x_cers_actionlist_url>
</cers>
<ircc>
<x_ircc_version>1.0</x_ircc_version>
<scpd_url>http://192.168.21.18:80/IRCC/IRCCSCPD.xml</scpd_url>
<control_url>http://192.168.21.18:80/IRCC</control_url>
<event_sub_url/>
</ircc>
<iptv_params>
<build>PKG4.027EUA</build>
<language>en</language>
<rating>21</rating>
<age_rating>21</age_rating>
<mpaa_rating>X</mpaa_rating>
<rating_country>EUR</rating_country>
<block_unrated>f</block_unrated>
<ui_type>0</ui_type>
<drm_types>MARLINBB,SSL,WMDRM10</drm_types>
<config_types>CAD,FLX</config_types>
<audio_types>AAC,AAC-LC,AC3,HE-AAv1,HE-AAv2,MP3,WMA</audio_types>
<stream_types>HTTP,HTTPLS,HTTPS</stream_types>
<video_types>AVC,MPEG2,WMV9</video_types>
<container_types>3GPP,ASF,MOV,MP3,MP4,MPEG2TS</container_types>
<display_types>2D</display_types>
<metafile_types>M3U8</metafile_types>
<display_width>960</display_width>
<display_height>540</display_height>
</iptv_params>
</product>
</sony>
</response>

http://192.168.21.18/IRCC/IRCCSCPD.xml

<scpd xmlns="urn:schemas-upnp-org:service-1-0">
<specVersion>
<major>1</major>
<minor>0</minor>
</specVersion>
<actionList>
<action>
<name>X_SendIRCC</name>
<argumentList>
<argument>
<name>IRCCCode</name>
<direction>in</direction>
<relatedStateVariable>X_A_ARG_TYPE_IRCCCode</relatedStateVariable>
</argument>
</argumentList>
</action>
<action>
<name>X_GetStatus</name>
<argumentList>
<argument>
<name>CategoryCode</name>
<direction>in</direction>
<relatedStateVariable>X_A_ARG_TYPE_Category</relatedStateVariable>
</argument>
<argument>
<name>CurrentStatus</name>
<direction>out</direction>
<relatedStateVariable>X_A_ARG_TYPE_CurrentStatus</relatedStateVariable>
</argument>
<argument>
<name>CurrentCommandInfo</name>
<direction>out</direction>
<relatedStateVariable>X_A_ARG_TYPE_CurrentCommandInfo</relatedStateVariable>
</argument>
</argumentList>
</action>
</actionList>
<serviceStateTable>
<stateVariable sendEvents="no">
<name>X_A_ARG_TYPE_IRCCCode</name>
<dataType>string</dataType>
</stateVariable>
<stateVariable sendEvents="no">
<name>X_A_ARG_TYPE_Category</name>
<dataType>string</dataType>
</stateVariable>
<stateVariable sendEvents="no">
<name>X_A_ARG_TYPE_CurrentStatus</name>
<dataType>string</dataType>
</stateVariable>
<stateVariable sendEvents="no">
<name>X_A_ARG_TYPE_CurrentCommandInfo</name>
<dataType>string</dataType>
</stateVariable>
</serviceStateTable>
</scpd>

http://192.168.21.18/cers/ActionList.xml

<actionList>
<action name="register" mode="2" url="http://192.168.21.18:80/cers/api/register"/>
<action name="getText" url="http://192.168.21.18:80/cers/api/getText"/>
<action name="sendText" url="http://192.168.21.18:80/cers/api/sendText"/>
<action name="getSystemInformation" url="http://192.168.21.18:80/cers/api/getSystemInformation"/>
<action name="getRemoteCommandList" url="http://192.168.21.18:80/cers/api/getRemoteCommandList"/>
<action name="getStatus" url="http://192.168.21.18:80/cers/api/getStatus"/>
<action name="BgmSearch::search" url="http://192.168.21.18:80/BgmSearch/search"/>
</actionList

http://192.168.21.18:52323/dmr.xml

<root xmlns="urn:schemas-upnp-org:device-1-0" xmlns:pnpx="http://schemas.microsoft.com/windows/pnpx/2005/11" xmlns:df="http://schemas.microsoft.com/windows/2008/09/devicefoundation">
<specVersion>
<major>1</major>
<minor>0</minor>
</specVersion>
<device>
<deviceType>urn:schemas-upnp-org:device:MediaRenderer:1</deviceType>
<friendlyName>BRAVIA KDL-32CX523</friendlyName>
<manufacturer>Sony Corporation</manufacturer>
<manufacturerURL>http://www.sony.net/</manufacturerURL>
<modelName>KDL-32CX523</modelName>
<UDN>uuid:00000000-0000-1010-8000-F0BF977F643F</UDN>
<dlna:X_DLNADOC xmlns:dlna="urn:schemas-dlna-org:device-1-0">DMR-1.50</dlna:X_DLNADOC>
<iconList>
<icon>
<mimetype>image/png</mimetype>
<width>32</width>
<height>32</height>
<depth>24</depth>
<url>/MediaRenderer_32x32.png</url>
</icon>
<icon>
<mimetype>image/png</mimetype>
<width>48</width>
<height>48</height>
<depth>24</depth>
<url>/MediaRenderer_48x48.png</url>
</icon>
<icon>
<mimetype>image/png</mimetype>
<width>60</width>
<height>60</height>
<depth>24</depth>
<url>/MediaRenderer_60x60.png</url>
</icon>
<icon>
<mimetype>image/png</mimetype>
<width>120</width>
<height>120</height>
<depth>24</depth>
<url>/MediaRenderer_120x120.png</url>
</icon>
<icon>
<mimetype>image/jpeg</mimetype>
<width>32</width>
<height>32</height>
<depth>24</depth>
<url>/MediaRenderer_32x32.jpg</url>
</icon>
<icon>
<mimetype>image/jpeg</mimetype>
<width>48</width>
<height>48</height>
<depth>24</depth>
<url>/MediaRenderer_48x48.jpg</url>
</icon>
<icon>
<mimetype>image/jpeg</mimetype>
<width>60</width>
<height>60</height>
<depth>24</depth>
<url>/MediaRenderer_60x60.jpg</url>
</icon>
<icon>
<mimetype>image/jpeg</mimetype>
<width>120</width>
<height>120</height>
<depth>24</depth>
<url>/MediaRenderer_120x120.jpg</url>
</icon>
</iconList>
<serviceList>
<service>
<serviceType>urn:schemas-upnp-org:service:RenderingControl:1</serviceType>
<serviceId>urn:upnp-org:serviceId:RenderingControl</serviceId>
<SCPDURL>/RenderingControlSCPD.xml</SCPDURL>
<controlURL>/upnp/control/RenderingControl</controlURL>
<eventSubURL>/upnp/event/RenderingControl</eventSubURL>
</service>
<service>
<serviceType>urn:schemas-upnp-org:service:ConnectionManager:1</serviceType>
<serviceId>urn:upnp-org:serviceId:ConnectionManager</serviceId>
<SCPDURL>/ConnectionManagerSCPD.xml</SCPDURL>
<controlURL>/upnp/control/ConnectionManager</controlURL>
<eventSubURL>/upnp/event/ConnectionManager</eventSubURL>
</service>
<service>
<serviceType>urn:schemas-upnp-org:service:AVTransport:1</serviceType>
<serviceId>urn:upnp-org:serviceId:AVTransport</serviceId>
<SCPDURL>/AVTransportSCPD.xml</SCPDURL>
<controlURL>/upnp/control/AVTransport</controlURL>
<eventSubURL>/upnp/event/AVTransport</eventSubURL>
</service>
<service>
<serviceType>urn:schemas-sony-com:service:IRCC:1</serviceType>
<serviceId>urn:schemas-sony-com:serviceId:IRCC</serviceId>
<SCPDURL>http://192.168.21.18:80/IRCC/IRCCSCPD.xml</SCPDURL>
<controlURL>http://192.168.21.18:80/IRCC</controlURL>
<eventSubURL/>
</service>
</serviceList>
<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>
</av:X_IRCCCodeList>
<pnpx:X_compatibleId>MS_DigitalMediaDeviceClass_DMR_V001</pnpx:X_compatibleId>
<pnpx:X_deviceCategory>MediaDevices</pnpx:X_deviceCategory>
<pnpx:X_hardwareId>VEN_0033&DEV_0006&REV_01</pnpx:X_hardwareId>
<df:X_deviceCategory>Display.TV Multimedia.DMR</df:X_deviceCategory>
<av:X_IRCC_DeviceInfo xmlns:av="urn:schemas-sony-com:av">
<av:X_IRCC_Version>1.0</av:X_IRCC_Version>
<av:X_IRCC_CategoryList>
<av:X_IRCC_Category>
<av:X_CategoryInfo>AAEAAAAB</av:X_CategoryInfo>
</av:X_IRCC_Category>
<av:X_IRCC_Category>
<av:X_CategoryInfo>AAIAAACX</av:X_CategoryInfo>
</av:X_IRCC_Category>
<av:X_IRCC_Category>
<av:X_CategoryInfo>AAIAAAAa</av:X_CategoryInfo>
</av:X_IRCC_Category>
<av:X_IRCC_Category>
<av:X_CategoryInfo>AAIAAACk</av:X_CategoryInfo>
</av:X_IRCC_Category>
</av:X_IRCC_CategoryList>
</av:X_IRCC_DeviceInfo>
<av:X_UNR_DeviceInfo xmlns:av="urn:schemas-sony-com:av">
<av:X_UNR_Version>1.2</av:X_UNR_Version>
<av:X_CERS_ActionList_URL>http://192.168.21.18:80/cers/ActionList.xml</av:X_CERS_ActionList_URL>
</av:X_UNR_DeviceInfo>
<av:X_S2MTV_DeviceInfo xmlns:av="urn:schemas-sony-com:av">
<av:X_S2MTV_Version>1.0</av:X_S2MTV_Version>
<av:X_S2MTV_BaseURL>http://192.168.21.18:80/s2mtv</av:X_S2MTV_BaseURL>
</av:X_S2MTV_DeviceInfo>
</device>
</root>

EDIT

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

#!/bin/sh

set -e

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

cmd="<?xml version=\"1.0\"?><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>$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 "✓"
else
  echo "Command failed (HTTP_CODE: $code, try running it in a console)"
  exit 1
fi

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
sony:scalar:a2686999-8d9f-48f1-b37c-bc558eebf92a:appControl-com__0sony__0dtv__0org__0xbmc__0kodi__0org__0xbmc__0kodi__0Splash-appstatuscontent_copy
Switch
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?
Thanks
Thomas

@beardedfool
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).

@ThomasK

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.

Tim

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 http://192.168.21.18:52323/dmr.xml (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.

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)

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?

@beardedfool
Actually - you can help me out if you would. Go to the web browser on your TV and go to “google.com” - 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 google.com 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

@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.

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

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…xxx.map:

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"}

Sitemap:

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

Rules:

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

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…

@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.

1 Like

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

http://helpguide.sony.net/gbmig/ADXM1001/eng/CX52x_o32/ft_index.html

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.
https://imgur.com/uFPe5Ac

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

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

Thanks,

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 org.openhab.binding.sony once I’m done here?

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).

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.

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?

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.