newAM / hisensetv

Python API to control Hisense brand TVs via their internal MQTT broker.
MIT License
37 stars 17 forks source link

Great Project. U8G partially works. #19

Closed mannyman closed 2 years ago

mannyman commented 2 years ago

U8G AndroidTV Python 3.7-64 / 3.9-64 hisensetv-0.2.0.tar.gz

[--key {,exit,ok,volume_up,volume_down,channel_up,channel_down,fast_forward,rewind,stop,play,pause,mute,home,subtitle,,0,1,2,3,4,5,6,7,8,9,source_1,source_2,source_3,source_4,source_5,source_6,source_7}]

Steps to Reproduce

The following does not work , (the TV stays on the home screen): --key netflix --key youtube --key amazon

Other commands such as power, back, etc. work fine

PS C:\WINDOWS\system32> hisensetv 192.168.86.98 --key youtube [2022-03-08 12:11:27,082] [INFO ] sending keypress: youtube <--- Does nothing

PS C:\WINDOWS\system32> hisensetv 192.168.86.98 --key back [2022-03-08 11:50:26,050] [INFO ] sending keypress: back <--- Works as expected

newAM commented 2 years ago

Yikes. I am not sure what steps to take with debugging this. This is probably something going wrong in the TV, and that's pretty much a black box.

mannyman commented 2 years ago

Opening apps uses launchapp mqtt message instead of sendkey.

To emulate power button: /remoteapp/tv/remote_service/XX:XX:XX:XX:XX:XY$normal/actions/sendkey -m KEY_POWER

To start netflix: /remoteapp/tv/remote_service/XX:XX:XX:XX:XX:XY$normal/actions/launchapp -m {"appIcon":"","appId":"","has_detail_page":0,"isLocalApp":1,"name":"Netflix","storeType":0,"type":0,"url":"com.netflix.ninja","urlType":0}

On Thu, Mar 10, 2022, 7:28 AM Alex Martens @.***> wrote:

Yikes. I am not sure what steps to take with debugging this. This is probably something going wrong in the TV, and that's pretty much a black box.

— Reply to this email directly, view it on GitHub https://github.com/newAM/hisensetv/issues/19#issuecomment-1064183825, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABPS36RVALJXNRP7DJXAZYTU7IIINANCNFSM5QK3PXIQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you authored the thread.Message ID: @.***>

newAM commented 2 years ago

Opening apps uses launchapp mqtt message instead of sendkey.

Yup. That is the current behaviour:

https://github.com/newAM/hisensetv/blob/25e00dafcd98ee432f439563b243786c375b7484/hisensetv/__init__.py#L389-L392 https://github.com/newAM/hisensetv/blob/25e00dafcd98ee432f439563b243786c375b7484/hisensetv/__init__.py#L242-L270

Is that not what you expected?

mannyman commented 2 years ago

the mqtt topic /remoteapp/tv/remote_service/XX:XX:XX:XX:XX:XY$normal/actions/launchapp with message { "name": "Netflix", "urlType": 37, "storeType": 0, "url": "netflix", } Does not work for me in hisensetv nor testing it in MQTT Explorer

But, the following works in MQTT Explorer when I change message to: /remoteapp/tv/remote_service/XX:XX:XX:XX:XX:XY$normal/actions/launchapp {"appIcon":"","appId":"","has_detail_page":0,"isLocalApp":1,"name":"Netflix","storeType":0,"type":0,"url":"com.netflix.ninja","urlType":0}

When I use RemoteNow app on Note 10+ android phone and press the Netflix logo it also works: MQTT Explorer shows: launchapp = {"appIcon":"","appId":"","has_detail_page":0,"isLocalApp":1,"name":"Netflix","storeType":0,"type":0,"url":"com.netflix.ninja","urlType":0}

mannyman commented 2 years ago

This home assistant community post looks accurate for the latest Hisense AndroidTVs in case that's the difference between our TVs: The author and I believe your code uses ui_service instead of remote_service (which also worked for me). https://community.home-assistant.io/t/hisense-tv-control/97638/95

"For app launching, here’s an example MQTT publish and the JSON for it. This launches the app immediately, from every screen and input I could try.

/remoteapp/tv/ui_service/XX:XX:XX:XX:XX:XY$normal/actions/launchapp

{
  "appIcon": "",
  "appId": "",
  "has_detail_page": 0,
  "isLocalApp": 1,
  "name": "Plex",
  "storeType": 0,
  "type": 0,
  "url": "com.plexapp.android",
  "urlType": 0
}

" I also think this would be useful for your code: " This will return a JSON response with all installed apps, makes it easy to format the app changing commands above.

/remoteapp/mobile/XX:XX:XX:XX:XX:XY$normal/ui_service/data/applist

"

newAM commented 2 years ago

Ah, that makes sense - they changed the API. I originally accepted a pull-request for the netflix/youtube/amazon keys - I never got those to work on my TV myself.

If you want to send in a pull-request for that update I am happy to review it, but I would rather not develop features myself without a mechanism to test them.

mannyman commented 2 years ago

Sound good, But I've never done that before. Do I just replace

{
"name": "Netflix",
"urlType": 37,
"storeType": 0,
"url": "netflix",
}

with

{
  "appIcon": "",
  "appId": "",
  "has_detail_page": 0,
  "isLocalApp": 1,
  "name": "Netflix",
  "storeType": 0,
  "type": 0,
  "url": "com.netflix.ninja",
  "urlType": 0
}

and then click save or something? Going to click on Pull request button and see what happens.

mannyman commented 2 years ago

OK tried pulling and forking. Not sure what to do now. added the following to init and main: Added more apps "disney+", "hulu", "peacock_tv", "tubi", "pluto_tv", "vudu", "hbo_max", "youtube_music", "iheartradio", "pandora", "TIDAL", "Spotify", "TuneIn Radio", "Plex", "MrMC", "Stadia",

mannyman commented 2 years ago

Holy moly. It worked! Thanks for this project. Here's video of it. https://youtu.be/v3QqIyN58ns

ersan commented 1 year ago

Sorry to revive this, but does this project still work on the U8H? Trying to decide if I should buy one.