Exec Binding to control Sony Bravia

Hi,

Full disclosure… I’m a noob. I have figured out how to control my Sony Bravia TV from the command line with a script and Now I would like to execute the commands in OpenHab2. Can someone please point me in the right direction

I created a switch item like below and accompanying sitemap but it does nothing .
Switch SonyTV “SonyTV” { exec=">[ON:bash /home/openhabian/SonyBraviaControl/remote.sh PowerOn] >[OFF:bash /home/openhabian/SonyBraviaControl/remote.sh PowerOff]" }

Problem number 2 is that the command to turn on the TV uses Ehterwake and that command only works when I run it as sudo. Any advice on that issue would be much appreciated too.

Thanks in advance!

I’d first confirm that the scripts work from a console using the same account that OH is running under, and then try:

Switch SonyTV “SonyTV” { exec=">[ON:/home/openhabian/SonyBraviaControl/remote.sh PowerOn] >[OFF:/home/openhabian/SonyBraviaControl/remote.sh PowerOff]" }

BUT, you may want to look at this:

Thanks for the quick response.

I have Openhabian installed and I assume it is the openhabian user that is running openhab. I have been testing my script under openhabian which works for the poweroff command but not the power on command.

I changed the Switch item like you suggested but no luck. Is there a way to turn on verbose logging to see if the command is being executed?

Thanks for the link to the binding. I have spent many hours looking for something suitable with no success. That particular link they talk about making a binding but I don’t think anybody actually has.

I am unfamiliar with Openhabian, so I’m not much help in that regard. If it’s a permissions issue, you should be able to tell from the log.

Are you sure you have the Exec binding installed and it’s active? Make sure it is version 1.11, since that is how you have your item configured. And the 2.0 Exec binding is a beast to figure out. Try a bundle:list in the Karaf console to check. Logging can be configured in too ways. You can manually edit the org.ops4j.pax.logging.cfg file (located in openhab2/userdata/etc or /var/lib/openhab2/userdata/etc, depending on the installation method), or just enter log:set DEBUG org.openhab.binding.exec in the Karaf console. You can then tail the openhab.log or do it in Karaf with log:tail |grep exec.

Follow the link to the PR in post 14. The whole thread is talk about using the binding :slightly_smiling_face:.

Tim

You can find the whole Sony binding at https://github.com/openhab/openhab2-addons/pull/1249 - go near the bottom and you’ll see the binding link. There are four different ‘things’ that could apply to your TV: SimpleIP (depends if your TV supports it AND you have it turned on via settings), DIAL & IRCC (depends on the firmware version of the TV) or WEBSCALAR (supported by newer TVs which we are testing right now).

Tim

Incorrect. OH Erin’s as the openhab user. openhabian is the user you log in with.

Thanks Tim, I found your binding and installed. Good effort so far! Unfortunately my TV does not auto discover even with the power on. I have a Bravia KDL-40W600B build date June 2014. To use my script I had to turn on Authentication PSK. I read the readme.md and am interested in doing a manual thing configuration but I’m a little lost. Is there an example of how to do this? Or can you set me in the right direction if I give you my TV details?

IP: 10.10.10.66
MAC: 90:48:9A:74:F5:60 (WOL works on my TV)
PSK Auth key "ABCD"
Interface is Wireless

Thanks!

Manually is very tough and requires Wireshark to sniff some packets (I don’t know how technical you are - so I don’t know if that makes sense). What I would do is to go into your TV settings - generally network or system area and look for IP Controls or Remote Devices (the wording and location differs on every TV model it seems). If you find something like, “Simple IP Control” - turn that on and the binding should discover the Simple IP thing. If you find something like “Allow Remote Devices” - turn that on and the binding should discovery IRCC (maybe DIAL) and maybe WebScalar - you’ll want webscalar if you see both.

If you find those, have them turned on and the binding doesn’t see it - then I’d like to do some diagnostic work with you.

Tim

Thanks Tim, I got it going. I had to reboot my Raspberry Pi and the binding works now. Auto discover works and I can power on and off the TV. I also got voice commands working through Google Home and HA-Bridge.

Thanks for your work on the binding! That is exactly what I was hoping to be able to do.

Might be a stupid question, but how do I install this?

Hi Mike, fair question. I had to look it up to do this. You want to download the latest version which is near the bottom of the thread. For a Linux install (mine is Openhabian) copy the file (current version org.openhab.binding.sony-2.2.0-SNAPSHOT) into /usr/share/openhab2/addons. Once copied you will find the binding installed in PaperUI under Bindings.You might need to restart to get auto discovery to work.

I downloaded the last version (or so I thought), and it says org.openhab.binding.sony-2.1.0-SNAPSHOT

I did ignore the one that said ‘New Webscalar’ though, is that the one I should have?

Ok, I copied the .jar file into the directory, nothing shows up in bindings.

Do I have to copy the whole zip in there, or just the .jar file?

1 Like

Extract the Jar file and copy it to the Addons folder. The version I am using is 2.2.0 that I downloaded from This thread and it’s currently the second last comment. https://github.com/openhab/openhab2-addons/pull/1249

Direct link: org.openhab.binding.sony-20170726-2.jar.zip

The Sony binding just showed up straight away without any intervention for me but I did have to reboot my Pi to get it working.

Thanks for the reply.

That’s what I did, not showing so far.

That folder only had 1 other file (and a README) called openhab-addons-2.1.0.kar

Is this the right folder?

OK, my bad, I was looking for it in the bindings section of the AddOns in paperUI, I just looked in the bindings and it is there, thank you for your help.

If my TV is on (which it is) should I not just be able to search for it? I tried that and nothing came up. Would my bravia be too old? It is a KDL-40W5500

It might be. Mine is manufactured in 2014. It needs to be a smart TV and it needs simple IP control turned on. If you can’t find simple IP control in the settings with the TV then you probably can’t do it.

Actually - that’s not correct as the binding works with 4 different protocols and many TVs will implement only a few and having simple IP doesn’t necessarily mean you don’t have one of the better ones (SimpleIP is the lowest [in terms of functionality] of the 4).

If you can find a simple IP option on the TV, turn it on and hopefully the binding will find it. If not, you can manually configure it by IP address alone.

If you can find a ‘allow remote devices’ option, turn that on and hopefully the binding will find either the IRCC, DIAL or WEB SCALAR protocols - the webscalar is the one you want followed by the IRCC (if you have multiple showing, do the webscalar - its by far the most powerful).

If NONE of those show up - install Sony’s TV SideView APP and see if it finds the TV.

If the app doesn’t find the TV - then I can work with you to figure out why.

Tim

My TV is 2009, and the supported TVs for the sideview app only list models 2011 or greater.

Link: LCD TV BRAVIA

This combined with having no network setting to expose any IP functions, I would have to assume that this kind of interaction is not available on my TV.

My TV does have ethernet, but that ethernet connection is only listed in the specs as a ‘DNLA ethernet port’.

Link: Specifications

Time to get a new TV I think.

I got a brand new Sony Bravia TV and new to Openhab. Two things to discover the coming weeks …

When I go to “PaperUI > Inbox > + > Sony Binding” no things are found.

Nevertheless, on my iphone app the Bravia tv is found and I can control it through the app.

How should I proceed?

BTW My goal would be to set the receiver to HDMI output whenever the TV is turned on. And set the receiver off whenever the TV is switched off. Nothing more (for the moment).