Library to control webOS based LG TV devices
Project description
aiowebostv
Python library to control LG webOS based TV devices.
Based on:
aiopylgtvlibrary at https://github.com/bendavid/aiopylgtvbscpylgtvlibrary at https://github.com/chros73/bscpylgtv
Requirements
- Python >= 3.11
Install
pip install aiowebostv
Install from Source
Run the following command inside this folder
pip install --upgrade .
Examples
Basic Example:
import asyncio
from pprint import pprint
from aiowebostv import WebOsClient
HOST = "192.168.1.39"
# For first time pairing set key to None
CLIENT_KEY = "140cce792ae045920e14da4daa414582"
async def main():
"""Basic webOS client example."""
client = WebOsClient(HOST, CLIENT_KEY)
await client.connect()
# Store this key for future use
print(f"Client key: {client.client_key}")
pprint(client.tv_info)
pprint(client.tv_state)
await client.disconnect()
if __name__ == "__main__":
asyncio.run(main())
Subscribed State Updates Example:
import asyncio
import dataclasses
import signal
from datetime import UTC, datetime
from pprint import pprint
from aiowebostv import WebOsClient
from aiowebostv.models import WebOsTvState
HOST = "192.168.1.39"
# For first time pairing set key to None
CLIENT_KEY = "140cce792ae045920e14da4daa414582"
async def on_state_change(tv_state: WebOsTvState) -> None:
"""State changed callback."""
now = datetime.now(UTC).astimezone().strftime("%H:%M:%S.%f")[:-3]
print(f"[{now}] State change:")
# for the example, remove apps and inputs to make the output more readable
state = dataclasses.replace(tv_state, apps={}, inputs={})
pprint(state)
async def main():
"""Subscribed State Updates Example."""
client = WebOsClient(HOST, CLIENT_KEY)
await client.register_state_update_callback(on_state_change)
await client.connect()
# Store this key for future use
print(f"Client key: {client.client_key}")
# Change something using the remote to get updates or ctrl-c to exit
sig_event = asyncio.Event()
signal.signal(signal.SIGINT, lambda _exit_code, _frame: sig_event.set())
await sig_event.wait()
await client.disconnect()
if __name__ == "__main__":
asyncio.run(main())
Examples can be found in the examples folder
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
aiowebostv-0.7.5.tar.gz
(19.8 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file aiowebostv-0.7.5.tar.gz.
File metadata
- Download URL: aiowebostv-0.7.5.tar.gz
- Upload date:
- Size: 19.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
88406409ce2fdbe7193f88df06db86304058135e13885847101b19e973f5b9b9
|
|
| MD5 |
2e6523dbed905f865d6a347e76dc7482
|
|
| BLAKE2b-256 |
809dac6ecbc122141a979a7e25caa36ccce8389290a3b8b02aefbafde0effcb6
|
File details
Details for the file aiowebostv-0.7.5-py3-none-any.whl.
File metadata
- Download URL: aiowebostv-0.7.5-py3-none-any.whl
- Upload date:
- Size: 19.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a900621298be87325ee2a40f46009d4cac5deb520b0c0a5e601ec86038b44c37
|
|
| MD5 |
cc0479765435dac9f59522a786bd100c
|
|
| BLAKE2b-256 |
4e374a63f38aca2139562c92bad3b2faa702d65368dd97f0ae184431ef7453ff
|