Skip to content

Instantly share code, notes, and snippets.

@Kuchiru
Last active June 12, 2024 10:02
Show Gist options
  • Save Kuchiru/55e1b509a85cbece056dc7196d5c7385 to your computer and use it in GitHub Desktop.
Save Kuchiru/55e1b509a85cbece056dc7196d5c7385 to your computer and use it in GitHub Desktop.
LG WebOS 4.9 Custom mediastate endpoint - Home Assistant
This custom integration will only work if you have followed the steps for your rooted TV.
Disable your LG WebOS integration.
Install HACS.
Add the custom respository: https://github.com/Kuchiru/lgtv/
Install the newly added LG TV integration.
Reboot Home Assistant
Go to settings, devices & services, add integration, and search for "LG TV"
Pick the one with the white square as icon.
Turn on your TV and enter the TV IP, confirm.
Confirm the access pop up on your tv.
!! This requires a Rooted TV with SSH access !!
I tested this on my own TV running WebOS 4.9, it may work for other versions but i am not able to test this.
SSH into your TV and run the following commands - THIS IS AT YOUR OWN RISK.
# Test if the endpoint is available to you
luna-send -n 1 luna://com.webos.service.acb/getForegroundAppInfo '{"subscribe":"false"}'
# The response should look like this
{ "returnValue": true, "appId": "cdp-30", "windowType": "_WEBOS_WINDOW_TYPE_CARD", "acbs": [ { "pipelineId": "_Ft70RTmNvefyJe", "playerType": "video", "playStateNow": "playing", "playStateNext": "playing", "isFullScreen": true, "positionX": 0, "positionY": 0, "width": 1920, "height": 1080 } ] }
Credit for figuring out the commands below goes to infowski.
# Create config overrides directory
mkdir -p /home/root/extra-interfaces
# Create config override/addition manifest file
echo '{"service": "com.webos.service.acb","methods": [{"path": "/getForegroundAppInfo","description": "get foreground","requiredPermissions": ["LAUNCH"]}]}' > /home/root/extra-interfaces/com.webos.service.acb.interface
# Enable config override
mount -t overlay overlay -olowerdir=/usr/palm/services/com.webos.service.secondscreen.gateway/interfaces:/home/root/extra-interfaces /usr/palm/services/com.webos.service.secondscreen.gateway/interfaces
# Restart ssap service - the states will be immediately available after this but will not persist when you restart your tv.
pkill -9 -f ss.apiadapter ; pkill -9 -f ss.gateway
# To persist the override add config override to init.d
echo 'mount -t overlay overlay -olowerdir=/usr/palm/services/com.webos.service.secondscreen.gateway/interfaces:/home/root/extra-interfaces /usr/palm/services/com.webos.service.secondscreen.gateway/interfaces' > /var/lib/webosbrew/init.d/override
echo 'pkill -9 -f ss.apiadapter ; pkill -9 -f ss.gateway' >> /var/lib/webosbrew/init.d/override
# Make override executable
chmod +x /var/lib/webosbrew/init.d/override
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment