Sony Devices Binding

IMO, this should be handled by the user itself (if needed) in rules or somewhere else, as that way there’s no overhead on the binding part to map/do all kind of stuff just to get switches if one does not need that functionality (that obviously isn’t up-to-date - switch can’t know when it’s on and when off)… also, this will only open possibility to break things on your end once sony fixes things on their end. if someone needs a switch, it is possible to create one. I see your binding solely as a communication interface between sony device and openhab…

no hard feelings to anyone… just my two cents on the topic :slight_smile:

i personally don’t need a switch. but i also did not succeed discovering the tv channels to create a selection for example. if that is doable without to much of an effort i think that’s the way to go.

If i switch on HDMI 1 then HDMI 4 ARC is selected.

Is that with the test version you are using or the real version? If test - respond via our PM chain

I had a look into this some more and think i found a promising solution for that.
Do you already know the auth method pre-shared key (PSK)?
In the Sony documentation you’ll find a description how to set up the tv and an .html file with some supported http-requests in it. I added some (for me) interesting functions to play around an attached the file for reference here in this post. After the download you have to change the file back to html.
displaycontrol.txt (4.5 KB)

With it i can control the tv just with the IP and the pre-shared key (PSK). No port or whatever needed.
Another good thing is that you do not have to register the tv with the binding anymore (four-digit code). I unregistered the binding on my TV but the html file still works fine. Maybe you could add this auth method to the binding, since i assume this will be much more robust (because regular port changes don’t matter anymore) when this binding is merged and used more often in the future. Since you have a working discovery for the devices i suppose this is sufficent to find out if the thing can be declared as “online” in openhab.

Sadly it really seems that the api is “broken” in some way because there is really no way anymore to find out which app is running.

getApplicationStatusList() just shows three applications:

-- appControl.getApplicationStatusList() --
status: 200
{
  "result": [
    [
      {
        "name": "textInput",
        "status": "off"
      },
      {
        "name": "cursorDisplay",
        "status": "on"
      },
      {
        "name": "webBrowse",
        "status": "off"
      }
    ]
  ],
  "id": 1
}

getPlayingContentInfo() unfortunately just says illegal state when an app ist running

-- avContent.getPlayingContentInfo() --
status: 200
{
  "error": [
    7,
    "Illegal State"
  ],
  "id": 1
}

However tv channels are reported reliably

-- avContent.getPlayingContentInfo() --
status: 200
{
  "result": [
    {
      "uri": "tv:dvbt?trip=9999.441.41104&srvName=BBC HD",
      "source": "tv:dvbt",
      "title": "BBC HD",
      "dispNum": "024",
      "tripletStr": "9999.441.41104",
      "programTitle": "Global with Matthew Amroliwala",
      "startDateTime": "2019-08-22T17:00:00+0200",
      "durationSec": 1800
    }
  ],
  "id": 1
}

Yep - the scalar binding supports PSKs and really your file is doing nothing different than what the scalar binding is doing under the scenes (but in much more detail). In fact, if you pull up the sony webpage you can pretty much play around with all that - simply load your device file from userdata/sony/definitions/capabilities) and you’ll see everything your TV supports and can play with it interactively (a much more powerful version of the page you put together because you can also interactively specify parameters).

The problem isn’t the port on the individual calls. The problem is the port is required during discovery to retrieve the descriptive information to setup everything the binding needs (to discover all that information you have in the file). Once I discover all that - the port isn’t needed anymore. Having said that - I don’t think I ever thought all that through and maybe I can come up with some solution that is easier.

As for your edits:

  1. getApplicationStatusList() that is not applications in what you think. That is internal sony application status and will tell you various states the sony internal applications are in. What you want to use is getWebAppStatus but you’ll notice that it returns stopped on everything. Sony broke that when they broke DIALs implementation as well.
  2. getPlayingContentInfo() yep - thats correct. And the binding should properly update the associated channels on the poll when it retrieve that information
1 Like

Thanks for your reply.

I also noticed that when i have the thing set up with the 4-digit auth i can also fill in the PSK and the binding works. However if the binding is not registered in the TV the thing is reported as “offline” and nothing works with the binding. I guess thats just the way how Openhab works. However the sony html-page is running fine and IMO therefore the binding should do as well.

It would really be nice if you found some convenient solution for that. :slight_smile:
I would imagine a thing definition with just the IP adress and the PSK. Your already working discovery does the magic with finding the port at thing initializiation in the background, getting the info it needs about the TV and then just keeps working with the PSK no matter if the port changes after that or not.

Best regards

That must have broken when I rewrote the authorization stuff. I’ll look into getting PSK fixed for the next version.

1 Like

I knew it wasn’t going to be that simple - there is generally a reason (that I usually have forgotten) why I did things a certain way. So your bravia varies the discovery port but uses port 80 for the rest API. My bravia doesn’t vary the discovery port but uses port 8080 for the rest api (which I find in the discovery packets). Likewise, the websocket devices (my DN1080) uses port 10000 [which is also discovered in the discovery packets].

Likewise, when you don’t use PSKs (which you really shouldn’t because it’s a bad security practice and I’m betting will eventually go away), the specific header (X-CERS-something) is specified in the discovery packets as well (a mistake MANY other sony implementations make - assuming it’s always the same header value which in fact it’s not for some devices).

While all this works for your specific device, it doesn’t work for all devices and that’s what I have to worry about.

So I’m back into that catch-22 that I need those discovery packets before going online and can’t simply have a IP address easily.

I’ll continue to think about this - but I still don’t see a clear, easy solution

I can definitely confirm I broke PSK with all the auth changes but the next version will restore that functionality

1 Like

Sounds great :slight_smile:

If i use that function on my tv, the response only shows if the internet browser is opened and if yes which website (url) is opened, like here. Not a list of my apps which all have the status stopped.

Do you know if there is a Sony forum (or similar) where we can ask the API developers if it is intended that the status of apps can not be retrieved? And if it is gone for good or if it is planned to reimplement it with a later API version? You think this forum is a good place to start? Then i could drop a question there.

Yep - but a long time ago, it also showed you which app was foreground (I always assumed that the apps were considered webapps). That assumption may be what sony ‘fixed’ and thus broke everything (including the dial side).

The only sony developer was @freke and he hasn’t responded for a very long time (plus he was on the audio side I believe). You can try the forum but I’m giving you about a 99% chance of getting a response like “APIs are for professional developers only” (in other words, you’d have to pay for access to something). Atleast that was the response I got a few times a few years ago - who knows however, maybe they are more open now…

it’s the same on both. i did some further investigation.
if i press the “sources” button on the tvs remote it shows my PS4 as “Player 1”. Is there a way to switch the source to this channel? the simple ip item for input does not change if i choose this. You could suggest that i just use the hdmi port the ps4 is plugged into but the great thing about using the “player1” menu entry is that it starts the ps4 via arc so i can directly use it with the tvs remote for watching blu rays for example.

And i figured out why my volume does not work.
I connected a 3,5 mm cable so i must control the headphone volume but i cant find the channel for this.

With simpleip - there is no way to do that. The API only allows setting of physical ports

The ONLY way to control headphone volume is through the scalar thing (which exposes both the speaker and headphone volume levels in the audio service). All other APIs do not have visibility to that

i am happy to go with scalar. i just could not find the dedicated item in the scalar thing to change to Player 1. Headphone Volume is set with scalar now, thanks! :slight_smile:

Edit:
Could you name the item i need to use for sources?
i tried playing source but it only gives back extint:hdmi for every hdmi - non specific.
i can find the input ps4 uri and status item but when i link it to items and read the status with rest api it says “no content”.

I know why i had trouble finding the headphone volume in the past.
It just simply did not show up.
i can remember on older bindings there was an option like “hide audio settings” in the thing properties and i had to turn that off after every restart. now there is not such an option but the audio section is hidden in the scalar thing.
if i press “show more” i just see:

application control
av content
video screen

maybe i can help you adress this bug.
regards

jonas

restarting my OH-system did bring them back.
tried restarting my tv but they are still here.
strange behaviour. i cannot reproduce it atm.

EDIT:
Today the Volume Section is gone again. It does not matter if the tv is on or off.
Even a restart did not bring them back.

Hey Tim, sorry for asking but do you have an ETA for the next version with the repaired auth?
Thanks in advance

Hi all,

I was happily using version 2.2 of this Mod (running Openhab on a debian stretch VM).

Now I got my Raspberry and did a fresh install of openhabian. I tried the 2.4 and 2.5 jar but I always get this in the log:

2019-09-18 21:36:04.456 [ERROR] [org.openhab.binding.sony ] - FrameworkEvent ERROR - org.openhab.binding.sony

org.osgi.framework.BundleException: Could not resolve module: org.openhab.binding.sony [205]

2019-09-18 21:36:12.133 [WARN ] [org.apache.felix.fileinstall ] - Error while starting bundle: file:/usr/share/openhab2/addons/org.openhab.binding.sony-2.4.0-SNAPSHOT.jar

org.osgi.framework.BundleException: Could not resolve module: org.openhab.binding.sony [205]

Any advice?