Sony Devices Binding

Tags: #<Tag:0x00007f433a2f8760>

Or you could try my “solution” to a similar, if not the same problem as well:

Thank you for hint. will try this :slightly_smiling_face:

Sorry for my late reply @tmrobert8. Here’s the log Sony debug.txt (251.5 KB).

I tried several times to switch off and on the device and everytime the scalar web thing goes correctly online and the ircc thing stays offline. If I edit the thing with some code it goes correctly online.

Are there any examples of item definitions and a sitemap for this binding?
I have a Sony TV which I have successfully linked to openhab using scalar web and I can control the power and volume easily. I am struggling to understand how to control the TV input e.g. dvb, hdmi1, hdmi2.
I used to have a selection dropdown for my old TV in the sitemap like this:
Selection item=TV_Source mappings=[DVB=“TV”, HDMI1=“HDMI1”, HDMI2=“HDMI2”]

I tried connecting this up to avContent#tm_source-main however it wasn’t correct. Is it possible to get a similar thing working using this binding? If so are there any examples of how to do this?
Thanks

I used the Sony binding some time ago without any problems. Now I have installed it and only get a forbidden error on my Sony tv and scalar, although the access code is correct and the Sony tv is the same like last time.
Here is the debug log: http://s000.tinyupload.com/index.php?file_id=00543819561068370414

Is there an obvious mistake here somewhere?

Hi @tmrobert8, welcome back
this is my script I’m using to convert the code for my bindings from 2.5.x to 3.x on a regular basis, because I’m still developing on 2.5.x.

find . -name *.java -exec sed -i '' -e "s/org.eclipse.smarthome.core.library.unit.SmartHomeUnits/org.openhab.core.library.unit.Units/g" {} \;
find . -name *.java -exec sed -i '' -e "s/tec.uom.se.unit.Units/org.openhab.core.library.unit.Units/g" {} \;
find . -name *.java -exec sed -i '' -e "s/, SmartHomeUnits/, Units/g" {} \;
find . -name *.java -exec sed -i '' -e "s/org.eclipse.smarthome.core/org.openhab.core/g" {} \;
find . -name *.java -exec sed -i '' -e "s/org.eclipse.smarthome/org.openhab.core/g" {} \;
mvn spotless:apply

Syntax is for Mac, other distributions have a slightly different syntax for the find command.

This is a good source of information: Guide: Binding development changes for openHAB 3 (from 2.5.x)

or as complete build script also copying the code (path and binding folders need to be adjusted):
buildpush.sh.txt (1.3 KB)
convert_v2_v3.sh.txt (971 Bytes)

  • apply mvn spotless
  • build v2
  • copy code to v3 directory
  • build v3
  • copy outputs to ~/Dev/myfiles/xxx (my private repo) & push

I keep pom.xml separate for both versions (this includes version number 2.5.12 vs. 3.1.0).

Most important

  • Namespace org.eclipse.smarthome.core has been renamed to org.openhab.core
  • ESH-INF has been renamed to OH-INF
  • Code changes are required around @NonNull (OH3 environment is more strict), e.g. map.get() and gson.fromJson are now @Nullable - this requires some code changes, backward compatible with v2
  • SmartHomeUnits has been renamed to Units, references to tec.uom.se.unit.Units have to be removed
  • There are some deprecated functions, which need to be replace
  • Usage of org.apache.commons needs to be replaced by native code

In general not a big job. This scripts help to to keep v2.5 and v3 codebase in sync. Working on 2.5 and transforming to 3 prevents from using new features of v3.

Adapt log filtering (optional): Log filtering in OH 3

Please make a 3.0 build of this binding so we can get testing :wink:

am in, also need it. Please :slight_smile:

I managed to figure this out, incase it helps someone else here is what I did.
Sitemap:
Selection item=Bravia_Input mappings=["extInput:hdmi?port=1"="HDMI1","tv:dvbt"="TV"]

Item:
String Bravia_InputSource "Input Source [%s]" <television> (TV) { channel="sony:scalar:8ab6ba3a:avContent#sources" }

@tmrobert8

BTW, i really appreciate your work in creating this binding. I don’t use much of the functionality but having the ability to know when it turns off the instant it turns off works really well for turning lights on and getting us a safe and lit path to the bedroom for sleep when TV time is over. Again, thanks.

I’m also ready for testing on 3.0 but don’t know how to install/build this addon on 3.0. Can someone help with this ? I see testing build here sony.binding but my system only have 203MB file “/usr/share/openhab/addons/openhab-addons-3.0.0.kar”. How to install this for testing ??

I’ve started to migrate the Sony binding code to openHAB 3.0 and followed the instructions provided by Developer Guide | openHAB with use of the IntelliJ IDE. You don’t need to build or install all addons as provided by the kar file. Just download and build from the Sony binding code.

I don’t think that the code on the Jenkins server is ready for testing, but you might give it a try. I had to make several changes for a successful built. Especially, I had to disable all errors from NULL annotation checks. Also, there is still a runtime issue that is presumable caused by the replacement of Jersey client by JAX-RX whiteboard. I’ve started solving this issue (rather a hack inspired by how this issue was tackled for other bindings) but it will take some days to complete. I’m happy to share any further experiences when available.

Note that my work on this topic is currently more a personal learning task with no intention to contribute to the official code. But this might change depending on the pace the official 3.0 binding is being developed and the need for support.

2 Likes

Hi andan,
is there any chance to get your early build?

I’m happy to share my build & code when it successfully runs in my envrionment (might take a few days).

However, this build should be viewed as a (hopefully) temporary workaround rather than an early version of a final release. As I’ve already mentioned, this might change when I’m getting more familiar with the binding development and particularly the Sony binding. I have some experience with the Sony API which might help me to actively contribute to the official source (I wrote an Android app to control my TV as a kind of poor man’s replacement of the discontiuned Sony TV SideView app).

Hello @andan,

I would like to test the code for you aswell.
Let me know when you’re finished with building and testing!

Hopefully I didn’t raise too high expectations.

At least I managed to get the DIAL thing working, meaning my TV is shown online in my dev environment. This should indicate that I’m on the right track. I’m now investigating an issue with the SCALAR thing handler.

After further investigation:

  1. I have put the file name in thing config and it works: map file was generated!

  2. I have already the MAC address specified in the binding configuration. However after truning off my TV ( retryPolling is -1 or 6000sec), the SimpleIP thing goes to OFFILNE-COMMUNICATION_ERROR instead of OFFLINE. Therefore I think it is something with the binding itself as I can see that openhab WOL binding1 works and wakes up and turns on (non authentification) my TV.
    I can see from the previous post this issue has been already reported…but seems not final solution. And rebooting my TV has not helped :neutral_face:

I’ve finished a very early openHAB 3 version of the Sony binding that can be downloaded from https://github.com/andan67/openhab-addons-sony/releases/tag/3.0.0-alpha.andan.1.

This version is based on the latest 2.5 release https://github.com/tmrobert8/openhab-addons/releases/tag/2.5-1201-2 and includes following major changes

  • Applied standard openHAB 2.5 -> 3.0 binding changes (partially based on scripts)
  • Replaced Jersey client by JAX-RX whiteboard by use of injected ClientBuilder reference

I had to perform some other changes and workarounds to solve some compiling and runtime issues (might be partially related to my specific environment):

  • Set all null annotations checks to warn level
  • Set default (hard coded) endpoint of IRCC service to ‘sony/IRCC’ instead ‘sony/ircc’. The lower case name resulted in ‘Not found’ error for my TV.
  • Some changes of the (deprecated and to be replaced) LoggingFilter

My initial tests show that the IRCC service seems to work fine. However, I can’t get the scalar service to run stable. It seems that any unauthorized/forbidden error brings the service down. From the debug logs I conculde that there is an issue with providing the cookie (my TV only supports the normal authentication) for calls that need authorization. As I observe the same behaviour with the 2.5 version of the binding running under openHAB 2.5, I assume that the cause of this issue is not directly related to the migration changes. Maybe I haven’t yet understood how to properly configure the discovered services.

So if you have a working 2.5 binding and want to migrate to openHAB 3 in short-term, you might consider to give my version a try. In this case, it would be great if you could provide any feedback.

I will continue to work on my personal binding as time permits. But for now I cannot commit to contribute to an offiical migration.

3 Likes

Hello @andan,

I’ve downloaded your binding and uploaded it into my openhab.

As far as I can see in 5 minutes everything is working fine, the TV is connected (SimpleIP and Scalar) and I can control it the same way as before. Although the TV is throwing some connection refused errors. But that looks more like a problem in the TV then in the binding. Because the port for the connection seems to change every now and then…

Like I said, I’ve just tested for a short time. I will test it for a few days and let you know if I find something!
For now, many thanks for updating the binding! :smiley:

Regards,
Jordo

Thanks @andan. I have downloaded and installed your build and was able to discover, add, and control my Scalar TV device. The 2.5 version of the binding was also working for me prior to upgrading to OH3.