AndroidTV Binding [3.2.0;4.2.0)

Ok folks, the moment everyone’s been waiting on is here! The googletv protocol stack is close to baked. I have a few small things to tweak in but it’s looking good (THANK YOU @mhilbush).

I’ve also just merged the googletv stack onto the shieldtv thing. So what does that mean. All of the things available on the googletv protocol are now available on the shieldtv. Like power, volume, mute, google keycodes. All of it.

So what do you have to do to upgrade?

  1. Install the new jar from here (I’ll update the main thread so the marketplace folks get a hit once we get a few positive test results): https://github.com/morph166955/openhab-addons/releases/download/androidtv-beta/org.openhab.binding.androidtv-3.2.0-4.0.0-SNAPSHOT-152e942.jar

  2. You may notice that your thing status is offline because GoogleTV is waiting for a PIN. To use this, you must run the PIN process TWICE for a new device. So request, pin, request, pin. If you had already done the PIN process for the shield and are upgrading the jar, you should only have to do it the one time for the googletv side. The on screen displays should look very different between the two. The first is authenticating shieldtv, the second is googletv. You should see the thing status tell you when the first comes online. Once both are hooked you should go ONLINE.

  3. Add the power, volume, mute channels. Power and mute are read/write. Volume (for the moment) is read only (I’m still working on the command to set the volume, hopefully this is soon). The binding will know which protocol to send commands on.

A full list now looks like:

String ShieldTV_KEYBOARD “KEYBOARD [%s]” { channel = “androidtv:shieldtv:theater:keyboard” }
String ShieldTV_KEYPRESS “KEYPRESS [%s]” { channel = “androidtv:shieldtv:theater:keypress” }
String ShieldTV_KEYCODE “KEYCODE [%s]” { channel = “androidtv:shieldtv:theater:keycode” }
String ShieldTV_PINCODE “PINCODE [%s]” { channel = “androidtv:shieldtv:theater:pincode” }
String ShieldTV_APP “APP [%s]” { channel = “androidtv:shieldtv:theater:app” }
String ShieldTV_APPNAME “APPNAME [%s]” { channel = “androidtv:shieldtv:theater:appname” }
String ShieldTV_APPURL “APPURL [%s]” { channel = “androidtv:shieldtv:theater:appurl” }
Switch ShieldTV_POWER “POWER [%s]” { channel = “androidtv:shieldtv:theater:power” }
Dimmer ShieldTV_VOLUME “VOLUME [%s]” { channel = “androidtv:shieldtv:theater:volume” }
Switch ShieldTV_MUTE “MUTE [%s]” { channel = “androidtv:shieldtv:theater:mute” }

=============================

For users who are here just for the GoogleTV stack (anything that isn’t an Nvidia Shield), just replace shieldtv with googletv and you’re good to go. You only do the PIN process once. Also note, APPNAME and APPURL don’t work as we don’t get an APPDB from googletv. Also, starting apps by sending a command isn’t working yet for you. That’s hopefully coming with the volume control once I figure out what the correct syntax for the command is.

2 Likes

I can confirm that the mDNS errors are gone on both of my Chromecasts with Google TV (HD and 4K). When I deleted my things, they popped up in autodiscovery and I didn’t have to go through the PIN process again.

The APP and POWER channels are working, but I haven’t tested anything else.

Thanks, @morph166955 and @mhilbush!

1 Like

It seems like @morph166955 has posted a new binding and mine stopped working as usual. I have used the command you have given me and this is what it returned:

274 │ Active │ 80 │ 4.0.0.202302171450 │ org.openhab.binding.androidtv

After posting the above I tried to uninstall the binding and found that there was no new version. Therefore, I downloaded the jar file and put it in the addons, but don’t seem to be able to display it in the bindings.
I then stopped the container and restarted to check if the binding became available, but to no avail. I looked at the Shield in things and found it to be online and fully functional, despite having unistalled the binding. I then run the command line again and this is the result:

277 │ Active │ 80 │ 4.0.0.202302171450 │ org.openhab.binding.androidtv

Another thing I cannot understand is why despite having the Sonoff binding up and running, since I have installed it it does not appear in the binding menu. Any clues?

So thats interesting. I haven’t updated the main thread yet so absolutely nothing should have happened. Thats still the jar from the main thread, not the new one I posted last night. I’d open an issue on github for one of the developers to look at this.

jar updated to fix a small issue with keepalives.

Hi

Someone more that can help with testing :slight_smile:

I have tried to setup my Philips 50PUS7373/12 (Android 8) but don’t get a pin code on TV

  1. Copy org.openhab.binding.androidtv-3.2.0-4.0.0-SNAPSHOT-152e942.jar to Add-On Folder
  2. Create Android-TV-Thing
  3. Link Item GoogleTV_Pin_Code to Channel Pin Code
  4. Send “REQUEST” in API Explorer
  • Trace attached (from the very beginning)
  • Files in /var/lib/openhab/androidtv I have deleted, but did not help

→ Not sure if port 1926 is really needed?
→ I have installed Philips TV (2016+) Binding but this should not be an issue?

openhab.log (61.9 KB)

Hey @michaeljoos! Thanks for trying it out. I would try to not use the port number in the configuration. It looks like that could be related to something Philips specific. The binding attempts by default to connect to the googletv video server on port 6466 which should be standard across any googletv installation. What you should see is a connection attempt to 6466, a rejection for certificate_unknown, and then a connection attempt to 6467. At that time you should be able to send REQUEST to the PIN channel and get a code. Once you submit the OSD code to the channel you should see the connection to 6467 close and a new connection to 6466 open. Assuming everything works, you should see a ton of messages back and forth indicating that PIN was successful. The thing should also come online at this time.

I’ve updated the main thread with the googletv version and I’ve pushed the changes into the PR so everything is nice and tidy now. Marketplace should update from this.

1 Like

Thanks! One step further now.

Binding does not like special characters :slight_smile: Removed /12 from network name 50PUS7373/12 and then auto discovery did work immediately!

Port number removed. But still there is an issue with certificate and error with SSL connection.

2023-02-27 21:28:40.101 [DEBUG] [l.googletv.GoogleTVConnectionManager] - Returning empty certificate for getAcceptedIssuers
2023-02-27 21:28:40.135 [INFO ] [l.googletv.GoogleTVConnectionManager] - Error opening GoogleTV SSL connection: Datenübergabe unterbrochen (broken pipe) (Write failed)

openhab.log (5.6 KB)

Interesting. Your TV isn’t spitting the normal certificate_unknown error. Can you please make sure you have updated the google video app on your tv (or confirm it’s installed)? If so what version is it on?

Also to note the getAcceptedIssuers being empty is absolutely normal and expected.

Under addons I have two folders. One named shieldtv and the other androidtv. Is that normal?

Again the ShieldTV is not connected and I receive an ERROR:HANDLER message on the state of the device. I used the command provided by @mhilbush and this time the prompt returned no message.

I then installed the new binding and the Shield turned to OFF LINE. In “things” the INBOX diplays the Shield as it has to be installed.

No. What’s in those folders?

I only have “Google Play Filme” (com.google.android.videos).
Do you mean this App? If yes, then it’s version 4.38.35.15-tv

Everything is up to date.

It had various keys. I have deleted the folders suspecting that this could be part of the issue I was having. I am now proceeding with a fresh re-install and configuration of the Shield. I will finish tomorrow if possible as here it is 22:30 and have another long busy day tomorrow.

Perfect. That’s what im running. I’ll go look in the code to see where this is stalling out. We look for a specific error to fire the PIN connection. It could possibly be the android version. Ill get back to you once I can align the errors to the code.

Please try this jar. https://github.com/morph166955/openhab-addons/releases/download/androidtv-beta/org.openhab.binding.androidtv-3.2.0-4.0.0-SNAPSHOT-force1.jar

This is a test for this specific issue, everyone else please don’t grab this one.

Once you get started, please send “FORCE” to the PIN channel and it will force a connection to the PIN server. Then do “REQUEST”. Then send the PIN.

Were the folders in addons or just the generic userdata folder? We did change the folder name when we went from shieldtv to androidtv for the keystores. Otherwise the binding jar should just be in the addons folder, no sub folders I’m aware of (unsure if the marketplace creates folders or not).

Thanks for new jar!

:+1: :muscle:

Status for Philips 50PUS7373/12:

  • Autodiscovery → OK (remove special characters in network name)
  • Pairing → OK (for this device FORCE and REQUEST needed)
  • Power → OK
  • Volume → OK (readable only)
  • App → OK (readable only)
  • Mute → Not tested yet

Other question: The PhilipsTV-Binding does have WakeOnLan support. Also something you think can be implemented in future?

NICE! I’ll see if I can write something into the binding to account for devices that don’t send the traditional certificate_unknown that we’ve been seeing (this is what usually triggers the PIN pieces we had to use FORCE for).

As for WOL, what’s the use case in respect to this? We maintain a connection to the device when it’s in a “powered off” state, which is more exactly a standby state. Does the Philips kill the connection when it’s powered off? I don’t see why we couldn’t do some kind of WOL functionality, but I’d like to understand how it applies.

Yes, the TV goes into a deep sleep mode (0.3 W) and when I switch it on, nothing happens.

My use case is Alexa :slight_smile: “Alexa, switch on TV”, “Alexa, switch on YouTube”, etc.

With WOL we can wake up the TV, switch ON and send the App-Command.