Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hammerspoon stuck after powering on TV because lgtv ... on does not return. #133

Closed
xane256 opened this issue Nov 30, 2023 · 1 comment
Closed

Comments

@xane256
Copy link

xane256 commented Nov 30, 2023

I am experiencing an issue similar to #124, using an LG C3 42", model OLED42C3PUA
The command lgtv --name c3 --ssl on works and turns on the TV but doesn't return / exit. So Hammerspoon is able to turn on the TV but it hangs afterwards and requires force quitting.

The output of the above command is

DEBUG:root:Initiating handshake
DEBUG:root:Received response
DEBUG:root:{"type":"registered","id":"register_0","payload":{"client-key":"d83083dcb1f148b03a4c18496018064d"}}
DEBUG:root:Handshake complete

The config ~/.lgtv/config.json has the correct MAC address of the TV and running wakeonlan 84:90:0a:95:02:18 in a shell correctly turns on the TV and exits.

Here is a watcher I added to lgtv_init.lua while troubleshooting. I replaced the provided watcher with this one. The print statements before the exec_command("on") sometimes don't print even though that's the line that freezes.

simplewatcher = hs.caffeinate.watcher.new(function(event_type)
    event_name = event_type_description(event_type)
    log_d("Received event: " .. (event_type or "") .. " " .. (event_name))
    if lgtv_disabled() then
        log_d("LGTV feature disabled. Skipping.")
        return
    end
    if (event_type == hs.caffeinate.watcher.screensDidWake or event_type ==
        hs.caffeinate.watcher.systemDidWake or event_type ==
        hs.caffeinate.watcher.screensDidUnlock) then
        sw_info = exec_command("swInfo")
        log_d("got info: " .. sw_info)
        if not tv_is_connected() then
            log_d("TV was not turned on because it is not connected")
            return
        end
        log_d("before power on")
        exec_command("on")
        log_d("after power on")
    end

end)
@Tenzer
Copy link
Collaborator

Tenzer commented Dec 5, 2023

Unaware of this ticket, I just made an improvement to the "on" command so it no longer tries to create a websocket connection to the TV when we want it to turn on: #141. It has been merged in now. It's possible that might help you out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants