Philips TV (2016+) Binding

1 - 3: → Done
4: Discovery → OK
5: Pin process → OK
6: Thing Online / Power ON/OFF / Switch Apps / Mute / Ambilight ON/OFF → OK
7: Thing is in status " HANDLER_INITIALIZING_ERROR". These are the errors I get:

2023-08-26 15:29:54.304 [ERROR] [st.core.internal.thing.ThingResource] - Exception during HTTP PUT request for update config at 'things/androidtv:philipstv:F00DBABE_AA5E_BABA_DADA_70af241424b4/config'
2023-08-26 15:30:12.899 [ERROR] [nal.common.AbstractInvocationHandler] - An error occurred while calling method 'ThingHandler.initialize()' on 'org.openhab.binding.androidtv.internal.AndroidTVHandler@100baad': null
2023-08-26 15:30:12.905 [ERROR] [core.thing.internal.ThingManagerImpl] - Exception occurred while initializing handler of thing 'androidtv:philipstv:F00DBABE_AA5E_BABA_DADA_70af241424b4': null

Full Log Enable GoogleTV:
openhab.log (19.7 KB)

Of course pin process for GTV does not work when Thing is in status “UNINITIALIZED” / " HANDLER_INITIALIZING_ERROR". Also no googletv keystore file in the androidtv folder.

These commands work with channel KeyPress now:
https://jointspace.sourceforge.net/projectdata/documentation/jasonApi/1/doc/API-Method-input-key-POST.html

KeyCode does not have any functionality anymore in PTV, correct?

I would love to know if Keyboard and Search Content do the same thing or not. I haven’t had any exposure to that.
These are GTV commands? Or should both work for PTV as well? I have never used these channels.

Update1: I think it is not the same. Search Content is to activate Google Assistance. Instead of pressing a button on Remote Control and speak, I can send a String Command to this Channel:

  • Toggle Google Assistant on TV for a given Input (e.g. “HDMI1” switches to HDMI1 or search for content)

For Keyboard I could not see any functionality. This is most probably GTV protocol?

I see the problem. Missing an entry in the xml.

Let me look at this and get back to you.

This should resolve the handler failure…

https://github.com/morph166955/openhab-addons/releases/download/androidtv-beta/org.openhab.binding.androidtv-4.1.0-SNAPSHOT-c68daea.jar

So is it safe to say that, since we made it through 6, you feel that we have the same stability that we had with the previous jar that was working well? I’m glad that the PIN process worked cleanly.

KeyCode became keypress to align with the other protocols. KeyCode in GTV is the raw keycodes so I didn’t want to cause a conflict/confusion there. In theory, anything you send to keypress (with GTV disabled for the moment) should work. I still need to adjust the command handler so they work properly with GTV enabled.

On my ShieldTV it triggers a google assistant search when it’s sent.

Thanks!

Error message → solved
Thing-Status is:

GoogleTV: Error opening SSL connection. Check log. | PhilipsTV: Online

keystore file is there but no Pin-Code shown on TV when I send the Request for GTV.
This is the Trace, but not sure if you can see something:

openhab.log (173.6 KB)

Do you have the Google TV app installed on the TV?

Nevermind, found it. Stray return in the handler was blocking it.

https://github.com/morph166955/openhab-addons/releases/download/androidtv-beta/org.openhab.binding.androidtv-4.1.0-SNAPSHOT-fdbcc93.jar

EDIT: If that worked, and you want to feel adventurous, this build resolves a ton of build warnings. I did not reintroduce the SAT issues from before on this one, we will take that step another day. Please regression test to make sure this didn’t break anything. You’ll need to set gtvEnabled to false to properly test, the googletv bits could mask problems.

https://github.com/morph166955/openhab-addons/releases/download/androidtv-beta/org.openhab.binding.androidtv-4.1.0-SNAPSHOT-cfeaee4.jar

Today I did a more comprehensive test :slight_smile: And it really looks good so far.

Whenever I mention ATV below, then I mean with setting “Google TV Enabled” (not Google-TV-Thing)

• Autodiscovery ATV & PTV → OK
• Pin-Process ATV & PTV → OK, but Thing-Settings missing/empty

• Key Press → Working for GTV and PTV, but it seems supported commands are different. E.g. command “WatchTV” works for PTV but not for GTV (this is the command I use to switch from an app back to TV). These are the commands integrated in official PhilipsTV-Binding:
https://jointspace.sourceforge.net/projectdata/documentation/jasonApi/1/doc/API-Method-input-key-POST.html

• Keyboard → No functionality in PTV. For GTV it works like I would use a keyboard. E.g I can search a keyword in YouTube

• Keycode → No functionality in PTV. Works in GTV (Tested VolUp, VolDown, Mute). But not all commands are working (e.g. 233 KEYCODE_TV_TELETEXT

• Volume → This channel only works for PTV & TV-Speaker. I have connected external HomeCinema and use ARC/HDMI. Volume Channel does not work for ARC. If I use Remote Control from TV it works. Do you think it would be possible to integrate? I have done a trace and changed volume with remote control, but only could see this:

2023-08-27 10:13:10.153 [DEBUG] [protocol.philipstv.ConnectionManager] - Target Uri is: https://192.168.1.57:1926/6/audio/volume

• Mute → Works with PTV-Protocol. With GTV-Protocol it is a bit strange: Seems not to be a switch, but a trigger (whenever I switch channel to ON, it triggers the TV-Volume ON/OFF)

• Power → Works for PTV & GTV (WOL and WoWLAN only with PTV what is expected I think)
• App / App-Name → Works for PTV & GTV
• Ambilight-Power → ON/OFF working for PTV & GTV
• Player → Commands working for GTV & PTV, but feedback does not work (Play/Pause on remote control not reflected in channel)
• Search Content → Works in PTV & GTV. It is about communicating with Google Assistant

Awesome! Just so I’m tracking, was this on the fdbcc93 or cfeaee4 jar?

What are you meaning by that? PIN is now completely removed from the thing settings. Keystore file/pass are set default if not configured, they aren’t required.

That’s a very valid point, I’ll have to setup a passthrough for the PTV commands. Right now it’s just GTV when it’s enabled. Noted.

Perfect, that’s what I would expect.

Also as expected. This is the GTV codes, no reason it would work on PTV. The codes have to be implemented in the bus on the device itself. Very much “your milage may vary” as to what works and what doesn’t depending on device.

I can fix this easily. Just need to send volume to the PTV protocol instead. GTV only accepts UP/DOWN.

Weird, so it’s muting but not. I can pass that to PTV also like volume.

I was curious on this. If the device goes into low power, does the GTV power work? I’d suspect not since it’s not doing a WOL. I’d assume as long as the TV is not in low power that they work the same. Did you notice anything different in terms of the channel updating? With GTV enabled we now get two sources of power state updating the channel so it should be really clean and fast.

So to be clear, on PTV, if you hit play/pause on your physical remote it updates the channel? I never expected that. I’ve always seen it as a one way write kind of channel where we are sending the command. Can you get a trace log showing this happening for PTV?

Ok, next step. This is a 3.x/4.x hybrid jar I’m testing. I’ve seen an error about a missing “Unresolved requirement: Import-Package: org.openhab.core.config.discovery.upnp”. I had it and one other user had it. On mine, it started about 5 seconds later and then on OH restart it worked just fine. Curious if you get the same. The hybrid jars are not working like they used to, but I’m trying for those on 3.x still.

https://github.com/morph166955/openhab-addons/releases/download/androidtv-beta/org.openhab.binding.androidtv-3.2.0-4.1.0-SNAPSHOT-b674ccf.jar

I’m getting very close to dropping this onto the marketplace, we’re pretty close to a beta for this.

Test report was with cfeaee4 jar

In Thing Configuration we have this:
image
Maybe not needed anymore and we can delete from user interface?

Yes, correct. If device is in low power, GTV does not work. If device is not in low power, channel did work the same way for GTV & PTV.

I could not see any difference between GTV & PTV → Channel command works, but if I control on my physical remote the channel don’t update. Yes confirmed, it’s “one way”.

Hybrid jar I can test in 4.02 but not in 3.x. Let me check if I can see the error as well. Do I need to delete eveything or can I just replace the jar?

Update1: Hybrid jar works in my system. I have done both: First just replaced the jar and then deleted and installed everything from scratch (Thing and Android-Folder deleted). So…no issues here :slight_smile:

Update2: Now I have also tested “TV Channel” → Working for PTV and GTV enabled. BTW one thing I have forgotten this morning: Brightness, Contrast, Sharpness don’t work on my TV. But it also seems not to work with original PhilipsTV-Binding. Maybe not supported for my Model.

Not needed, but optional. Some people may want their keystore encrypted or stored differently. I can make it advanced though down the line to hide it.

Perfect.

Ok so, we’re good here then? I’ll leave it as is through GTV if there is no appreciable difference between the two. My usual process is, if the vendor protocol provides an enhancement (e.g. volume here) then I go with that, otherwise use GTV.

Perfect! It looks like it only causes an issue if there are no other upnp bindings loaded. Having one of them loaded resolves the dependency. Alternatively, the jar can be put into the addons folder for that specific bundle for those who don’t run any other upnp bindings.

THANK YOU!

Ok, getting very close. This jar:

  • Moves volume and mute to PTV, should fix all those issues.
  • Power has been slightly adjusted. If the TV is not in low power it uses GTV, if the TV is in low power it uses PTV to do a WOL
  • KeyPress now has a fall through. Basically, it tries GTV first, and if there is no match it sends it to PTV to be handled

https://github.com/morph166955/openhab-addons/releases/download/androidtv-beta/org.openhab.binding.androidtv-4.1.0-SNAPSHOT-d52ef14.jar

The link doesn’t work but I could find the jar :wink:

Somehow the power channel is broken when “Enable Google TV” is disabled. Nothing happens and I get this error:

2023-08-28 18:34:39.791 [ERROR] [nal.common.AbstractInvocationHandler] - An error occurred while calling method 'ThingHandler.handleCommand()' on 'org.openhab.binding.androidtv.internal.AndroidTVHandler@12d34b7': Cannot invoke "org.openhab.binding.androidtv.internal.protocol.googletv.GoogleTVConnectionManager.getLoggedIn()" because "googletvConnectionManager" is null
java.lang.NullPointerException: Cannot invoke "org.openhab.binding.androidtv.internal.protocol.googletv.GoogleTVConnectionManager.getLoggedIn()" because "googletvConnectionManager" is null
	at org.openhab.binding.androidtv.internal.AndroidTVHandler.handleCommand(AndroidTVHandler.java:332) ~[?:?]
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[?:?]
	at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
	at java.lang.reflect.Method.invoke(Method.java:568) ~[?:?]
	at org.openhab.core.internal.common.AbstractInvocationHandler.invokeDirect(AbstractInvocationHandler.java:147) ~[?:?]
	at org.openhab.core.internal.common.InvocationHandlerSync.invoke(InvocationHandlerSync.java:59) ~[?:?]
	at jdk.proxy18114.$Proxy18243.handleCommand(Unknown Source) ~[?:?]
	at org.openhab.core.thing.internal.profiles.ProfileCallbackImpl.handleCommand(ProfileCallbackImpl.java:85) ~[?:?]
	at org.openhab.core.thing.internal.profiles.SystemDefaultProfile.onCommandFromItem(SystemDefaultProfile.java:48) ~[?:?]
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[?:?]
	at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
	at java.lang.reflect.Method.invoke(Method.java:568) ~[?:?]
	at org.openhab.core.internal.common.AbstractInvocationHandler.invokeDirect(AbstractInvocationHandler.java:147) ~[?:?]
	at org.openhab.core.internal.common.Invocation.call(Invocation.java:52) ~[?:?]
	at java.util.concurrent.FutureTask.run(FutureTask.java:264) ~[?:?]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) ~[?:?]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) ~[?:?]
	at java.lang.Thread.run(Thread.java:833) ~[?:?]

Does this help or do you need a Debug or Trace?

The volume channel works! But functionality is “Volume up” and “Volume down”. Therefore channel should not be a dimmer anymore because absolute value does not work. Do we have another type for this channel with up and down buttons?

Another question: In future do we need the “Enable Google TV” setting for PTV-Thing? Does it not confuse the user? Is the idea to hide this in final release? Because logic is for PTV-Thing = disabled and for GTV = enabled, correct? Or did I miss something?

I’ll put a check in for the null. Volume should work as it always has with PTV. Not sure why it isn’t taking absolute values now. Is mute working like it used to?

The enable gtv is really just for testing. Expected behavior is for it to be enabled. I could see a use where someone may want to force everything to PTV so it enables the user to make that decision.

Ah, for volume I see now the difference. If I change audio output to TV-Speaker, the slider and absolute volume works. But when I change audio output to HDMI-Soundsystem (ARC), then it’s a volume up and volume down. The same as I do on remote control. There is no slider on remote control :slight_smile: Don’t know if we can solve this. Maybe with a stepper item…

Gotcha. So worked as before then? Let me think about how to better handle this.

ARC/HDMI did not work at all as I remember. Something like this:

→ Default List Item → Stepper Item (show buttons only) → would be a working solution

I’m trying to remember if that’s one of those that you can just swap the item on the sitemap and make it show up differently. Do you get a volume level back when you hit up/down? GTV in theory should be getting the volume level from the TV and pushing it to the channel as an update. So even if it’s not an option you can set, you may still be getting the value back.

I think this works for TV speaker. But for Home Cinema it won’t work. Or in other words TV volume is not the same as Home Cinema volume and not synced.

True. I have a Sonos on my TV doing ARC. I use the volume through the Sonos binding for my setup. Does your soundbar/sound system have a binding that you could do the same?

This should fix the NPE in the power channel…

https://github.com/morph166955/openhab-addons/releases/download/androidtv-beta/org.openhab.binding.androidtv-3.2.0-4.1.0-SNAPSHOT-2108e5d.jar