Control legacy LG TVs from circa 2012. More details here (link is an older Rust version).
./LGremote TV_IP TV_PORT
- show auth key on TV./LGremote TV_IP TV_PORT KEY
- show auth with TV (idk how long an auth lasts)./LGremote TV_IP TV_PORT CMD
- send command to TV (only works if already auth'd)./LGremote TV_IP TV_PORT KEY CMD
- Auth with TV then send command./LGremote TV_IP TV_PORT KEY SCREENSHOT OUTFILE.JPG
- Save a screenshot to a file
./LGremote 192.168.1.101 8080 6942069 HOME
- Opens the HOME
menu.
The command key HOME
, POWER
etc is case insenstive and ignores _
.
Where there is output:
./LGremote 192.168.1.101 8080 6942069 SCREENSHOT > screenshot.jpg
Uniquely, screenshot can also be done with an output file:
./LGremote 192.168.1.101 8080 6942069 SCREENSHOT screenshot.jpg
nim c --opt:speed --verbosity:0 LGremote.nim
There are roughly two types of commands that these TVs can accept.
- Post Commands a. HandleKeyInput - basically what you might press on a traditional controller - SUPPORTED b. Touch controls - what you would use a special controller for - NOT YET SUPPORTED
- Get Commands - request info about the current state - SUPPORTED
Command | Key | Notes |
---|---|---|
POWER | 1 | Can power the TV off but not on. Consider trying Wake on lan (not all TVs support this). |
NUM_0 | 2 | |
NUM_1 | 3 | |
NUM_2 | 4 | |
NUM_3 | 5 | |
NUM_4 | 6 | |
NUM_5 | 7 | |
NUM_6 | 8 | |
NUM_7 | 9 | |
NUM_8 | 10 | |
NUM_9 | 11 | |
UP | 12 | |
DOWN | 13 | |
LEFT | 14 | |
RIGHT | 15 | |
OK | 20 | |
HOME | 21 | |
MENU | 22 | |
BACK | 23 | |
VOLUME_UP | 24 | |
VOLUME_DOWN | 25 | |
MUTE | 26 | |
CHANNEL_UP | 27 | |
CHANNEL_DOWN | 28 | |
BLUE | 29 | |
GREEN | 30 | |
RED | 31 | |
YELLOW | 32 | |
PLAY | 33 | |
PAUSE | 34 | |
STOP | 35 | |
FF | 36 | |
REW | 37 | |
SKIP_FF | 38 | |
SKIP_REW | 39 | |
REC | 40 | |
REC_LIST | 41 | |
LIVE | 43 | |
EPG | 44 | |
INFO | 45 | |
ASPECT | 46 | |
EXT | 47 | |
PIP | 48 | |
SUBTITLE | 49 | |
PROGRAM_LIST | 50 | |
TEXT | 51 | |
MARK | 52 | |
3D | 400 | |
3D_LR | 401 | |
DASH | 402 | |
PREV | 403 | |
FAV | 404 | |
QUICK_MENU | 405 | |
TEXT_OPTION | 406 | |
AUDIO_DESC | 407 | |
NETCAST | 408 | |
ENERGY_SAVE | 409 | |
AV | 410 | |
SIMPLINK | 411 | |
EXIT | 412 | |
RESERVED | 413 | Does nothing? |
PIP_CHANNEL_UP | 414 | |
PIP_CHANNEL_DOWN | 415 | |
PIP_SWITCH | 416 | |
APPS | 417 |
Command | Target | Notes |
---|---|---|
SCREENSHOT | screen_image | Returns JPEG data in body |
CHANNEL | cur_channel | Returns XML data about current channel |
CHANNELS | channel_list | Returns XML list of channels programmed into computer |
VOLUME | volume_info | Returns XML data about min, max and current volume |
CONTEXT | context_ui | Returns XML data about the context, what controls can work etc |
3D | is_3d | Returns XML data if currently in 3D mode |
- HandleTouchMove - I'll need to log some traffic to workout format
- HandTouchClick - Ditto
- HandleTouchWheel - Ditto
- HandleChannelChange - Ditto
- AppExecute - Ditto!!!
Unfortunately official documentation doesn't seem to be available any longer but several libraries and scripts are available. node-lgtv-api[4] is by far the most complete and useful project.
- https://github.com/ubaransel/lgcommander
- https://github.com/grieve/python-lgtv - this is where the command codes are from largely.
- http://dorchain.net/~joerg/code/lg.py
- https://github.com/timmson/node-lgtv-api - most useful
- https://developer.lgappstv.com/TV_HELP/index.jsp?topic=%2Flge.tvsdk.references.book%2Fhtml%2FUDAP%2FUDAP%2FAnnex - defunct
- https://github.com/StefanNemeth/PHP-LG-SmartTV - Also very, very helpful
MIT licensed as that is in keeping with previous projects.