core
core copied to clipboard
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
The endpoint you linked is not exposed from the outside, it is only available for applications running directly on the TV - https://github.com/bendavid/aiopylgtv/issues/39#issuecomment-1014702695
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
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.
I went ahead and got it working in home assistant now. If needed, I can make a PR for it as well, if https://github.com/home-assistant-libs/aiowebostv/pull/178 is merged.
I'm interested in try this solution. Would it be possible to test it somehow? Thanks in advance!
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: https://github.com/home-assistant/core/compare/dev...rale:core:webos_media_state
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 }
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"
Looking forward for release
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!
@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)
I was able to test and confirm it's also working on another TV, a QNED85 with latest firmware, webOS 7.3.1-37.
@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.
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.
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!!
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.
When is this expected to be merged?
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.
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
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())
- Turn on the TV.
- Change the IP to the IP of your TV.
- 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.
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.
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.
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}'
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
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...
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.
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.
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.
@thecode I'm eager to use this feature 😃. Do you know when it will be released?