Last active
February 12, 2025 19:39
-
-
Save keithstellyes/85ff116aebcc500b4f11f66e4bf3808b to your computer and use it in GitHub Desktop.
Start up LG TV and open Netflix on connected Chromecast
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!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() |
Author
Author
To get different ChromeCast app IDs: home-assistant-libs/pychromecast#518
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
requirements.txt