Sony Devices Binding for OH3

I’ve found the root cause of the issue reported by @Sebastian1 and @mjcumming.
It is related to a recent dependency upgrade in OH 3.2 to the XStream 1.4.18 library that handles XML messaging for the IRCC service.

I’ve created a new binding version 3.1.3 which I hope will fix the issue
Release openhab-addons-sony-3.1.3 · andan67/openhab-addons (github.com)

@Sebastian1 /@mjcumming Please try this version and let me know if the issue is resolved for you.

Thank you for the quick help. Until everything works great and gives no error message.

Works great - thank you!!

I have successfully declared my Sony X8500E in the textual format as below:

// Things file
Thing sony:scalar:KD-55X8500E "Sony KD-55X8500E" @ "Livingroom" [ 
  deviceAddress="http://192.168.0.215:35224/sony/webapi/ssdp/dd.xml", 
  irccURL="http://192.168.0.215:35224/sony/webapi/ssdp/dd.xml", 
  accessCode="RQST" 
]

// Items file
Switch Livingroom_TV_Power "Power [%s]" <switch> (gLivingroom_TV) { channel="sony:scalar:KD-55X8500E:system#powerstatus" }
String Livingroom_TV_IRCC_Command "IRCC Command" (gLivingroom_TV) { channel="sony:scalar:KD-55X8500E:system#sysCmd" }
Dimmer Livingroom_TV_Volume "Volume [%d]" <soundvolume> (gLivingroom_TV) { channel="sony:scalar:KD-55X8500E:audio#volume-speaker" }

Now I can turn the TV on/off and adjust the volume, but I don’t know how to switch the inputs (HDMI1, HDMI2, TV…). Can someone tell me how to do that please?

The input can be selected by setting the playing content in form of an uri that denotes the (physical) type of input source and further parameters like HDMI port or tv channel.

There are various channels that allow setting the content uri and thus switching the input:

avContent#tm_source-main

This channel can be used to directly switch to a specific input source. It internally holds state options for all avaiblable input sources along with title name if available (used as UI labels). Examples state values are:

extInput:hdmi?port=1 (HDMI 1)
extInput:scart?port=3 (AV)
tv:dvbs

avContent#cn_cmd select

This channel command selects the content (uri) defined by a browing process through the channels: avContent#cn_parenturi, avContent#cn_childcount, avContent#cn_idx, avContent#cn_uri as follows:

  • Set the of main type of the source (the parent uri) through the channel avContent#cn_parenturi (e.g. tv:dvbs, extInput:hdmi)
  • The channel avContent#cn_childcount will show the number of contents (channels, ports) for this source
  • The desired content can be set by a (0-based) index through avContent#cn_idx
  • avContent#cn_uri will then show the uri for that index
  • Sending select command to avContent#cn_cmd will actually switch to the selected content (e.g. extInput:hdmi?port=1for the HDMI 1 port

avContent#ps_channel-{tv_source}

These are preset channels for the various tv sources that allow an easy switching to tv channels (plus filtering and ordering options) that are preset.

I hope this info helps to get started. Please also have a look into the README file for the scalar service which provides much more details (see new documentation section in initiial post).

1 Like

Just to note that the binding can now be directly installed from the community marketplace (requires OH 3.2M3 or higher).

This will be the prefered and potentially single supported release channel for this binding in the future.

Please post any issues with this release in the Sony Binding marketplace topic

2 Likes

@andan

I removed the jar from the addons folder and installed it from the marketplace - all works great. Thank you.

Works good for me - Thank you.

One question: is it possible to Pause/Play Netflix etc?
I can start and close Netflix with “App Netflix Status”

Hello,

if I’m not mistaken, I do this on my Sony Bravia tv using the button codes (AAAAAgAAAJcAAAAaAw== for play and pause). The channel is called IRCC channel.

Oh yes and I have now also switched to the marketplace and there seems to be no problems. Thanks!

have looked again, there is still a better variant, there went with me last time not yet, but now already. avContent#pl_cmd-main, here you get even a selection back like play, pause, etc…

once we are there :smiley:
is there actually a nicer variant to start an app than with the respective channel of the app? if I do not want to make a separate button for each app, I always have to go through a dummy and a rule. But the problem is that I never see which app is currently open when I work with the original remote control. Does anyone here have a tip on how I can improve this?

I guess what you are asking for is the ability to identify the status of an app through a channel (i.e. whether it is active or not). According to the original author (see README) this is not possible. So it seems that you need to implement your own logic to keep track of the state.

Unfortunately it is true, that this is not possible through the sony rest api anymore.
This function used to report the active application, but this stopped a few years ago and never came back. In the documentation i also do not find another rest api call that could do the job or be the successor of the above.

However there is at least one way, but i am sure you won’t like: I installed Automagic (a tool that is like tasker) on my Android Bravia TV. Automagic development is stopped, but because of that it is free and of course still works. There you can create a flow that triggers on startup of certain apps that you can choose (even the start page, which was afaik not possible through the sony rest api in the past) and sends the active app via http request to an openhab item. From there i have OH rules that react on the changes.

But please beware that Automagic was never made for Android TV, so expect glitches in the UI and the permission management that can be a job stopper. However i succeeded somehow a few months ago :slight_smile:

Maybe another possiblity is to use ADB. Looking at the ADB Binding documentation it supports:

|start-package |String |Run application by package name|
|stop-package |String |Stop application by package name|
|current-package |String |Package name of the top application in screen|

Maybe I try it out when i find some time…

1 Like

ok, thank you! I had also searched around in the Sony API list yesterday, but couldn’t find anything either. Had also searched for a way to use the google search via an OH input, but again no luck.

Hello,

I installed the addon according your documentation. Unfortunatelly, after installation I get the following error message:

2021-11-17 22:08:49.625 [WARN ] [org.apache.felix.fileinstall        ] - Error while starting bundle: file:/usr/share/openhab/addons/org.openhab.binding.sony-3.1.3.jar

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

  Unresolved requirement: Import-Package: javax.measure; version="[2.1.0,3.0.0)"

	at org.eclipse.osgi.container.Module.start(Module.java:444) ~[org.eclipse.osgi-3.12.100.jar:?]

	at org.eclipse.osgi.internal.framework.EquinoxBundle.start(EquinoxBundle.java:383) ~[org.eclipse.osgi-3.12.100.jar:?]

	at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundle(DirectoryWatcher.java:1260) [bundleFile:3.6.4]

	at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundles(DirectoryWatcher.java:1233) [bundleFile:3.6.4]

	at org.apache.felix.fileinstall.internal.DirectoryWatcher.doProcess(DirectoryWatcher.java:520) [bundleFile:3.6.4]

	at org.apache.felix.fileinstall.internal.DirectoryWatcher.process(DirectoryWatcher.java:365) [bundleFile:3.6.4]

	at org.apache.felix.fileinstall.internal.DirectoryWatcher.run(DirectoryWatcher.java:316) [bundleFile:3.6.4]

Any idea what is going wrong? I have installed OH3.1.

Kay

Hello,

This error can occur for OH versions less than 3.1 stable (e.g. 3.1 milestone builds). So please check your installed version and upgrade if necessary.

If this doesn’t help, you could try a previous binding version from Release openhab-addons-sony-3.1.0_20210518 · andan67/openhab-addons (github.com)

Andreas

Thank you. That solved the problem.

Hi! I just installed the binding from community marketplace and set up simpleIP. It works great when the TV is ON, but when I turn it OFF the log starts to be filled up with the following:

"2022-01-17 22:10:58.384 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'sony:simpleip:tv' changed from OFFLINE (COMMUNICATION_ERROR): Error connecting to device: not reachable to UNKNOWN: Initializing ...

2022-01-17 22:10:58.886 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'sony:simpleip:tv' changed from UNKNOWN: Initializing ... to OFFLINE (COMMUNICATION_ERROR): Error connecting to device: not reachable"

I tried the edit /srv/openhab-userdata/etc/log4j2.xml as stated on the OP (the file path is not correct in the OP I guess), and restarted OH but no effect, I get those errors in every 10 s. Could you please help me? What did I wrong?

It depends on Retry Polling parameter set up. See the first posts from the Aug 21 above in this thread

I’ve read it but maybe I don’t understand it correctly. I understand that the bindigs tries to connect every X sec. and gives an error if the TV is swiched off. There is no way the set up the bindig not to fill the log with unnecessary errors? (In other bindigs it is solved somehow that there is no error in log if the device is offline.)