Skip to content

Automatically turning a LG TV on/off with sleep/wake when used as a MacOS monitor

Notifications You must be signed in to change notification settings

roals/LGTV-Mac-On-Off

Folders and files

NameName
Last commit message
Last commit date

Latest commit

8aee471 · Jul 10, 2023

History

3 Commits
Jul 10, 2023
Jul 10, 2023

Repository files navigation

LGTV Mac On/Off

Automatically turning a LG TV on and off with sleep/wake when used as a monitor.

Tested on a 14" M1 Macbook Pro and 48" LG CX.

Requirements

Using either ethernet or WiFi IP address works. You can find this information (on an LG CX) by holding the setting remote button for 3 seconds, then navigating to:

Connection > Network Connection Settings > Wired Connection (For Ethernet)
Connection > Network Connection Settings > Wi-Fi Connection > Advanced Wi-Fi Settings (For WiFi)

How to use this Lua script

  1. Install all requirements as well as properly setting up LGWebOSRemote (instructions on their project page)
  2. Select 'Open Config' option from the HammerSpoon menu bar icon
  3. Paste this project's lua script
  4. Input your LG TV's MAC address and IP address ('mac_address' and 'lgtv_ip')
  5. Save file
  6. IMPORTANT: Select the 'Reload Config' option from the HammerSpoon menu bar icon

Additional Notes

If your TV's IP address changes, you have to re-authorize via LGWebOSRemote.

Example (If 192.168.1.31 is your TV's new IP address, then you have to re-authenticate that IP address):

source lgtv-venv/bin/activate
lgtv auth 192.168.1.31 MyTV ssl

An authentication prompt should pop up on your TV and you have to accept using your TV's remote.

Credits

This solution was heavily based off of these existing projects:

I couldn't get my 48" LG CX to turn on with just the MAC address in cmer's earlier gist and after messing around, I found that an IP flag (-i) was required as well as an IP address to get the on function to work. Using cmer's newest script, the off function worked for me, but the on function didn't. I modified cmer's earlier gist, fixed the on function, and implimented a simplified off command based on cmer's newest LGTV Control MacOS script.

About

Automatically turning a LG TV on/off with sleep/wake when used as a MacOS monitor

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages