core: WebOS TV doesn't report media playback status

The problem

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

From the previous discussion at https://github.com/home-assistant/core/issues/67681#issuecomment-1059727183_ 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

About this issue

  • Original URL
  • State: open
  • Created a year ago
  • Comments: 26 (8 by maintainers)

Most upvoted comments

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

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.

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…

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!