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

WebOS TV doesn't report media playback status #91709

Closed
rale opened this issue Apr 19, 2023 · 29 comments · Fixed by #113774
Closed

WebOS TV doesn't report media playback status #91709

rale opened this issue Apr 19, 2023 · 29 comments · Fixed by #113774
Assignees

Comments

@rale
Copy link
Contributor

rale commented Apr 19, 2023

The problem

The webostv integration isn't currently able to display media playing state.

From the previous discussion at #67681 (comment)_ it looks like the problem was that no one knew how to query it.

The required webos endpoint is "com.webos.media/getForegroundAppInfo", which you can request or subscribe to for updates, and the response looks like this:

{'subscribed': False, 'returnValue': True, 'foregroundAppInfo': [{'appId': 'com.webos.app.mediadiscovery', 'playState': 'paused', 'type': 'media', 'mediaId': '_xxxxxxx', 'windowId': '_Window_Id_3'}]}

What version of Home Assistant Core has the issue?

2023.4.5

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant Core

Integration causing the issue

webostv

Link to integration documentation on our website

No response

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

@thecode
Copy link
Member

thecode commented Apr 23, 2023

The endpoint you linked is not exposed from the outside, it is only available for applications running directly on the TV - bendavid/aiopylgtv#39 (comment)

I have tested this endpoint in the past with no success. If you have a working version please create a PR to add it to https://github.com/home-assistant-libs/aiowebostv

@home-assistant
Copy link

@rale
Copy link
Contributor Author

rale commented Apr 23, 2023

OK, did some more testing. It looks like it's only available on newer versions.

On my C2 with the latest firmware (webOS 7.3.0-2402) it's accessible remotely, but on my older tv running webOS 3.9.0, it just 404s.

@rale
Copy link
Contributor Author

rale commented May 5, 2023

I went ahead and got it working in home assistant now. If needed, I can make a PR for it as well, if home-assistant-libs/aiowebostv#178 is merged.

@prosenba1
Copy link

I'm interested in try this solution. Would it be possible to test it somehow? Thanks in advance!

@rale
Copy link
Contributor Author

rale commented Jul 25, 2023

Sure, you'll need to replace the aiowebostv package with my version here: https://github.com/rale/aiowebostv/tree/main and patch webostv/media_player.py something like this: dev...rale:core:webos_media_state

@Sergey-SRG
Copy link

Sergey-SRG commented Aug 5, 2023

OK, did some more testing. It looks like it's only available on newer versions.

On my C2 with the latest firmware (webOS 7.3.0-2402) it's accessible remotely, but on my older tv running webOS 3.9.0, it just 404s.

Old version tv run:
luna-send -i 'luna://com.webos.service.acb/getForegroundAppInfo' '{"subscribe":true}'
Return:
{ "returnValue": true, "appId": "cdp-30", "windowType": "_WEBOS_WINDOW_TYPE_CARD", "acbs": [ { "pipelineId": "_DQkpIEevD7jSbF", "playerType": "video", "playStateNow": "playing", "playStateNext": "playing", "isFullScreen": true, "positionX": 0, "positionY": 0, "width": 1920, "height": 1080 } ], "subscribed": true }

@Sergey-SRG
Copy link

Based on the above, it turned out to create a pause sensor:
command_line:

  • sensor:
    command: >
    echo "luna-send -n 1 luna://com.webos.service.acb/getForegroundAppInfo '{"subscribe":"false"}' & exit" | curl --raw --max-time 1 telnet://192.168.0.62:23 2>&1 | grep -c paused
    scan_interval: 30
    value_template: "{{(value == '1') | iif('on','off','unwkown')}}"
    unique_id: "tv_livingroom_paused"
    name: "TV livingroom paused"

@Lipown
Copy link

Lipown commented Aug 6, 2023

Looking forward for release

@SLG
Copy link

SLG commented Aug 7, 2023

For older (and maybe newer?) tv's this might work as well: https://github.com/SLG/tv-service
It's a bit more work to set up and use, but when running, it works!

@Sergey-SRG
Copy link

@SLG you can test the endpoint com.webos.service.acb/getForegroundAppInfo on your webos and report the result with the webos version (com.webos.service.systemservice/osInfo/query)

@rale
Copy link
Contributor Author

rale commented Aug 8, 2023

I was able to test and confirm it's also working on another TV, a QNED85 with latest firmware, webOS 7.3.1-37.

@Sergey-SRG
Copy link

@rale it is worth rewriting the code to use endpoint com.webos.service.acb/getForegroundAppInfo since it works on old and new versions of webos.

@rale
Copy link
Contributor Author

rale commented Aug 9, 2023

Sorry, I was referring to com.webos.media/getForegroundAppInfo working. As far as I can tell, you can only access com.webos.service.acb/getForegroundAppInfo from locally on the tv, not through the remote API.

@prosenba1
Copy link

Sure, you'll need to replace the aiowebostv package with my version here: https://github.com/rale/aiowebostv/tree/main and patch webostv/media_player.py something like this: dev...rale:core:webos_media_state

I didn't understand where to patch, so I wasn;t able to test it. Do you know if this upgrade will be released in home assistant? Thanks!!

@dekiesel
Copy link

dekiesel commented Aug 30, 2023

For older (and maybe newer?) tv's this might work as well: https://github.com/SLG/tv-service

This seems like a much better basis since, from what I understand, this means we could see what is being played, not only whether something is playing.
Scratch that, I didn't realise I was looking at the webos open source page.

@RosaliePerron
Copy link

When is this expected to be merged?

@dekiesel
Copy link

When is this expected to be merged?

My understanding is that this needs to be merged first, but it is waiting for testers. If you have a TV with a webos version older than 7.3.1 you can help the merge process by testing what happens on your tv.

@RosaliePerron
Copy link

My tv is at version 5.4.3-36, how can I test that? I'm new to HA so I'm not sure where to begin with testing a pre-release version

@dekiesel
Copy link

dekiesel commented Sep 21, 2023

You need at least python 3.9.

First check out the code from the PR:

git clone https://github.com/rale/aiowebostv.git

Then you need to open the folder containing the code

cd aiowebostv/

In this folder create a file with the following code (let's call the file mediastate.py):

import asyncio

from aiowebostv import WebOsClient

HOST = "192.168.178.170" #THE IP OF YOUR TV GOES HERE
CLIENT_KEY = "None"


async def on_state_change(client):
    """State changed callback."""
    print("State changed:")
    print(f"System info: {client.system_info}")
    print(f"Media State: {client.media_state}")
    print(f"Software info: {client.software_info}")

async def main():
    """Basic webOS client example."""
    client = WebOsClient(HOST, CLIENT_KEY)
    await client.connect()

    await client.register_state_update_callback(on_state_change)
    await asyncio.sleep(60)

if __name__ == "__main__":
    asyncio.run(main())
  1. Turn on the TV.
  2. Change the IP to the IP of your TV.
  3. Run the code: python3.9 mediastate.py

The TV should ask you whether you want to let the mobile device connect (mine did, at least, idk how it is with lower version numbers).

Then start playing something, pause it, stop it, and so on.

You should see new lines flying down your computer screen.

Copy let's say 10 lines of that output and paste them in the PR I linked so they know what happens on lower versions.

@issue-triage-workflows
Copy link

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates.
Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍
This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

@dekiesel
Copy link

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

Since this is waiting for a pr to be merged i don't think this should be considered stale.

@github-actions github-actions bot removed the stale label Dec 21, 2023
@Mincka
Copy link

Mincka commented Jan 15, 2024

Hi,
I just want to confirm that it sadly does not work with webOS 4.5 (latest version available on C9).
Tested with com.webos.media/getForegroundAppInfo or com.webos.service.acb/getForegroundAppInfo.

State changed:
System info: {'returnValue': True, 'features': {'3d': False, 'dvr': True}, 'receiverType': 'dvb', 'modelName': 'OLED65C9PLA', 'programMode': 'true'}
Media State: {}
Software info: {'returnValue': True, 'product_name': 'webOSTV 4.5', 'model_name': 'HE_DTV_W19O_XXXXXX', 'sw_type': 'FIRMWARE', 'major_ver': '05', 'minor_ver': '30.40', 'country': 'FR', 'country_group': 'EU', 'device_id': 'xxxxxxxxxx', 'auth_flag': 'N', 'ignore_disable': 'N', 'eco_info': '01', 'config_key': '00', 'language_code': 'fr-FR'}

Only tested remotely with @rale fork.

I did not test locally with
luna-send -i 'luna://com.webos.service.acb/getForegroundAppInfo' '{"subscribe":true}'

@rale
Copy link
Contributor Author

rale commented Jan 17, 2024

I set up a custom component repo for anyone who wants to test or just wants to use media player status. You should be able to just add it as a custom repo in HACS and install it, then add the LG TV integration.

https://github.com/rale/lgtv

@Lipown
Copy link

Lipown commented Jan 29, 2024

I set up a custom component repo for anyone who wants to test or just wants to use media player status. You should be able to just add it as a custom repo in HACS and install it, then add the LG TV integration.

https://github.com/rale/lgtv

But it reports just on / off state isnt it? It does not report playing...

@rale
Copy link
Contributor Author

rale commented Jan 30, 2024

I set up a custom component repo for anyone who wants to test or just wants to use media player status. You should be able to just add it as a custom repo in HACS and install it, then add the LG TV integration.
https://github.com/rale/lgtv

But it reports just on / off state isnt it? It does not report playing...

What model tv / webos version do you have? It should show playing or paused for any newer TVs with the api available.

@issue-triage-workflows
Copy link

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates.
Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍
This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

@dekiesel
Copy link

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

The pr isn't merged yet.

@Solom00n
Copy link

Solom00n commented May 5, 2024

@thecode I'm eager to use this feature 😃. Do you know when it will be released?

@github-actions github-actions bot locked and limited conversation to collaborators Jun 4, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants