Change lib to only support 2011 models
This commit is contained in:
parent
22c7791baa
commit
2521428614
2 changed files with 149 additions and 76 deletions
|
@ -7,4 +7,5 @@ if __name__ == "__main__":
|
||||||
key = raw_input('Enter pairing key: ')
|
key = raw_input('Enter pairing key: ')
|
||||||
remote.set_pairing_key(key)
|
remote.set_pairing_key(key)
|
||||||
|
|
||||||
remote.send_command(Remote.VOLUME_UP)
|
print("EXAMPLE: remote.send_command(INSERT_CMD_HERE, remote.session)")
|
||||||
|
import pdb; pdb.set_trace()
|
||||||
|
|
222
lg.py
222
lg.py
|
@ -23,12 +23,13 @@ class Remote():
|
||||||
|
|
||||||
self.pair_key = pair_key
|
self.pair_key = pair_key
|
||||||
self.ip_address = ip_address
|
self.ip_address = ip_address
|
||||||
|
self.session = None
|
||||||
|
|
||||||
if not self.ip_address:
|
if not self.ip_address:
|
||||||
raise Remote.NoTVFound
|
raise Remote.NoTVFound
|
||||||
|
|
||||||
if self.pair_key:
|
if self.pair_key:
|
||||||
self.get_session()
|
self.session = self.get_session()
|
||||||
else:
|
else:
|
||||||
self.request_pair()
|
self.request_pair()
|
||||||
|
|
||||||
|
@ -82,7 +83,7 @@ class Remote():
|
||||||
"""
|
"""
|
||||||
|
|
||||||
self.pair_key = pair_key
|
self.pair_key = pair_key
|
||||||
self.get_session()
|
self.session = self.get_session()
|
||||||
|
|
||||||
def make_request(self, endpoint, content, extra_headers={}):
|
def make_request(self, endpoint, content, extra_headers={}):
|
||||||
"""
|
"""
|
||||||
|
@ -108,7 +109,7 @@ class Remote():
|
||||||
<type>AuthKeyReq</type>
|
<type>AuthKeyReq</type>
|
||||||
</auth>
|
</auth>
|
||||||
"""
|
"""
|
||||||
self.make_request('/roap/api/auth', content)
|
self.make_request('/hdcp/api/auth', content)
|
||||||
|
|
||||||
def get_session(self):
|
def get_session(self):
|
||||||
"""
|
"""
|
||||||
|
@ -122,10 +123,10 @@ class Remote():
|
||||||
<value>{0}</value>
|
<value>{0}</value>
|
||||||
</auth>
|
</auth>
|
||||||
""".format(self.pair_key)
|
""".format(self.pair_key)
|
||||||
response = self.make_request('/roap/api/auth', content)
|
response = self.make_request('/hdcp/api/auth', content)
|
||||||
return response.find('session').text
|
return response.find('session').text
|
||||||
|
|
||||||
def send_command(self, code):
|
def send_command(self, code, session):
|
||||||
"""
|
"""
|
||||||
Send a remote control key command. Ignores response for now.
|
Send a remote control key command. Ignores response for now.
|
||||||
"""
|
"""
|
||||||
|
@ -135,11 +136,12 @@ class Remote():
|
||||||
content = """
|
content = """
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<command>
|
<command>
|
||||||
<name>HandleKeyInput</name>
|
<session>{1}</session>
|
||||||
|
<type>HandleKeyInput</type>
|
||||||
<value>{0}</value>
|
<value>{0}</value>
|
||||||
</command>
|
</command>
|
||||||
""".format(code)
|
""".format(code, session)
|
||||||
self.make_request('/roap/api/command', content)
|
self.make_request('/hdcp/api/dtv_wifirc', content)
|
||||||
|
|
||||||
def send_multiple(self, codes, delay=0.2):
|
def send_multiple(self, codes, delay=0.2):
|
||||||
"""
|
"""
|
||||||
|
@ -149,7 +151,7 @@ class Remote():
|
||||||
"""
|
"""
|
||||||
|
|
||||||
for code in codes:
|
for code in codes:
|
||||||
self.send_command(code)
|
self.send_command(code, self.session)
|
||||||
time.sleep(delay)
|
time.sleep(delay)
|
||||||
|
|
||||||
# exceptions
|
# exceptions
|
||||||
|
@ -168,71 +170,141 @@ class Remote():
|
||||||
"""
|
"""
|
||||||
|
|
||||||
pass
|
pass
|
||||||
|
# heavily inspired by https://github.com/dreamcat4/lgremote/blob/master/lgremote
|
||||||
|
commands = {}
|
||||||
|
|
||||||
# command code shortcuts
|
# all work with 42LW579S-ZD
|
||||||
|
menus = {
|
||||||
|
"STATUS_BAR" : 35,
|
||||||
|
"QUICK_MENU" : 69,
|
||||||
|
"HOME_MENU" : 67,
|
||||||
|
"PREMIUM_MENU" : 89
|
||||||
|
}
|
||||||
|
|
||||||
POWER = 1
|
# all work with 42LW579S-ZD
|
||||||
NUM_0 = 2
|
power_controls = {
|
||||||
NUM_1 = 3
|
"POWER" : 8,
|
||||||
NUM_2 = 4
|
"SLEEP_MENU" : 14
|
||||||
NUM_3 = 5
|
}
|
||||||
NUM_4 = 6
|
|
||||||
NUM_5 = 7
|
# all work with 42LW579S-ZD
|
||||||
NUM_6 = 8
|
navigation_controls = {
|
||||||
NUM_7 = 9
|
"LEFT" : 7,
|
||||||
NUM_8 = 10
|
"RIGHT" : 6,
|
||||||
NUM_9 = 11
|
"UP" : 64,
|
||||||
UP = 12
|
"DOWN" : 65,
|
||||||
DOWN = 13
|
"SELECT" : 68,
|
||||||
LEFT = 14
|
"BACK" : 40,
|
||||||
RIGHT = 15
|
"EXIT" : 91,
|
||||||
OK = 20
|
"RED" : 114,
|
||||||
HOME = 21
|
"GREEN" : 113,
|
||||||
MENU = 22
|
"YELLOW" : 99,
|
||||||
BACK = 23
|
"BLUE" : 97
|
||||||
VOLUME_UP = 24
|
}
|
||||||
VOLUME_DOWN = 25
|
|
||||||
MUTE = 26
|
# all work with 42LW579S-ZD
|
||||||
CHANNEL_UP = 27
|
keypad_controls = {
|
||||||
CHANNEL_DOWN = 28
|
"0" : 16,
|
||||||
BLUE = 29
|
"1" : 17,
|
||||||
GREEN = 30
|
"2" : 18,
|
||||||
RED = 31
|
"3" : 19,
|
||||||
YELLOW = 32
|
"4" : 20,
|
||||||
PLAY = 33
|
"5" : 21,
|
||||||
PAUSE = 34
|
"6" : 22,
|
||||||
STOP = 35
|
"7" : 23,
|
||||||
FF = 36
|
"8" : 24,
|
||||||
REW = 37
|
"9" : 25,
|
||||||
SKIP_FF = 38
|
"_" : 76,
|
||||||
SKIP_REW = 39
|
}
|
||||||
REC = 40
|
|
||||||
REC_LIST = 41
|
# untested
|
||||||
LIVE = 43
|
playback_controls = {
|
||||||
EPG = 44
|
"PLAY" : 176,
|
||||||
INFO = 45
|
"PAUSE" : 186,
|
||||||
ASPECT = 46
|
"FAST_FORWARD" : 142,
|
||||||
EXT = 47
|
"REWIND" : 143,
|
||||||
PIP = 48
|
"STOP" : 177,
|
||||||
SUBTITLE = 49
|
"RECORD" : 189
|
||||||
PROGRAM_LIST = 50
|
}
|
||||||
TEXT = 51
|
|
||||||
MARK = 52
|
# untested
|
||||||
_3D = 400
|
tv_controls = {
|
||||||
_3D_LR = 401
|
"CHANNEL_UP" : 0,
|
||||||
DASH = 402
|
"CHANNEL_DOWN" : 1,
|
||||||
PREV = 403
|
"CHANNEL_BACK" : 26,
|
||||||
FAV = 404
|
"FAVORITES" : 30,
|
||||||
QUICK_MENU = 405
|
"TELETEXT" : 32,
|
||||||
TEXT_OPTION = 406
|
"T_OPT" : 33,
|
||||||
AUDIO_DESC = 407
|
"CHANNEL_LIST" : 83,
|
||||||
NETCAST = 408
|
"GUIDE" : 169,
|
||||||
ENERGY_SAVE = 409
|
"INFO_TOGGLE" : 170,
|
||||||
AV = 410
|
"INFO" : 217,
|
||||||
SIMPLINK = 411
|
"LIVE_TV" : 158
|
||||||
EXIT = 412
|
}
|
||||||
RESERVE = 413
|
|
||||||
PIP_CHANNEL_UP = 414
|
# all work with 42LW579S-ZD
|
||||||
PIP_CHANNEL_DOWN = 415
|
input_controls = {
|
||||||
PIP_SWITCH = 416
|
"TV_RADIO" : 15,
|
||||||
APPS = 417
|
"SIMPLINK" : 126,
|
||||||
|
"INPUT" : 11,
|
||||||
|
"COMPONENT_RGB_HDMI" : 152,
|
||||||
|
"RGB" : 213, #215 seems to do the same
|
||||||
|
"COMPONENT" : 191,
|
||||||
|
"ANTENNA" : 214, #240 does the same without channels programmed. 240 could also be CABLE input
|
||||||
|
"HDMI" : 198,
|
||||||
|
"HDMI1" : 206,
|
||||||
|
"HDMI2" : 204,
|
||||||
|
"HDMI3" : 233,
|
||||||
|
"HDMI4" : 218,
|
||||||
|
"AV1" : 90,
|
||||||
|
"AV2" : 208,
|
||||||
|
"AV3" : 209,
|
||||||
|
"USB" : 124,
|
||||||
|
"SLIDESHOW_USB1" : 238,
|
||||||
|
"SLIDESHOW_USB2" : 168
|
||||||
|
}
|
||||||
|
|
||||||
|
# should work
|
||||||
|
audio_controls = {
|
||||||
|
"VOLUME_UP" : 2,
|
||||||
|
"VOLUME_DOWN" : 3,
|
||||||
|
"MUTE" : 9,
|
||||||
|
"AUDIO" : 10,
|
||||||
|
"SOUND_MODE" : 82,
|
||||||
|
"SUBTITLE_LANGUAGE" : 57,
|
||||||
|
"AUDIO_DESCRIPTION" : 145,
|
||||||
|
"FACTORY_SOUND_CHECK" : 253
|
||||||
|
}
|
||||||
|
|
||||||
|
# all work with 42LW579S-ZD
|
||||||
|
picture_controls = {
|
||||||
|
"AV_MODE" : 48,
|
||||||
|
"PICTURE_MODE" : 77,
|
||||||
|
"RATIO" : 121,
|
||||||
|
"RATIO_4_3" : 118,
|
||||||
|
"RATIO_16_9" : 119,
|
||||||
|
"ENERGY_SAVING" : 149, #only works as expected in quick-menu. Outside of it it sets Energy Saving to Auto and toggles the GREEN_EYE_CHECK menu. Maybe due to previous tinkering with POWER_ONLY mode.
|
||||||
|
"CINEMA_ZOOM" : 175,
|
||||||
|
"3D" : 220,
|
||||||
|
"FACTORY_PICTURE_CHECK" : 252
|
||||||
|
}
|
||||||
|
|
||||||
|
# not sure about these
|
||||||
|
self_diagnosis = {
|
||||||
|
"DIAG1" : 164,
|
||||||
|
"DIAG2" : 165,
|
||||||
|
"DIAG3" : 173,
|
||||||
|
"DIAG4" : 188,
|
||||||
|
"DIAG5" : 190,
|
||||||
|
"PICTURE_TEST" : 249
|
||||||
|
}
|
||||||
|
|
||||||
|
# see: http://openlgtv.org.ru/wiki/index.php/Hidden_service_modes_/_menus
|
||||||
|
hidden_menues = {
|
||||||
|
"INSTALLATION_MENU" : 207,
|
||||||
|
"POWER_ONLY" : 254,
|
||||||
|
"EZ_ADJUST" : 255,
|
||||||
|
"IN_START" : 251
|
||||||
|
}
|
||||||
|
|
||||||
|
HAPPENS_WITHOUT_CONFIRMATION = { "FACTORY_RESET" : 250 }
|
||||||
|
|
Loading…
Reference in a new issue