Sony Devices Binding

Hello Tim, I have tried to add a KDL-46HX855 Bravia, but found on log the below message:

19-May-2020 14:17:53.322 [DEBUG] [y.internal.scalarweb.ScalarWebDiscoveryParticipant] - No specific thing type found for KDL-46HX855

The log file are in:

Update: after I change the settings:

discovery.sony-simpleip:background=false
discovery.sony-dial:background=false
discovery.sony-ircc:background=false
discovery.sony-scalar:background=true

they found the TV as Sony Ircc Device, but got a “OFFLINE - CONFIGURATION_ERROR” 404 - not foundnot found

The below link is for the new logfile.

Regards,
Arnaldo.

Hi Tim, I have the same problems with Sony KDL-26EX553 (Bravia-2012). After enabling ircc discovery, I was able to add it, but it displays in thing with error. Of all available items only “power off” works.

openhab log

2020-06-04 22:31:51.787 [home.event.InboxAddedEvent] - Discovery Result with UID ‘sony:ircc:5453EDC2BE0A’ has been added.==> /var/log/openhab2/openhab.log <==
2020-06-04 22:31:51.788 [INFO ] [g.discovery.internal.PersistentInbox] - Added new thing ‘sony:ircc:5453EDC2BE0A’ to inbox.==> /var/log/openhab2/events.log <==
2020-06-04 22:54:02.325 [me.event.InboxRemovedEvent] - Discovery Result with UID ‘sony:ircc:5453EDC2BE0A’ has been removed.
2020-06-04 22:54:02.359 [hingStatusInfoChangedEvent] - ‘sony:ircc:5453EDC2BE0A’ changed from UNINITIALIZED to INITIALIZING
2020-06-04 22:54:02.369 [hingStatusInfoChangedEvent] - ‘sony:ircc:5453EDC2BE0A’ changed from INITIALIZING to UNKNOWN: Initializing …
2020-06-04 22:54:02.587 [hingStatusInfoChangedEvent] - ‘sony:ircc:5453EDC2BE0A’ changed from UNKNOWN: Initializing … to OFFLINE (CONFIGURATION_ERROR): 404 - not foundnot found
2020-06-04 23:03:31.828 [.ItemChannelLinkAddedEvent] - Link ‘BRAVIAKDL26EX553_Primary_IRCCPower-sony:ircc:5453EDC2BE0A:primary#power’ has been added.

2020-06-04 23:03:42.349 [ome.event.ItemCommandEvent] - Item ‘BRAVIAKDL26EX553_Primary_IRCCPower’ received command ON
2020-06-04 23:03:42.372 [nt.ItemStatePredictedEvent] - BRAVIAKDL26EX553_Primary_IRCCPower predicted to become NULL
2020-06-04 23:03:46.491 [ome.event.ItemCommandEvent] - Item ‘BRAVIAKDL26EX553_Primary_IRCCPower’ received command OFF
2020-06-04 23:03:46.499 [nt.ItemStatePredictedEvent] - BRAVIAKDL26EX553_Primary_IRCCPower predicted to become NULL
2020-06-04 23:03:48.008 [ome.event.ItemCommandEvent] - Item ‘BRAVIAKDL26EX553_Primary_IRCCPower’ received command ON
2020-06-04 23:03:48.026 [nt.ItemStatePredictedEvent] - BRAVIAKDL26EX553_Primary_IRCCPower predicted to become NULL
2020-06-04 23:03:49.053 [ome.event.ItemCommandEvent] - Item ‘BRAVIAKDL26EX553_Primary_IRCCPower’ received command OFF
2020-06-04 23:03:49.063 [nt.ItemStatePredictedEvent] - BRAVIAKDL26EX553_Primary_IRCCPower predicted to become NULL
2020-06-04 23:04:00.996 [ome.event.ItemCommandEvent] - Item ‘BRAVIAKDL26EX553_Primary_IRCCPower’ received command ON
2020-06-04 23:04:01.006 [nt.ItemStatePredictedEvent] - BRAVIAKDL26EX553_Primary_IRCCPower predicted to become NULL

2020-06-04 23:05:26.623 [.ItemChannelLinkAddedEvent] - Link ‘BRAVIAKDL26EX553_Primary_IRCCCommand-sony:ircc:5453EDC2BE0A:primary#command’ has been added.
2020-06-04 23:05:37.708 [.ItemChannelLinkAddedEvent] - Link ‘BRAVIAKDL26EX553_Viewing_Title-sony:ircc:5453EDC2BE0A:viewing#title’ has been added.
2020-06-04 23:05:45.973 [.ItemChannelLinkAddedEvent] - Link ‘BRAVIAKDL26EX553_Content_Title-sony:ircc:5453EDC2BE0A:content#title’ has been added.
2020-06-04 23:05:54.098 [.ItemChannelLinkAddedEvent] - Link ‘BRAVIAKDL26EX553_Content_Description-sony:ircc:5453EDC2BE0A:content#description’ has been added.

2020-06-04 23:07:55.067 [ome.event.ItemCommandEvent] - Item ‘BRAVIAKDL26EX553_Primary_IRCCCommand’ received command NULL
2020-06-04 23:07:55.072 [nt.ItemStatePredictedEvent] - BRAVIAKDL26EX553_Primary_IRCCCommand predicted to become NULL
2020-06-04 23:08:03.553 [ome.event.ItemCommandEvent] - Item ‘BRAVIAKDL26EX553_Primary_IRCCCommand’ received command NULL
2020-06-04 23:08:03.562 [nt.ItemStatePredictedEvent] - BRAVIAKDL26EX553_Primary_IRCCCommand predicted to become NULL

dmr.xml (5.8 KB)

Haven’t forgotten any of this - work/life got very busy but am hoping maybe next week to address…

Hi Tim,

today I tried to install the SONY Binding, and after trying and failing first I read quite a bit but not successful. I understand it is still in development so there isn’t any rush, just wanted to provide this feedback for you to know, and in case someone can give me a hint, I would be very happy. :hugs:
Environment :

  • Raspberry pi 4 Model B Rev 1.2

  • OH 2.5.5.1

  • SONY KDL 65 XF 9005 (2020) latest firmware

Problem:

  • Binding installs fine through PaperUI
  • Scalar is discovered
  • Thing created, and On Screen PIN dispalyed.
  • After entry of PIN, following error in log

2020-06-08 20:24:39.277 [INFO ] [.internal.scalarweb.ScalarWebHandler] - Attempting connection to Scalar Web device…

2020-06-08 20:24:41.243 [INFO ] [web.protocols.ScalarWebLoginProtocol] - Writing remote commands to /etc/openhab2/transform/scalar-c1e7152b-e879-4057-b3cb-f07c5d147f6a.map

2020-06-08 20:24:41.247 [WARN ] [mmon.WrappedScheduledExecutorService] - Scheduled runnable ended with an exception:

java.lang.NoSuchFieldError: bundleContext

at org.openhab.binding.sony.internal.scalarweb.ScalarWebHandler.initializeTask(ScalarWebHandler.java:187) ~[?:?]

at org.openhab.binding.sony.internal.scalarweb.ScalarWebHandler.access$1(ScalarWebHandler.java:160) ~[?:?]

at org.openhab.binding.sony.internal.scalarweb.ScalarWebHandler$2.run(ScalarWebHandler.java:152) ~[?:?]

at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) ~[?:1.8.0_252]

at java.util.concurrent.FutureTask.run(FutureTask.java:266) ~[?:1.8.0_252]

at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180) ~[?:1.8.0_252]

at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) ~[?:1.8.0_252]

at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_252]

at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_252]

at java.lang.Thread.run(Thread.java:748) [?:1.8.0_252]

Tried so far:

  • remove/ reinstall,clean cache, delete Pin association with TV, Delete .map, reinstall… same issue…

I guess it only something minor…but don’t know what else to try.

Thanks and greeitings…:smiley:
A

I have just tried to migrate from the Sonyaudio binding, which I’ve completely removed, to the Sony plugin to control my HT-ZF9 soundbar. The Sony plugin discovers it, but reports “Error connecting to Scalar Web device (may need to turn it on manually)” after accepting the Thing creation. Reviewing the Thing’s properties shows the correct IP, and curl is able to download the XML from the displayed Web URL.
I tested with the soundbar on and plugged in, but I never saw any kind of authentication request.
This is OpenHAB 2.5.5-1 with version 2.5.5.202004201157 of the Sony binding. Here’s an excerpt of the downloaded XML:

<device>
<deviceType>urn:schemas-upnp-org:device:MediaRenderer:1</deviceType>
<friendlyName>HT-ZF9</friendlyName>
<manufacturer>Sony Corporation</manufacturer>
<manufacturerURL>http://www.sony.net/</manufacturerURL>
<modelName>HT-ZF9</modelName>
<modelNumber>BAR-2018</modelNumber>
<UDN>uuid:00000000-0000-1010-8000-702605db8969</UDN>
<dlna:X_DLNACAP>playcontainer-0-1</dlna:X_DLNACAP>
<dlna:X_DLNADOC>DMR-1.50</dlna:X_DLNADOC>
<av:X_StandardDMR>1.1</av:X_StandardDMR>

Hi
I use this addon to start some light in the evening based on TV ON status. It has always been working fine with SimpleIP. However, since Scalar is working in the binding, the simpleIP seems to be sometimes broken (or doesn’t get upted)

That wouldn’t be a problem if the Scalar thing was working fine from the filebase config. It seems it works fine when defined via PaperUI, but if I define it manually in a sony.things file, it doesn’t work properly

Any idea how I can stabilize this ?

I still can’t reliably get the POWER status, either via simpleIP or via Scalar. With simpleIP, it is because it is simply not checked. There are queries sent periodicaly (like every 30s) to check for the volume or channel for example, but never for the power state :

25-Jun-2020 22:28:22.799 [DEBUG] [ab.binding.sony.internal.simpleip.SimpleIpProtocol] - Sending ‘*SEVOLU################’
25-Jun-2020 22:28:22.821 [DEBUG] [ab.binding.sony.internal.simpleip.SimpleIpProtocol] - Send ‘*SEVOLU################’ result: ‘*SAVOLU0000000000000000’
25-Jun-2020 22:28:22.824 [DEBUG] [ab.binding.sony.internal.simpleip.SimpleIpProtocol] - Sending ‘*SECHNN################’
25-Jun-2020 22:28:23.157 [DEBUG] [ab.binding.sony.internal.simpleip.SimpleIpProtocol] - Send ‘*SECHNN################’ result: ‘*SACHNN00000004.0000000’
25-Jun-2020 22:28:23.160 [DEBUG] [ab.binding.sony.internal.simpleip.SimpleIpProtocol] - Sending ‘*SETCHN################’
25-Jun-2020 22:28:23.525 [DEBUG] [ab.binding.sony.internal.simpleip.SimpleIpProtocol] - Send ‘*SETCHN################’ result: ‘*SATCHN000100CA4EE9####’
25-Jun-2020 22:28:23.528 [DEBUG] [ab.binding.sony.internal.simpleip.SimpleIpProtocol] - Sending ‘*SEISRC################’
25-Jun-2020 22:28:23.888 [DEBUG] [ab.binding.sony.internal.simpleip.SimpleIpProtocol] - Send ‘*SEISRC################’ result: ‘*SAISRCdvbt############’
25-Jun-2020 22:28:23.891 [DEBUG] [ab.binding.sony.internal.simpleip.SimpleIpProtocol] - Sending ‘*SECHNN################’
25-Jun-2020 22:28:24.605 [DEBUG] [ab.binding.sony.internal.simpleip.SimpleIpProtocol] - Send ‘*SECHNN################’ result: ‘*SACHNN00000004.0000000’
25-Jun-2020 22:28:24.607 [DEBUG] [ab.binding.sony.internal.simpleip.SimpleIpProtocol] - Sending ‘*SETCHN################’
25-Jun-2020 22:28:24.925 [DEBUG] [ab.binding.sony.internal.simpleip.SimpleIpProtocol] - Send ‘*SETCHN################’ result: ‘*SATCHN000100CA4EE9####’
25-Jun-2020 22:28:24.933 [DEBUG] [ab.binding.sony.internal.simpleip.SimpleIpProtocol] - Sending ‘*SEPIPI################’
25-Jun-2020 22:28:25.327 [DEBUG] [openhab.binding.sony.internal.AbstractThingHandler] - Checking connectivity to 192.168.0.7:80 - successful
25-Jun-2020 22:28:34.947 [DEBUG] [ab.binding.sony.internal.simpleip.SimpleIpProtocol] - Empty reponse (or unsupported command): ‘*SEPIPI################’

Any idea how to get this working ?
Thanks

is it possible to query the play, pause and stop status of my sony xe9305? if you e.g. press in the netflix app.

thanks :slight_smile:

@tmrobert8 is there any way to restart CEC/HDMI synchronization?
I have this problem, that I always use my KD-75XE9005 connected via HDMIwARC to my Onkyo TX-RX820. So I have speakers set up to “System audio” instead of “TV Speakers”. Usually it works very well with my Xbox One X connected to Onkyo. However when I want tu use TV Android apps like HBO or Netflix, it happens that pretty often I’m loosing sound, so Onkyo don’t switch for some reason to its AMP and there is lack of sound.
As I discovered, the only way to fix that is to switch Sony TV to “TV Speakers” and then, after few seconds, switch back to “System audio”.
It usually fix the problem, but I was hoping to find some solution with your binding. I remember that with some previous version of your binding I made a rule for switching CEC sync to OFF and then switch it back to ON and this was pretty nice solution. Unfortunately I don’t remember which channel it was and also I can’t find this option with the current version, is there any?
Maybe you or someone else have some better solution for me to fix this issue?

@tmrobert8 as you have a lot of knowledge about the Sony REST API, I have a question where you might be able to help. I’m using the REST API in my own rules, directly adressing (without the binding, just the get/post requests). It’s working all fine, no issues.
However I wanted to get the information, which App is currently running. In the docs I see the call to start an App, but I see no get request detailing which App is currently active, running and on front. Do you know how to get this information and if yes, which request & endpoint you are using.

Thank you :slight_smile:

Perhaps you could share your rules so others can learn from them? It would be great to see you post this in a new thread as often peoples scripts and rules can inspire new features.

This would also make it easier for you to get a more useful reply.

Ähhm sorry?! If you have invested 5 seconds more in looking at my profile and my posts rather then writing the above comment, you would know that I support this forum with good posts and help other members… Always great to have such a member like you! :slight_smile:

But to answer your question, it’s the function that I posted into OAuth thread. You can find it by looking at my recent posts…

Edit: thanks for editing your original message…

My apologies, I made a mistake when looking at your profile. And if you did post it then I would also like to say thank you.

Accepted, thank you.

As said before, it is a function originally posted in the OAuth 2.0 thread with just a small modification. Basically you hand over to the function the endpoint and the post payload detailed in the Sony Bravia docs.
The question that I raised was, that I can’t find a request for the currently actively running App. This would be nice, because then I could display it also in OH. For now I can only start an, see which apps are installed etc, but no where I find the current running app in the foreground. Therefore @tmrobert8 might know it, because he is working on the REST API quite some time and knows a (unofficial) solution?

Here is the code that I use. Please note that the PSK is replaced by **** and as an example I just post the rule for on off the TV. You can obviously improve this code, e.g. putting it all in one function, put in a flag so that no duplicated commands are sent leading to strange behaviour etc etc…

Rule to call the function

// Query for TV Power status from TV API directly
rule "Sony TV an aus schalten toggle"
when
  Item Sw_v_sonyTV_onoff_toggle received command
then
  St_v_sonyTV_err.sendCommand("Starting start/shut down TV")
  St_v_sonyTV_err_bol.sendCommand("false")
  Dt_v_sonyTV_on_energy_API_updatestamp.postUpdate(new DateTimeType())

  val endpointExt = "system"
  var queryBody = ''

  switch(receivedCommand) { 
      case OFF: {
        queryBody = '{"method": "setPowerStatus","id": 55,"params": [{"status": false}],"version": "1.0"}'
        St_v_sonyTV_err.sendCommand("Starting shut down TV")
      }
      case ON: {
        queryBody = '{"method": "setPowerStatus","id": 55,"params": [{"status": true}],"version": "1.0"}'
        St_v_sonyTV_err.sendCommand("Starting start TV")
      }
  }

  val response = querySonyTVAPI.apply(IP_SONYTV + BASE + endpointExt, queryBody, readResponse)
  // logWarn("SonyTV", "Query Status: " + response)

  if (response.startsWith("ERROR")) {
    St_v_sonyTV_err_bol.sendCommand("true")
    return
  }
  St_v_sonyTV_err.sendCommand("Finished status query")
end

Function itself

val Functions$Function1<HttpURLConnection, String> readResponse = [ connection |

  val responseCode = connection.responseCode
  if(responseCode != 200){
    return "ERROR " + responseCode.toString;
  }

  val StringBuffer sb = new StringBuffer()
  val BufferedReader br = new BufferedReader(new InputStreamReader(new BufferedInputStream(connection.getInputStream())))
  var String inputLine = ""
  while ((inputLine = br.readLine()) !== null) {
    sb.append(inputLine)
  }
  sb.toString
]

// send the command and get the answer back
val Functions$Function3<String, String, Functions$Function1<HttpURLConnection, String>, String> querySonyTVAPI = [ endpointURL, queryBody, readResponse |

  try {
    val endpoint = new URL(endpointURL)
    val HttpURLConnection connection = endpoint.openConnection() as HttpURLConnection
    connection.requestMethod = "POST"
    connection.setRequestProperty ('X-Auth-PSK', "****")
    connection.doOutput = true
    connection.setDoInput = true
    connection.setConnectTimeout(30000); //set timeout to 30 seconds

    val OutputStream os = connection.getOutputStream()
    val OutputStreamWriter osw = new OutputStreamWriter(os, "UTF-8")
    osw.write(queryBody)
    osw.flush()
    osw.close()
    os.close()

    val response = readResponse.apply(connection)

    return response;
    } catch (java.net.SocketTimeoutException e) {
        return "ERROR TIMEOUT " + e.toString;
    } catch (java.io.IOException e) {
        return "ERROR IOException " + e.toString;
  }
]

Hey unfortunately it is not possible (anymore). It used to work once but Sony changed something and broke or abandoned it. Refer to this post here.

Best regards

1 Like

Ahh cool thanks for the post. Yeah I saw the same description in the binding docs on github, butit wouldbbe interestingtto wwhich API call this is referred to (though probably broken atm).
However very hacky solution would beto have a background deamon on the TV, aaccessing it via the Android functions… But that’s not a good design and approach

Hi,

I’ve installed the binding and give me this:

changed from UNKNOWN: Initializing … to OFFLINE (COMMUNICATION_ERROR): Forbidden

I put the correct accessCode in the thing…
Can someone point me a direction?

Best Regards,
Fernando Gomes

I recently bought a BDP S-6700 and I’m trying to enable the binding. It seems that there are some problems with the authentication for IRCC protocol. The device never shows the code and the binding remains in OFFLINE with error ‘forbidden’. I tried with curl to start the registration process with

http://xxx.xxx.xxx.xxx:50002/register?name=name=Openhab&registrationType=initial&deviceId=Openhab01&wolSupport=true

and the device correctly shows the code but when I try to put the code in the binding I still have the same error.

Any suggestion?

I’m having the same forbidden error trouble. It seems my TV is upset with 3 request types;

  • getSystemInformation()
  • getWolMode()
  • getPostalCode()

Looking at the logs it responds to the request with an auth error page.

29-Sep-2020 21:24:28.507 [DEBUG] [org.openhab.binding.sony.internal.net.HttpRequest ] - 8 * Sending client request on thread OH-thingHandler-14
8 > POST http://192.168.102.161/sony/system
8 > Accept: application/json
8 > Connection: close
8 > Content-Type: application/json
8 > User-Agent: OpenHab/Sony/Binding
8 > X-CERS-DEVICE-ID: MediaRemote:00-11-22-33-44-55
8 > X-CERS-DEVICE-INFO: OpenHab/Sony/Binding
{"id":4176,"method":"getSystemInformation","version":"1.0","params":[]}

29-Sep-2020 21:24:28.600 [DEBUG] [org.openhab.binding.sony.internal.net.HttpRequest ] - 8 * Client response received on thread OH-thingHandler-14
8 < 403
8 < Connection: close
8 < content: text/html; charset=ISO-8859-1
8 < Content-Length: 75
8 < Date: Tue, 29 Sep 2020 11:24:28 GMT
{"auth_url":{"default":"http://192.168.102.161/sony/webauth/auth_default"}}

29-Sep-2020 21:24:28.602 [DEBUG] [rnal.scalarweb.protocols.AbstractScalarWebProtocol] - Communication error executing method getSystemInformation() on service system: Forbidden
java.io.IOException: Forbidden

Time to keep digging.

I have a X750H TV and cant get it to communicate with the Binding. My old Sony TV talks just fine, but my new one will not talk on any of the binding options. I have Simple IP commutation trued on, and it dose talk to the Sony Simple IP test app.

Any Ideas would be appreciated.