Skip to content

Instantly share code, notes, and snippets.

@keithstellyes
Last active February 12, 2025 19:39
Show Gist options
  • Select an option

  • Save keithstellyes/85ff116aebcc500b4f11f66e4bf3808b to your computer and use it in GitHub Desktop.

Select an option

Save keithstellyes/85ff116aebcc500b4f11f66e4bf3808b to your computer and use it in GitHub Desktop.
Start up LG TV and open Netflix on connected Chromecast
#!venv/bin/python
import asyncio, json
import time
from aiowebostv import WebOsClient
import pychromecast
import zeroconf
HOST = "LGWebOsTV.local"
CLIENT_KEY = None
try:
with open('clientkey', 'r') as f:
CLIENT_KEY = f.read().strip()
except FileNotFoundError:
print('Failed to get client key. Will request one but will not save it.')
async def tohdmi():
client = WebOsClient(HOST, CLIENT_KEY)
await client.connect()
# Store this key for future use
print(f"Client key: {client.client_key}")
await client.launch_app('com.webos.app.hdmi1')
await client.disconnect()
def open_netflix():
print('getting chromecasts')
casts, browser = pychromecast.get_chromecasts()
cast = casts[0]
cast.wait()
cast.start_app('Netflix')
if __name__ == "__main__":
asyncio.run(tohdmi())
open_netflix()
@keithstellyes
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment