cmer / lg-tv-control-macos

Automatically wake/sleep and change the input of your LG TV when used as a monitor on macOS
129 stars 12 forks source link

LG C2 January 24 update breaks LGWebOSRemote #2

Closed Mike076 closed 1 year ago

Mike076 commented 1 year ago

LG issued a Jan 24, 2023 update that breaks the functionality of LGWebOSRemote app (https://github.com/klattimer/LGWebOSRemote).

Tony Cassara has discovered that the leading digits of the television’s MAC address are being parsed out. Copying the issue here for visibility since this workflow depends on that Python app working properly.

tonycassara commented 1 year ago

It's possible the mac address is still viable with the leading 0's removed. Here's the issue with more details and errors: https://github.com/klattimer/LGWebOSRemote/issues/107

This is only affecting the latest OLED C2 software update, also if it helps I'm on Mac OS 13.2

tonycassara commented 1 year ago

Basically if you know Python or if anyone reading this does, please help us out 😄

tonycassara commented 1 year ago

@Mike076 did the latest fix work for you? I tried upgrading my package but got the same error.

Mike076 commented 1 year ago

Latest fix for LGWebOSRemote with SSL works, but now lgtv.lua needs to be modified to reflect the ssl command appended to each command. I'm looking at the code but this is a little beyond my expertise. @greyshi can probably tweak it.

tonycassara commented 1 year ago

I did this locally but now the turn on command isn't working anymore. Maybe another bug.

Mike076 commented 1 year ago

I’ll play around with this more tomorrow. Lua is pretty simple so maybe I’ll crash course the syntax a bit 😆

greyshi commented 1 year ago

Here's what I've been using. Seems to be working well after updating to the latest LGWebOSRemote but haven't tested it for long.

local tv_identifier = "LG TV"
local mac_address = "ab:cd:ef:gg:aa:bb"
local tv_input = "HDMI_2"
local tv_found = (hs.screen.find(tv_identifier) ~= nil)
local debug = false  -- Set to true to enable debug messages

if debug then
  print("List of all screens: " .. hs.inspect(hs.screen.allScreens()))
  if tv_found then print("TV with identifier '"..tv_identifier.."' was detected.") end
end

watcher = hs.caffeinate.watcher.new(function(eventType)
  if (eventType == hs.caffeinate.watcher.screensDidWake or
      eventType == hs.caffeinate.watcher.systemDidWake or
      eventType == hs.caffeinate.watcher.screensDidUnlock) and tv_found then

    if debug then print("TV was turned on.") end
    hs.execute("/opt/homebrew/bin/wakeonlan "..mac_address)
    hs.execute("/opt/lgtv-venv/bin/lgtv MyTV setInput ssl "..tv_input)
  end

  if (eventType == hs.caffeinate.watcher.screensDidSleep or
      eventType == hs.caffeinate.watcher.systemWillPowerOff) and tv_found then

    if debug then print("TV was turned off.") end
    hs.execute("/opt/lgtv-venv/bin/lgtv MyTV off ssl")
  end
end)
watcher:start()
cmer commented 1 year ago

I have just released an update addressing the SSL issue.

tonycassara commented 1 year ago

TYVM @greyshi and @cmer