AndroidTV Binding [3.2.0;4.2.0)

I’ve updated to version 0.7.

This adds the reported Device ID (which I can’t find in the shield on screen GUI but seems to be some sort of unique ID of the server that the binding talks to) as well as the supported system architectures as reported. This also fixes some bits on the certificate parsing/storage process after successful PIN authentication.

I’d appreciate knowing if the PIN process is working or failing for anyone who uses this. The calculation of the length of the keys has been completely reworked and seems to be OK on the dozen or so attempts I’ve made, but it’s a little weird so I’d appreciate knowing it works for others too.

There was no problem with the pin process after I installed the binding.
When I switched to your 0.6 version I even hadn’t to repeat the Pin-Game
with my shield.
But still I or openhab are not able to see wether the shield is running or
not (the “power on problem”). If it’s solved I could get rid of my android debug binding that still causes these messages of not being able to read media and refresh play status… Or would it be possible with your new versions to solve my problem?

Best wishes!

Im glad to hear it’s working. The issue of not having awareness of power state still exists. Simply put, I havent found any specific flag on any message that comes from the shield to indicate power state. It’s definitely something on the todo list. I have one other option I’m going to investigate, but it will require several hours worth of work to identify and then potentially several more hours to code if it does work. If that fails, plan B is to actually integrate the ADB connection into the binding to have it pull that data directly so that happens behind the scenes for the user. I’ll get there eventually, just going to take some time.

No hurry! :grinning:

So good news and bad news.

Good news, I was able to successfully do a MITM on the new Google TV app and I was able to capture some of the parts of the pin process. Getting that going has been a pain but I had a breakthrough today that gives me some hope that this is possible. My plan here is to integrate both protocol stacks and basically hope that one is going to get the data we need. The protocol seems similar to the shield stack so I’m hoping that some of it seems familiar as I go.

Bad news, there are some added complexities I have to figure out with the PKI process. The googletv (version 2) protocol uses mutual TLS certificate authentication which I haven’t had to do yet so I need to figure out how to adapt the binding to do this as the shield protocol doesn’t do it. Why they did this level of complexity is beyond me, it’s a bit overkill. Once I get the authentication parts done then I’m going to have to try to decode the parts of the protocol that I haven’t been exposed to yet. So, this is going to take some time.

To note, for this to work you will have to make sure your apps are updated on your shield. They discontinued support for the version 1 of the protocol in the last few months.

So stay tuned, I’ll try to post some more updates as I hit some milestones.

I’ve started a thread (link below) about converting this binding to be a googletv binding with an option to add the shieldtv protocol as opposed to just being a shieldtv binding. The googletv protocol is available to any androidtv system so it would have a broader reach than just the shield. If anyone would like to comment please feel free:

At some point (not urgent), it would be nice to get a 4.0 build that adapted to the new addon metadata change that went into core recently (i.e. addon.xml vs binding.xml).

I have that actually sitting in my current merge to pull in. If I pull this back and make it googletv vs. shieldtv it will have that on the first rev. I just haven’t committed it yet as I have a relatively large and major amount of code changes to pull over with the addition of the googletv protocol.

Is it causing you problems? The binding I have posted is running on my 4.0.0 system which has been updated to the new addons.xml and it seems to work just fine.

Not currently. But Jan said bindings in the addons directory that used binding.xml would not work. Maybe I misread what he said… And if it’s working for you, then there’s no rush at all.

Mine’s been just fine. If it breaks please let me know and I’ll spin off a jar to fix it while I work on the googletv bits. That shouldn’t take too long.

Confirming that the binding still works. The only issue I’ve seen (and it’s a very minor one) is that the UI doesn’t show that the binding is installed (and therefore you can’t manually create a thing through the UI). So from my perspective no need to do anything right now.

FOR ANYONE TRACKING THIS THREAD - READ THIS POST

I’ve made several major (and breaking) changes to the binding. The first and most major, this is now the AndroidTV binding, not just the ShieldTV. You MUST rebuild your things as androidtv:shieldtv instead of shieldtv:shieldtv. You MUST also rerun the PIN process (just as you did before, it just needs to be rerun because of all the changes). Otherwise, this should work just the same as the last ShieldTV release (minus a few bug fixes).

Also, thanks to @hilbrand and his compile magic trick, the attached jar will now work on all releases from 3.2.0 through 4.0.0 (or it should, please report if they aren’t working). I’ll be killing the other thread since I don’t have to maintain two versions now.

Please report success/failure with the new binding changes. Next step, adding the googletv protocol which I’m actively working on. This was the first major step in that direction. Also, with any hope, this binding should start to cover a large variety of AndroidTV devices.

1 Like

I have installed the new binding, but I get the following message:“No thing types can be added with this binding.” I am running Openhab 3.4.0 and the previous ShieldTv binding was working just fine.
I am running Opnhab in a container on a Qnap Nas.

EDIT: I just realised that the INBOX shows a thing to add so will try that later and report back. I am still discovering how things work, No pun intended :wink:

Well thats different. Can anyone on 3.4.0 confirm the same? I don’t have a 3.4.0 running to check.

Both of mine are running on a 4.0 SNAPSHOT.

I confirm that the new Android Tv binding works on Openhab 3.4.0 with a 2019 Shield TV (P3430).
One thing I am curious about is if there is any way of being able to keep the last command sent active. I give an example. When you select a command such as KEY_RIGHT then it is necessary to re-select the same command from the command slection menu. It would be nice to have the possibility of simply re-press the same command that appears in the string rather than running through the menu selection process.

Glad to hear that 3.4.0 is working. Ill keep doing these single jar releases then. Easier on everyone!

As far as the command, I don’t have any issue with it as long as I can figure out what’s causing the issue. @mhilbush any idea why its happening? It looks like its going back to null immediately after the command is sent.

Let’s make sure I understand correctly…

You’re saying that after sending a keypress string (e.g. “KEY_RIGHT”) to the keypress channel, the binding correctly handles the command (i.e. sends it to the android tv), but that the state of the channel is NULL?

I guess I’m confused about what @Norixone means by “menu selection process”.

Thank you for looking into this request of mine. Actually the KEYPRESS command line does not revert back to null. I’ill try to expalin what I was asking for to the best of my writing capabilities :slight_smile:
When you press on the key press function you get a sort of pop-up menu that lists the available commands to send to the Shield such as
KEY_UP
KEY_DOWN
KEY_RIGHT
KEY_LEFT
KEY_ENTER

Let’s say that I press KEY_RIGHT. After I have selected the command and it has been executed, the pop-up menu closes leaving me with only KEY_RIGHT visible in the command line. If I want to perform another key press, I click / tap on KEY_RIGHT which brings up the pop-up menu once again, I then re-select / press KEY_RIGHT and once the command has been executed, the command list closes showing me the last selected value wihich is KEY_RIGHT. This procedure has to be repeated until you are on the app or function you want to launch.
What I was asking for is if there is a way to keep the pop-up list available until I decide to close it.
Maybe I have done something wrong when I copied the available commands into the metadata command field.

Ok, I think I’m getting there now… :wink:

Your question pertains to the UI, not the binding. But which UI are you referring to? Main UI, HABpanel, Basic UI?