# Shows all available commands for your TV # from libLGTV_serial import LGTV # Change this to your TV's model model = '42LW650s' tv = LGTV(model, 'dont_care') # Example of adding a custom toggle command. Passing in '--toggleinput' # will toggle between 'inputrgbpc' and 'inputdigitalcable' tv.add_toggle('input', 'inputrgbpc', 'inputdigitalcable') tv.available_commands()
model = '32LW300C-ZA' # Change this to your TV's model # Change this to the serial port you're using # On Linux it might look like '/dev/ttyS0' # On a Mac it might look like '/dev/tty.usbmodemfa2321' serial_port = "/dev/ttyUSB0" # Verify passed command if len(sys.argv) != 2: print('Usage: {0} <command>'.format(sys.argv[0])) print('Example: {0} --togglepower'.format(sys.argv[0])) sys.exit(1) tv = LGTV(model, serial_port) # Example of adding a custom toggle command. Passing in '--toggleinput' # will toggle between 'inputrgbpc' and 'inputdigitalcable' tv.add_toggle('input', 'inputrgbpc', 'inputdigitalcable') tv.add_toggle('lock', 'lockon', 'lockoff') # Sometimes a single remote button press is detected as many. By debouncing a # command, we make sure its only called once per button press. tv.debounce('togglepower') tv.debounce('togglelock') # Finally, send the command # .send() Returns nothing on failure, 2-digit bytecode for status commands, # and True for other commands print(tv.send(sys.argv[1].lstrip("--")))
from libLGTV_serial import LGTV model = '42LK450' # Change this to your TV's model # Change this to the serial port you're using # On Linux it might look like '/dev/ttyS0' # On a Mac it might look like '/dev/tty.usbmodemfa2321' serial_port = "\\.\COM4" # Verify passed command if len(sys.argv) != 2: print('Usage: {0} <command>'.format(sys.argv[0])) print('Example: {0} --togglepower'.format(sys.argv[0])) sys.exit(1) tv = LGTV(model, serial_port) # Example of adding a custom toggle command. Passing in '--toggleinput' # will toggle between 'inputhdmi1' and 'inputhdmi2' tv.add_toggle('input', 'inputhdmi1', 'inputhdmi2') tv.add_toggle('screenoff', 'ecooff', 'ecoscreenoff') # Sometimes a single remote button press is detected as many. By debouncing a # command, we make sure its only called once per button press. tv.debounce('togglepower') # Finally, send the command # .send() Returns nothing on failure, 2-digit bytecode for status commands, # and True for other commands print(tv.send(sys.argv[1].lstrip("--")))
# Shows all available commands for your TV # from libLGTV_serial import LGTV model = '42LK450' # Change this to your TV's model tv = LGTV(model, 'dont_care') # Example of adding a custom toggle command. Passing in '--toggleinput' # will toggle between 'inputrgbpc' and 'inputdigitalcable' tv.add_toggle('input', 'inputrgbpc', 'inputdigitalcable') tv.available_commands() input("Press Enter to continue...")
from libLGTV_serial import LGTV # Change this to your TV's model model = '42LW650s' # Change this to the serial port you're using # On Linux it might look like '/dev/ttyS0' # On a Mac it might look like '/dev/tty.usbmodemfa2321' serial_port = "/dev/ttyS0" # Verify passed command if len(sys.argv) != 2: print('Usage: {0} <command>'.format(sys.argv[0])) print('Example: {0} --togglepower'.format(sys.argv[0])) sys.exit(1) tv = LGTV(model, serial_port) # Example of adding a custom toggle command. Passing in '--toggleinput' # will toggle between 'inputrgbpc' and 'inputdigitalcable' tv.add_toggle('input', 'inputrgbpc', 'inputhdmi1') # Sometimes a single remote button press is detected as many. By debouncing a # command, we make sure its only called once per button press. tv.debounce('togglepower') # Finally, send the command # .send() Returns nothing on failure, 2-digit bytecode for status commands, # and True for other commands print(tv.send(sys.argv[1].lstrip("--")))