Philips TV (2016+) Binding

Mmmh, I don’t think that you need to have access to username and password in Thing-Configuration. At least I have never touched these settings.

Just downloaded again the version from @NorbertHD (thx!!). With this one everything seems to work.
Lets see if it stays that way :slight_smile:

I’ve made some relatively major changes since the last working jar above. I’d appreciate knowing I didn’t completely break it. This is the first version which tries to normalize the two bindings together. Things to note:

  • host is now ipAddress in the thing configuration. Works the same way as it did before, this is just a name change.
  • keycode channel is now keypress. ATV uses keycode to identify raw hex keycodes where keypress is for “normal name” to things like volume up, volume down, etc. The key names are the same for now, but will normalize later. You may notice that the options are no longer in the dropdown on the UI. This is temporary for this version. Button codes for reference are in here… https://github.com/morph166955/openhab-addons/blob/androidtv-philips/bundles/org.openhab.binding.androidtv/src/main/java/org/openhab/binding/androidtv/internal/protocol/philipstv/service/KeyPress.java
  • most of the services were adjusted to align to the newer SAT requirements and to clear warnings there. This took some significant rework of things like the ambilight to make sure we didn’t have any null issues. In theory, nothing should have changed from the perspective of functionality so this is mostly to verify that we didn’t have a regression
  • appName is now appname, appIcon is now appicon. Just a camel case name change to normalize.
  • the player channel has been slightly adjusted, it should work just the same as before but has some behind the scenes adjustments
  • discovery was adjusted slightly, mostly name changes. It may fix autodiscovery now or get us closer to the mark.

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

Thank you!

– Autodiscovery now works!

– Initial Thing-Configuration is without Hostname (IP):

Is IP already known with autodiscovery or does user need to set it manually?

– After entering the host name (IP), I should receive the 4-digit Pin-Code. But this doesn’t work anymore. I can send a trace tomorrow if needed.

I probably missed something in the XML. There was a lot that moved around. I’ll go through it again in a few hours to see where I missed.

Is that the discovery result thing? What happens if you manually create it?

Sorry for the spam.

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

And if you are feeling adventurous, try…

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

The first jar should fix the issue you had. The second moves username, password, and macAddress to a json file so they aren’t part of the thing config. I would like to see a debug log of the PIN process with this one please, and then a disable/enable of the thing. I want to make sure we are properly saving and restoring the configuration from json. You should see a new folder show up in your OH userdata folder called androidtv with a file named philipstv.(yourThingID).config. That should have a json in it with the data.

Also as a note with the second one, I changed the places where the thing is offline/online. It is possible that the thing may not come online even though it is. I don’t think this should happen, but it is possible

I’m feeling adventurous and did go with option 2 :slight_smile:
And I think you are already very close to a working PhilipsTV-Binding!

Steps:

  1. Autodiscovery → OK

  1. Ignore GoogleTV / Add PhilippsTV → Thing in status " HANDLER_INITIALIZING_ERROR because “Enable GoogleTV” is on

  2. Switch OFF "Enable GoogleTV and save Thing → 4-digit-Pin visible on TV

  3. Enter Pin and save Thing → Thing ONLINE

  4. New Config-File available in Android-Directory → password OK, Mac-Address and username missing:

  5. Disable and Enable Thing again does not change anything. It is ONLINE but still username and macAdress are missing in json.

  6. Channels do not work, but I’m quite sure this is because of missing username

Here 2 DEBUG-Files with interesting Part:

1.log (7.2 KB)
2.log (3.6 KB)

BTW You have now 2 channels for App:

Is one channel for control and the other read only with app name?

Im glad it got that far. Probably just a typo somewhere in the username paths.

App is for the org.google.youtube… ID. We get it on the other protocols so im adding it for uniformity. App Name is the common name like it has been. App shouldn’t do anything yet, I have it on the todo.

I’ll dig through the code later to see if I can find the username issue.

Thanks for all the help!

Awesome @morph166955. I will try this this weekend!

1 Like

@michaeljoos try this for the username fix…

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

I think I found the offending line which was leaving it blank. In theory once the username is fixed the mac address should also populate properly.

Thanks for new jar. I could only do a quick & dirty test today. Tomorrow I have more time.

But what I could see

  • Username and password in JSON → OK
  • MAC was not there yet
  • Tried to power OFF PhilipsTV over channel but did not work

But now I have another issue:
The initial setup was OK and I was able to enter the pin I got from TV. Then I deleted the Thing again and tried to add it again. This time I could not see the pin anymore on TV. I tried restarting the binding but that didn’t help. Question: username and password are in JSON. Where does the binding store the pin? Can I delete this one as well?

Did the thing come online at any point? With the json file existing now you’ll have to delete the file and restart the binding to trigger pin again. My next step is to move pin to a channel and that will enable you to be more forceful with the process. The filename includes the thing id so if you use the same name it just reads it from the file even if you destroy the thing. Mac is only for WOL so that shouldn’t impact the channels working. Did any channel work? Power is a little different from the others.

Yesterday evening I did delete the file and trigger pin worked again. The thing is online and Username, Password and MAC-Address are populated in JSON!

Summary:

  • The Thing is now ONLINE all the time. It doesn’t matter if TV is switched ON or completely OFF (Power OFF)
  • Power-Channel/Command ON/OFF → Works, but does not refresh automatically. If I switch ON or OFF the TV manually (with remote) the Item does not update automatically. I need to disable/enable Thing to get new status
  • Mute Volume → OK
  • Ambilight ON/OFF → OK
  • App-Channels do not work anymore. For these 2 channels I even do not see any change when I disable/enable Thing
  • If I save settings, the Thing-Status remains Offline and in status “Protocols Starting”

Disable/Enable Thing brings Thing back ONLINE

Overall I have the feeling, that Binding/Thing does not refresh at all anymore. Pin-Process is working. Channels are working except the two for the App-Control/Name.

Edit:
And now I have just realized, that WOL still works with Power Channel in Binding :ok_hand:

Getting closer! There is a scheduled service to refresh the channels. I’d bet something is blocking it from starting properly.

For app, app name is the only one that should work right now. The other isn’t implemented yet. Are you saying that if you send a command to it (e.g. “YouTube”) the app doesn’t start? Please elaborate so I make sure I understand.

I think I found the typo on the refresh scheduler which was causing that to fail to start. I also moved the logic of when it starts so it’s a little more deterministic. Updated jar at…

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

I have tried both: Send a command to channel but also start different apps manually on TV. The name on channel did not change. I will test again with new jar when I’m at home. Maybe it was because refresh scheduler as well.

That’s very possible. Let’s get the channels updating and if that doesn’t fix the app issues I can start to see why. A debug log would help me trace it through.

@michaeljoos What version of OH are you running? 3.x or 4.x?

Latest stable version 4.01

I have tried with new jar now but still the same issues. Here a few files/logs:

Send command to “App Name”-Channel (e.g. YouTube, Netflix:)
App_Command.log (127.1 KB)

Switch Off TV with remote. Power channel does not refresh. Enable/Disable Thing refreshes the channel:
Switch_Off_TV_Disable_Enable_Thing.log (210.6 KB)

Video Thing-Status “Protocols Starting”:
https://drive.google.com/file/d/1izzzGMQ5HSq5Q4kWopTh3qaEUy2HfNkR/view?usp=drive_link

And Debug-Log for the same:
Protocols_Starting.log (145.0 KB)

I see some warnings in Logs. I hope this helps :slight_smile: