I am Vera Plus refugee and moved over my whole system to openhab.
With the help of all the documentation and this forum I was able to get more things working than I even imagined when I started - so thank you for that!
But now I have hit a road block.
I am trying to create a ircc thing to control my (rather old) Sony BD Player BDP-S490.
I was hoping I could detect wether it is starting a BD to automagically turn off the lights.
When I try to create a thing from PaperUI discovery menu the player is never found although it is turned on. So when I use āadd manuallyā the config menu is presented, I fill in IP and MAC but I am missing the map file.
I created that manually from posts I found in this thread so I could close the config dialog.
The thing created is always in state of
OFFLINE - COMMUNICATION_ERROR Error connecting to IRCC device (may need to turn it on manually): java.net.ConnectException: Connection refused (Connection refused)
This is in the log
2019-08-18 12:28:32.617 [INFO ] [nding.sony.internal.ircc.IrccHandler] - Attempting connection to IRCC device...
2019-08-18 12:28:32.623 [DEBUG] [ding.sony.internal.ircc.IrccProtocol] - WOL packet sent to 54:53:ED:5C:5C:B2
2019-08-18 12:28:32.715 [DEBUG] [inding.sony.internal.net.HttpRequest] - 1 * Sending client request on thread OH-thingHandler-3
1 > GET http://192.168.2.102
1 > Connection: close
1 > User-Agent: OpenHab/Sony/Binding
1 > X-CERS-DEVICE-ID: MediaRemote:00-11-22-33-44-55
1 > X-CERS-DEVICE-INFO: OpenHab/Sony/Binding
So here it goes:
should the BD player be discovered automatically?
what is the correct format for the URL (I tried with/without http and port :50002)?
how do I discover the right access code (is set to RQST right now, had the player in listening mode for control apps in itās network settings menu)?
Any help is greatly appreciated!
EDIT
Out of the blue after one day (!) a thing was discovered after I restarted OH (BD player was off at that time, strange).
Now in PaperUI the thing states
OFFLINE - CONFIGURATION_ERROR 403 - Forbidden
On the Config page in PaperUI everthing was prepopulated (IP,MAC), only access code is still on RQST.
Any ideas how I can get hold off a valid access code?
Hmā¦ i canāt find it eitherā¦ maybe weāre again facing the bug where TV doesnāt respond with this channel unless you turn on the TV, and then discover the thingā¦
perfect, thatās the trick. After re-discovery there is the channel group Audio, which includes volume and mute. @tmrobert8 Is that a bug or āit is what it isā?
Which switches are you talking about? The app switches or the TV channel switches (or possibly both)? Iām contemplating putting the tv channel switches back as an ease of use thing. If people want the app switches - I can switch that back as well as long as you understand itās not really a switch since I canāt detect when something is running or not (unlike the TV ones).
Yeah - I wish I knew what conditions the TV has to switch a port. None of mine switch ports but many people have mentioned it. Unfortunately there is nothing I can do about that.
Yeah- blurays are a bit of a pain in that they donāt send out constant discovery messages. The forbidden means that you need to pair it. Hereās the steps Iād do at this point:
Turn on the bluray player and make sure itās on the home menu (none of the sub menues)
In OH for the thing config, change āRQSTā to some 4 digit number (doesnāt really matter - 0000 will do).
Hopefully, a 4 digit number will then appear on the bluray screen. Change the thing config to that number and it should pair itself.
If that doesnāt work - Iāll need a copy of your log to see whatās going on (see the first post on how to create a separate sony log to send to me).
Interesting - I never knew the audio group would be affected by the device power. Apparently it is and would probably be the issue (Iāll run a test on my end to confirm). However, I will say that the next version will formally implement my evil scheme of discovery/creating custom thing types for devices and any ātv must be onā stuff should go away if the device information was already approved (more on all that later).
Thank you @tmrobert8 for your reply!
I made some progress.
I did exactly as you suggested but no access code popped up.
Then I browsed the log and found the line
X-CERS-DEVICE-ID: MediaRemote:00-11-22-33-44-55
I used the number string as access code and went to the BD player menu
Network Settings > Media Remote Device Registration
started the registration and the thing went online! Great!
Alas, the 2 items I then configured (switch for āpower on/offā and a string for āIRCC Viewing Channel Sourceā donāt seem to work.
The log states a problem
2019-08-19 15:19:55.895 [DEBUG] [y.internal.transports.SonyAuthFilter] - Trying to renew our authorization cookie
2019-08-19 15:19:55.971 [DEBUG] [y.internal.transports.SonyAuthFilter] - Could not renew authorization cookie: java.net.ConnectException: Connection refused (Connection refused)
I guess Iām not compltely there yet
Every time i flip the switch item mentioned above I get this
Sorry yes i mean both app switches and the TV channel switches.
Maybe you could do the dicovery in the background and assign the new discovered port to the thing.
That way the deviceAddress in the thing definition could be just the ip address, eg. ā192.168.1.11ā instead of āhttp://192.168.1.11:27282/sony/webapi/ssdp/dd.xmlā where the regularly changing port is defined.
I think this would spare this thread some inquiries about things that do not go online.
Iād appreciate a log on that (preferably the whole log so I can see the URLs the discovery packets are sending as well).
Thatās not an issue for you and can be ignored. Simply means that the device doesnāt have the scalar/rest API defined and we arenāt renewing the auth cookie because of that. However, your version of IRCC doesnāt need auth cookies (uses auth headers instead) so it can be fully ignored.
That says that the disc you have in doesnāt contain any metadata on it and the āviewingā fields wonāt populate. Thatās actually the first time Iāve seen that and Iāll make some logging adjustments in the code but there isnāt much I can do about that (since the player is stating it has no meta data to work with).
And by switch you mean the āpower switchā? If thatās the case, I need to see a different part of the log where it tries to post the change (the log above simply is the polling part).
Iāve tried doing that various times but it just doesnāt work across all devices (and is unbelievably complicated code wise).
The issue is that
the discovery packets the device sends have critical information in it
some devices donāt send the discovery packets regularly.
So I canāt have a simple IP configuration option (the thing would remain offline until a discovery packet is sent to get the correct port number). This would happen irregularly and some devices only send that packet when they get turned on (so any restart of OH would require you to turn on your devices as well - very inconvenient).
The second option is to initially set it up with a port and then try to monitor discovery packets for a new port number. Problem is that you fall into the same trap in that your .things file defines a port that was valid when you created the file and the device wouldnāt come online until it receives the correct port from the discovery packet.
The only real option would be to start saving the last port used (which you can then use at startup) and run a whole parallel discovery process for port changes. Just a ton of code Iād have to create - which Iām not sure I want to do (Iāve already invested waaaay to much time into this).
So Iām going to be messing with a few channel ids (mainly the input status ones). Along the way, Iāll probably re-add back the TV channel switches (atleast the digital ones [5.1, 20.5, etc] - sony broke the analog ones [the api returns all possibilities rather than those it found]).
Question for you all - I may add back some switches for apps (but still keep the command channels since there are devices that support more than stop/start). Note that the switch will likely not be live (ie it will not turn off when you end the app).
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
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.
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:
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:
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.
getPlayingContentInfo() yep - thats correct. And the binding should properly update the associated channels on the poll when it retrieve that information