Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for v6 features to philips js integration #46422

Merged
merged 37 commits into from
Feb 26, 2021

Conversation

elupus
Copy link
Contributor

@elupus elupus commented Feb 11, 2021

Proposed change

  • Add support for pairing v6 android tv's
  • Add support for media control, play, pause, stop
  • Add support for application selection
  • Add support for state monitoring using notification API
  • Add support for applications and icons
  • Switch to async api

Known Issues

  • There is no way to get current hdmi source
  • The selection list of hdmi sources is statically provided to be able to at least select a source
  • Often the returned activity from the TV is invalid. It also have a tendency to output a new intent even thou we are not changed.

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • The code has been formatted using Black (black --fast homeassistant tests)
  • Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • Untested files have been added to .coveragerc.

The integration reached or maintains the following Integration Quality Scale:

  • No score or internal
  • 🥈 Silver
  • 🥇 Gold
  • 🏆 Platinum

To help with the load of incoming pull requests:

@nstrelow
Copy link

nstrelow commented Feb 12, 2021

This is amazing work :D

Dreamt of doing this, but never took the time to actually dig into this.

Kudos on updating everything. Will test it out and deprecate my custom component afterwards. (Or is there anything that my poor custom component can do, your update here can't? If there is, I'll try to add it later on to the official component)

For reference, custom v6 implementation: https://github.com/nstrelow/ha_philips_android_tv (damn so close to 100 stars 🙈 )

@elupus
Copy link
Contributor Author

elupus commented Feb 12, 2021

@nstrelow your have very likely handled many edge cases that i have not encountered. So I would be very happy for you to look it over and comment on behaviour you have been forced to handle.

@nstrelow
Copy link

My edge case handling was bad and I think some recent commit broke the on/off display for most users.

Also I am using the synchronous API and I think it works better with async.

Will check your code as soon I am back at my TV, probably in 1-2 weeks. Sorry for that. Maybe somebody else can review and test it out until then :)

@elupus
Copy link
Contributor Author

elupus commented Feb 12, 2021

It's still not async. It really should be changed to that i suppose. Would clean it up a bit.

@elupus elupus marked this pull request as ready for review February 13, 2021 16:36
@balloob balloob linked an issue Feb 25, 2021 that may be closed by this pull request
@balloob balloob added this to the 2021.3.0 milestone Feb 25, 2021
@nstrelow
Copy link

nstrelow commented Feb 26, 2021

Finally able to test out the integration. IT IS AMAZING. Very great to see paring integrated.

What works:

  • Pairing
  • Volume up down mute
  • Starting applications/TV channels
  • On/Off
  • Play on Youtube video that was paused

What does not work for my model (2016 model: philips 43pus6401/12):

  • the play/pause button only triggers Play in the youtube app, but cannot pause
  • The text2speech didnt do anything
  • Cannot swithc HDMI and TV:
"2021-02-26 15:05:51 WARNING (MainThread) [haphilipsjs] Post failed: {'intent': {'extras': {'uri': 'content://android.media.tv/passthrough/com.mediatek.tvinput%2F.hdmi.HDMIInputService%2FHW5'}, 'action': 'org.droidtv.playtv.SELECTURI', 'component': {'packageName': 'org.droidtv.playtv', 'className': 'org.droidtv.playtv.PlayTvActivity'}}} -> <html>"

Will investigate more, if there is a way to trigger that HDMI switch, but it is probably just a limitation of older devices

image

Philips TV System Info

{
   "notifyChange":"http",
   "menulanguage":"English",
   "name":"Android TV",
   "country":"",
   "serialnumber":"",
   "softwareversion":"AND1E.0.0.0.1",
   "model":"43PUS6401/12",
   "deviceid":"57334431",
   "nettvversion":"8.1.3",
   "epgsource":"one",
   "api_version":{
      "Major":6,
      "Minor":2,
      "Patch":0
   },
   "featuring":{
      "jsonfeatures":{
         "editfavorites":[
            "TVChannels",
            "SatChannels"
         ],
         "recordings":[
            "List",
            "Schedule",
            "Manage"
         ],
         "ambilight":[
            "LoungeLight",
            "Hue",
            "Ambilight"
         ],
         "menuitems":[
            "Setup_Menu"
         ],
         "textentry":[
            "context_based",
            "initial_string_available",
            "editor_info_available"
         ],
         "applications":[
            "TV_Apps",
            "TV_Games",
            "TV_Settings"
         ],
         "pointer":[
            "not_available"
         ],
         "inputkey":[
            "key"
         ],
         "activities":[
            "intent"
         ],
         "channels":[
            "preset_string"
         ],
         "mappings":[
            "server_mapping"
         ]
      },
      "systemfeatures":{
         "tvtype":"consumer",
         "content":[
            "dmr",
            "dms_tad"
         ],
         "tvsearch":"intent",
         "pairing_type":"digest_auth_pairing",
         "secured_transport":"true"
      }
   }
}

This command is switches to HDMI channel 2 (for me):

adb shell am start -a android.intent.action.VIEW -d content://android.media.tv/passthrough/org.droidtv.hdmiService%2F.HdmiService%2FHW10 -n org.droidtv.zapster/.playtv.activity.PlayTvActivity -f 0x10000000

@elupus
Copy link
Contributor Author

elupus commented Feb 26, 2021

@nstrelow
Annoying with that HDMI switch. So seems that intent is missing (a bit unsure since you get a failure in the post which seem to indicate that it didn't parse the intent). If you could PM me the extracted apk for xtv and playtvapp on discord. I can perhaps have a look inside them.

Play/Pause is messy. On my TV the actual playpause toggle key is broken. So i send a spacebar command instead. Which is commonly used for playpause. Does the PlayPause key work normally on your TV using your component?

@elupus
Copy link
Contributor Author

elupus commented Feb 26, 2021

Ps.. the serial number in above data is not actually empty right? I hope you redacted it?

@balloob balloob merged commit e12eba1 into home-assistant:dev Feb 26, 2021
@elupus elupus deleted the philips_js_pair branch February 26, 2021 17:35
@nstrelow
Copy link

Ps.. the serial number in above data is not actually empty right? I hope you redacted it?

I did.

Will test further things, if I find the time, extract the apks.

@github-actions github-actions bot locked and limited conversation to collaborators Feb 27, 2021
@elupus
Copy link
Contributor Author

elupus commented Mar 1, 2021

I've resolved the post merge comments in: #46422

This pull request was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

philips_js [Unknown error occurred] [KeyError: 'serialnumber']
5 participants