python-lgtv/README.md

46 lines
1.6 KiB
Markdown
Raw Permalink Normal View History

2014-07-04 00:35:42 +02:00
python-lgtv
===========
2019-01-31 18:21:16 +01:00
Simple class for pairing with and controlling your 2011 LG TV with python.
**For 2012+ TVs check out the original of this fork at https://github.com/grieve/python-lgtv**
2017-11-08 10:46:05 +01:00
**This library does not appear to support the newer WebOS LG TVs. Please see https://github.com/klattimer/LGWebOSRemote if this does not work for you.**
You can find all TVs on the network using the `find_tvs` class method.
2019-01-31 18:21:16 +01:00
**This was only tested with a 42LW579S-ZD
```
from lg import Remote
addresses = Remote.find_tvs()
```
If you have only one, it'll be faster to use the `first_only` parameter.
```
address = Remote.find_tvs(first_only=True)
```
2019-01-31 18:21:16 +01:00
You will need a pairing key, if you already know it you can initiate the Remote class with it as second parameter. Otherwise you can create your remote control instance and it'll ask the TV to display it onscreen. You can then provide this pairing key using the `set_pairing_key` method.
```
remote = Remote(address)
# Pairing key will appear on screen
key = raw_input('Please enter pairing key: ')
remote.set_pairing_key(key)
```
After this you can send single or multiple commands using `send_command` and `send_multiple`.
```
2019-01-31 19:31:11 +01:00
remote.send_command(Remote.audio_controls["VOLUME_UP"])
commands = [Remote.HOME, Remote.EXIT, Remote.MENU]
remote.send_multiple(commands)
```
2014-07-04 10:29:46 +02:00
An optional `delay` parameter can be provided to `send_multiple`; this will the amount of seconds the control will wait between commands. N.B. Sending commands too fast can cause some of them to be ignored.
2019-01-31 19:31:11 +01:00
Shortcuts-structure is subject to change. They still can be looked up in `lg.py`. Be careful on your journey!