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 media player state #178

Merged
merged 9 commits into from
Feb 3, 2024
Merged

Conversation

rale
Copy link
Contributor

@rale rale commented Apr 23, 2023

Subscribe to and query media player state.

get_media_foreground_app() will return something like this when using the media player:
[{'appId': 'com.webos.app.mediadiscovery', 'playState': 'playing', 'type': 'media', 'mediaId': '_', 'windowId': '_Window_Id_3'}]

It also works with other media apps:
[{'appId': 'amazon', 'playState': 'playing', 'type': 'media', 'mediaId': '_fMe9g81DBtDVNw', 'windowId': '_Window_Id_9'}]

The endpoint used doesn't appear to be available in all versions of webOS. It works for me on a newer TV running webOS 7, but on webOS 3.5, it will throw a aiowebostv.exceptions.WebOsTvServiceNotFoundError: 404 no such service or method.

@thecode
Copy link
Collaborator

thecode commented May 6, 2023

@rale can you please run pre-commit supplied in this repo locally so it fixes the formatting? https://github.com/home-assistant-libs/aiowebostv/actions/runs/4780101336/jobs/8752249979?pr=178

@andyscott
Copy link

andyscott commented Aug 13, 2023

FWIW I have tested remotely against my LG G2 TV and it works great. I'd love to see this functionality merged so it's usable more easily from Home Assistant.

@thecode
Copy link
Collaborator

thecode commented Aug 28, 2023

FWIW I have tested remotely against my LG G2 TV and it works great. I'd love to see this functionality merged so it's usable more easily from Home Assistant.

@andyscott Can you add your TV OS version so that we can confirm what versions support it?
Would also need someone with older OS versions to confirm what is the behavior when/if the TV doesn't support this endpoint.

@andyscott
Copy link

@thecode yep! I'm out of town at the moment and can't check the WebOS version until I'm back. I believe it was 7.x.x. As for the TV itself, it's:

OLED55G2PUA by LG
Firmware: 03.33.65

@dekiesel
Copy link

dekiesel commented Sep 6, 2023

I can confirm that this is working:

Media State: {'subscribed': True, 'returnValue': True, 'foregroundAppInfo': [{'appId': 'netflix', 'playState': 'playing', 'type': 'media', 'mediaId': '_LWZpv6U9CkVIAz', 'windowId': '_Window_Id_4'}]}
Software info: {'returnValue': True, 'product_name': 'webOSTV 7.0', 'model_name': 'HE_DTV_W22O_AFABATAA', 'sw_type': 'FIRMWARE', 'major_ver': '03', 'minor_ver': '33.65', 'country': 'DE', 'country_group': 'EU', 'device_id': 'XX', 'auth_flag': 'N', 'ignore_disable': 'N', 'eco_info': '01', 'config_key': '00', 'language_code': 'de-DE'}

WebOS: 7.3.1-39 (mullet-mebbin)

@thecode
Copy link
Collaborator

thecode commented Sep 6, 2023

I would prefer someone with older OS versions check it, I have a TV with an older OS but it is disconnected right now, the main problem would be to verify it doesn't break anything and how we detect that the TV doesn't support it to show it correctly on HA

@rale
Copy link
Contributor Author

rale commented Sep 6, 2023

On older TVs where it's not supported, client.media_state is None.

This is what I've been using myself: home-assistant/core@f3c65c6

@RosaliePerron
Copy link

Hi!
I've followed what @dekiesel said in this comment to test the branch on my tv that's running an old version of webos (5.4.3-36).
Sadly, the script doesn't seem to receive any information concerning the media that is playing on the tv. Here are the lines that outputted when launching the script, then accepting the external program on my tv:

State changed:
System info: {'returnValue': True, 'features': {'dvr': False}, 'receiverType': 'ATSC', 'modelName': '75UN7070PUC', 'programMode': False}
Media State: {}
Software info: {'returnValue': True, 'product_name': 'webOSTV 5.0', 'model_name': 'HE_DTV_W20P_AFADATAA', 'sw_type': 'FIRMWARE', 'major_ver': '04', 'minor_ver': '41.45', 'country': 'CA2', 'country_group': 'CA', 'device_id': '58:fd:b1:f0:**:**', 'auth_flag': 'N', 'ignore_disable': 'N', 'eco_info': '01', 'config_key': '00', 'language_code': 'en-CA'}

I then started playing a show from the Jellyfin app directly on the tv but nothing more outputted from the script. I let it run for a while, paused, stopped it, to no avail.

On the contrary, here's the output when I lower the volume:

State changed:
System info: {'returnValue': True, 'features': {'dvr': False}, 'receiverType': 'ATSC', 'modelName': '75UN7070PUC', 'programMode': False}
Media State: {}
Software info: {'returnValue': True, 'product_name': 'webOSTV 5.0', 'model_name': 'HE_DTV_W20P_AFADATAA', 'sw_type': 'FIRMWARE', 'major_ver': '04', 'minor_ver': '41.45', 'country': 'CA2', 'country_group': 'CA', 'device_id': '58:fd:b1:f0:**:**', 'auth_flag': 'N', 'ignore_disable': 'N', 'eco_info': '01', 'config_key': '00', 'language_code': 'en-CA'}
State changed:
System info: {'returnValue': True, 'features': {'dvr': False}, 'receiverType': 'ATSC', 'modelName': '75UN7070PUC', 'programMode': False}
Media State: {}
Software info: {'returnValue': True, 'product_name': 'webOSTV 5.0', 'model_name': 'HE_DTV_W20P_AFADATAA', 'sw_type': 'FIRMWARE', 'major_ver': '04', 'minor_ver': '41.45', 'country': 'CA2', 'country_group': 'CA', 'device_id': '58:fd:b1:f0:**:**', 'auth_flag': 'N', 'ignore_disable': 'N', 'eco_info': '01', 'config_key': '00', 'language_code': 'en-CA'}

Let me know if I can test anything else!

@dekiesel
Copy link

Is there anything that should be tested before merging this PR? I am eager to see it merged.

@alex255
Copy link

alex255 commented Oct 28, 2023

i want to see this merged too :)

@andyscott
Copy link

👋🏽 I'd also like to see this merged. Is there anything I can do to help?

@michalstanczyk
Copy link

I can (unfortunately) confirm that on an older webOS version (6.3.3-442), C1 series "playing" status is not presented. But all other functionalities are working the same. So for version 6.x it's safe to merge, nothing is broken.

Copy link
Collaborator

@thecode thecode left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @rale 👍
Sorry for the delay, just got a TV connected back so I can test it.

@thecode thecode merged commit b4cd5bc into home-assistant-libs:main Feb 3, 2024
3 checks passed
@ghost
Copy link

ghost commented Feb 11, 2024

When do you think the update will be released in HA ?

@thecode
Copy link
Collaborator

thecode commented Feb 11, 2024

I can release a new version, but someone needs to work on it on HA side.
I will release a new version tomorrow so we can start working on HA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants