Skip to main content

Library to remote control LG Web OS TV

Project description

# PyWebOSTV
[![Build Status](https://api.travis-ci.org/supersaiyanmode/PyWebOSTV.svg?branch=develop)](https://travis-ci.org/supersaiyanmode/PyWebOSTV)
[![Coverage Status](https://coveralls.io/repos/github/supersaiyanmode/PyWebOSTV/badge.svg?branch=master)](https://coveralls.io/github/supersaiyanmode/PyWebOSTV?branch=master)

### Why another Library?
I looked at a few libraries. The LGWebOSRemote repository by
[klattimer](https://github.com/klattimer/LGWebOSRemote) is definitely a good library, but it has a few problems:
- Meant to be used with Python 2.x.
- Assumes all the users of the library would like to save the credentials to ~/.lgtv.json.
- Assumes only a single command will be fired and waited on at any given time (ctrl+F for `self.__waiting_callback`)
- Mouse/Keyboard not supported.

This SDK is a tiny attempt at overcoming some of the above problems.


### Current status?
~~At the moment, I haven't been able to do any kind of extensive testing. No unit test cases too!~~ Current status: Works for quite a few people! :)

Currently working on more controls and unit test cases. Upon testing, I will upload it to PyPI.

### How to use it?

```
from pywebostv.discovery import *
from pywebostv.connection import *
from pywebostv.controls import *

# The 'store' gets populated during the registration process. If it is
# empty, a registration prompt will show up on the TV. You can pass any
# dictionary-like interface instead -- that when values are set, will
# persist to a DB, a config file or something similar.
store = {}

# Scans the current network to discover TV. Avoid [0] in real code.
# If you already know the IP, you could skip the slow scan and
# instead simply say:
# client = WebOSClient("<IP Address of TV>")
client = WebOSClient.discover()[0]
client.connect()
for status in client.register(store):
if status == WebOSClient.PROMPTED:
print("Please accept the connect on the TV!")
elif status == WebOSClient.REGISTERED:
print("Registration successful!")
```

#### Media Controls

```
media = MediaControl(client)
media.volume_up()
media.volume_down()
media.get_volume()
media.set_volume(<int>)
media.mute(<mute status as boolean>)
media.play()
media.pause()
media.stop()
media.rewind()
media.fast_forward()
```

#### System Controls

```
system = SystemControl(client)
system.notify("This is a notification message!")
system.power_off()
system.info()
```

#### Application Controls

```
app = ApplicationControl(client)
apps = app.list_apps()
launch_info = app.launch(apps[0], content_id="...", params=...)
app.close(launch_info)
```

#### Mouse and Button Controls

You need to execute the first two commands.
```
inp = InputControl(client)
inp.connect_input()
inp.move(10, 10) # Moves mouse
inp.click()
inp.up()
inp.down()
inp.left()
inp.right()
inp.home()
inp.back()

# Following 3 lines are valid only when an input field is focussed on TV.
inp.type("This sends keyboard input!")
inp.enter() # Return key.
inp.delete(10) # Backspace 10 chars

inp.disconnect_input()
```

#### TV Controls

```
tv_control = TvControl()
tv_control.channel_down()
tv_control.channel_up()
```

#### Source Controls

```
source_control = SourceControl(client)
sources = source_control.list_sources()
source_control.set_source(sources[0])
```

More controls coming soon!


# Credits
- [klattimer](https://github.com/klattimer/LGWebOSRemote) for his library! Since WebOS team decided against providing any sort of documentation, his repository was extremely useful for an initial implementation
- As far as input controls are concerned, they are based on the Java package written by [Connect-SDK folks](https://github.com/ConnectSDK/Connect-SDK-Android-Core/tree/master/src/com/connectsdk/service/webos)!


Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pywebostv-0.8.2.tar.gz (8.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pywebostv-0.8.2-py3-none-any.whl (11.7 kB view details)

Uploaded Python 3

File details

Details for the file pywebostv-0.8.2.tar.gz.

File metadata

  • Download URL: pywebostv-0.8.2.tar.gz
  • Upload date:
  • Size: 8.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for pywebostv-0.8.2.tar.gz
Algorithm Hash digest
SHA256 2ba7739d8572734622283cec13c093bc44319744833d2a069b70d4f18722918c
MD5 cccc386564a2b926ead8e7f88ce1dbae
BLAKE2b-256 90c7383c8fd9a27a77df737a52954492e2c403200ea6c54fecf19c1d0efe80d9

See more details on using hashes here.

File details

Details for the file pywebostv-0.8.2-py3-none-any.whl.

File metadata

File hashes

Hashes for pywebostv-0.8.2-py3-none-any.whl
Algorithm Hash digest
SHA256 e5efca66d231c7523012003e6222a8b7ae05c6dc2bbffbd2d43d9b3fbca3ad24
MD5 add151e5e33e6bfc6e51e50b0d36ba56
BLAKE2b-256 b2f1756951755fe48e9686d01b1ca97d4a2fda90032e93a7f8cd9dd88d53d9af

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page