cmer / lg-tv-control-macos

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

AttributeError: module 'ssl' has no attribute 'wrap_socket' #32

Closed Krizid closed 7 months ago

Krizid commented 7 months ago

hi, getting this error with the new setup

lgtv auth 10.0.0.90 MyTV --ssl Traceback (most recent call last): File "/Users/name/.local/bin/lgtv", line 10, in sys.exit(main()) ^^^^^^ File "/Users/name/Library/Application Support/pipx/venvs/lgtv/lib/python3.12/site-packages/LGTV/init.py", line 137, in main ws.connect() File "/Users/name/Library/Application Support/pipx/venvs/lgtv/lib/python3.12/site-packages/ws4py/client/init.py", line 214, in connect self.sock = ssl.wrap_socket(self.sock, **self.ssl_options) ^^^^^^^^^^^^^^^ AttributeError: module 'ssl' has no attribute 'wrap_socket'

syncr commented 7 months ago

Same issue

cmer commented 7 months ago

I completely messed up a couple of days ago. It's been resolved.

Also make sure you install the latest version of the LG TV Python scripts.

syncr commented 6 months ago

I executed a --force installation of the LGWebORemote files but am still getting the same error as above. Is there something I've missed or can try? Thanks in advance.

cmer commented 6 months ago

Looks like this is the issue: https://github.com/klattimer/LGWebOSRemote/issues/140

syncr commented 6 months ago

Ok thanks. Standing by till that gets resolved. đź‘Ť

cmer commented 6 months ago

Until LGWebOSRemote fixes the issue, I recommend you use Python 3.6 instead of the latest.

pipx uninstall LGTV
brew uninstall --ignore-dependencies python
brew uninstall --force python@3.11
brew install python@3.6

Then reinstall pipx and LGTV.

Aurshur commented 6 months ago

Until LGWebOSRemote fixes the issue, I recommend you use Python 3.6 instead of the latest.

pipx uninstall LGTV
brew uninstall --ignore-dependencies python
brew uninstall --force python@3.11
brew install python@3.6

Then reinstall pipx and LGTV.

Unfortunately that's not working for me - I get the following:

% brew install python@3.6 Warning: No available formula with the name "python@3.6". Did you mean python@3.9, python@3.8, python@3.7, python@3.10, python@3.12, python@3.11 or python-yq? ==> Searching for similarly named formulae and casks... ==> Formulae python@3.9 python@3.8 python@3.7 python@3.10 python@3.12 python@3.11 python-yq

MattCis commented 6 months ago

@Aurshur and it will not work. Installing (or reinstalling) pipx will automatically install python 3.12 - which is part of the problem. I am trying to come up with some workaround, but I doubt I will - all of this is too complex to me at the moment.

Aurshur commented 6 months ago

@Aurshur and it will not work. Installing (or reinstalling) pipx will automatically install python 3.12 - which is part of the problem. I am trying to come up with some workaround, but I doubt I will - all of this is too complex to me at the moment.

I ran into the same issue - but actually got it working in the end as I used pip instead of pipx to install.

MattCis commented 6 months ago

@Aurshur and it will not work. Installing (or reinstalling) pipx will automatically install python 3.12 - which is part of the problem. I am trying to come up with some workaround, but I doubt I will - all of this is too complex to me at the moment.

I ran into the same issue - but actually got it working in the end as I used pip instead of pipx to install.

I managed to overcome this as well, but pip3 wasn't the solution - it was showing different errors when installing LGTV.

I somehow managed to use pipx and go through the whole process, despite various errors popping-up in the meantime. The sleep/wake-up function was working flawlessly for those few days, until yesterday. My M1 Mini received the update of mac os. Now, Hammerspoon is "not responding" when the lgtv_init script is loaded and the functionality is gone. Restarting doesn't help. I am not able to tell where is the matter, but it seems that some "element" of the whole puzzle changes and the script is not correct/compatible anymore.

I am learning ver hard way, what actually means that "TV is not going to be a monitor" ;)

This is my console. No errors, but tries to load the "external headphones" (słuchawki zewnętrzne) over and over. I have my M1 Mini connected through mini jack to the stereo system.

2024-01-10 16:58:27: -- Lazy extension loading enabled 2024-01-10 16:58:27: -- Loading ~/.hammerspoon/init.lua 2024-01-10 16:58:27: TV name: MyTV 2024-01-10 16:58:27: TV input: HDMI_2 2024-01-10 16:58:27: LGTV path: ~/.local/bin/lgtv 2024-01-10 16:58:27: LGTV command: ~/.local/bin/lgtv --ssl --name MyTV 2024-01-10 16:58:27: App ID: com.webos.app.hdmi2 2024-01-10 16:58:27: lgtv_disabled: false 2024-01-10 16:58:27: Executing command: ~/.local/bin/lgtv --ssl --name MyTV swInfo 2024-01-10 16:59:42: 2024-01-10 16:59:42: Executing command: ~/.local/bin/lgtv --ssl --name MyTV getForegroundAppInfo 2024-01-10 17:00:57: 2024-01-10 17:00:57: -- Loading extension: screen 2024-01-10 17:00:57: Connected screens: { [1] = hs.screen: LG TV SSCR2 (0x60000282d538),} 2024-01-10 17:00:57: TV is connected? true 2024-01-10 17:00:57: -- Loading extension: caffeinate 2024-01-10 17:00:58: -- Loading extension: eventtap 2024-01-10 17:00:58: -- Done. 2024-01-10 17:01:05: -- Loading extension: audiodevice 2024-01-10 17:01:05: Słuchawki zewnętrzne is the current audio device. 2024-01-10 17:01:07: Słuchawki zewnętrzne is the current audio device. 2024-01-10 17:01:10: Słuchawki zewnętrzne is the current audio device. 2024-01-10 17:01:10: Słuchawki zewnętrzne is the current audio device. 2024-01-10 17:01:24: Słuchawki zewnętrzne is the current audio device. 2024-01-10 17:01:24: Słuchawki zewnętrzne is the current audio device. 2024-01-10 17:01:24: Słuchawki zewnętrzne is the current audio device. 2024-01-10 17:01:25: Słuchawki zewnętrzne is the current audio device. 2024-01-10 17:01:30: Słuchawki zewnętrzne is the current audio device

.

Aurshur commented 6 months ago

@Aurshur and it will not work. Installing (or reinstalling) pipx will automatically install python 3.12 - which is part of the problem. I am trying to come up with some workaround, but I doubt I will - all of this is too complex to me at the moment.

I ran into the same issue - but actually got it working in the end as I used pip instead of pipx to install.

I managed to overcome this as well, but pip3 wasn't the solution - it was showing different errors when installing LGTV.

I somehow managed to use pipx and go through the whole process, despite various errors popping-up in the meantime. The sleep/wake-up function was working flawlessly for those few days, until yesterday. My M1 Mini received the update of mac os. Now, Hammerspoon is "not responding" when the lgtv_init script is loaded and the functionality is gone. Restarting doesn't help. I am not able to tell where is the matter, but it seems that some "element" of the whole puzzle changes and the script is not correct/compatible anymore.

I am learning ver hard way, what actually means that "TV is not going to be a monitor" ;)

This is my console. No errors, but tries to load the "external headphones" (słuchawki zewnętrzne) over and over. I have my M1 Mini connected through mini jack to the stereo system.

2024-01-10 16:58:27: -- Lazy extension loading enabled 2024-01-10 16:58:27: -- Loading ~/.hammerspoon/init.lua 2024-01-10 16:58:27: TV name: MyTV 2024-01-10 16:58:27: TV input: HDMI_2 2024-01-10 16:58:27: LGTV path: ~/.local/bin/lgtv 2024-01-10 16:58:27: LGTV command: ~/.local/bin/lgtv --ssl --name MyTV 2024-01-10 16:58:27: App ID: com.webos.app.hdmi2 2024-01-10 16:58:27: lgtv_disabled: false 2024-01-10 16:58:27: Executing command: ~/.local/bin/lgtv --ssl --name MyTV swInfo 2024-01-10 16:59:42: 2024-01-10 16:59:42: Executing command: ~/.local/bin/lgtv --ssl --name MyTV getForegroundAppInfo 2024-01-10 17:00:57: 2024-01-10 17:00:57: -- Loading extension: screen 2024-01-10 17:00:57: Connected screens: { [1] = hs.screen: LG TV SSCR2 (0x60000282d538),} 2024-01-10 17:00:57: TV is connected? true 2024-01-10 17:00:57: -- Loading extension: caffeinate 2024-01-10 17:00:58: -- Loading extension: eventtap 2024-01-10 17:00:58: -- Done. 2024-01-10 17:01:05: -- Loading extension: audiodevice 2024-01-10 17:01:05: Słuchawki zewnętrzne is the current audio device. 2024-01-10 17:01:07: Słuchawki zewnętrzne is the current audio device. 2024-01-10 17:01:10: Słuchawki zewnętrzne is the current audio device. 2024-01-10 17:01:10: Słuchawki zewnętrzne is the current audio device. 2024-01-10 17:01:24: Słuchawki zewnętrzne is the current audio device. 2024-01-10 17:01:24: Słuchawki zewnętrzne is the current audio device. 2024-01-10 17:01:24: Słuchawki zewnętrzne is the current audio device. 2024-01-10 17:01:25: Słuchawki zewnętrzne is the current audio device. 2024-01-10 17:01:30: Słuchawki zewnętrzne is the current audio device

.

EDIT I may have a fix. Still tinkering but insert the following at the top of .init.lua:

print(hs.location.get())

Then reload the config and go to Security and Privacy in System settings - Location Services and give hammer spoon permission (it should now be listed).

Seems to be working so far on my end!

Sadly, I am finding myself in the exact same situation. Pretty frustrating that in the end it worked flawlessly for only a matter of days just to be defeated by a MacOS update.

MattCis commented 6 months ago

@Aurshur I appreciate so much all your support!

My issue was of other sort. Very trivial. I noticed that, for unknown reason, TV disconnected from my WiFi. It didn't want to connect back (to both 2.4 and 5kHz), just showing generic error message. I must power cycle the router and restart my network. I found on the Internet, that unfortunately some of LG C2 have that kind of issue and frequently drops the connection. I will be observing my TV and see if/how often this will repeat.

After reconnecting to the WiFi, script started to work again (which is logical).

Yesterday I switched the connection to HDMI 2.1 cable and usb c->hdmi converter, to have 120Hz, RGB, 4:4:4 mode. My latest issue is that the screen (after few hours of being off) wakes up, but only to the TV screen saver (art gallery) and I have to wait couple of minutes for the converter to "pick up" the signal and actually start showing my macos desktop. Reconnecting adapter works, but of course I don't want to reconnect adapter everytime the issue appears.

However, I am only mentioning this "by the way". This isn't the script's issue and most probably won't be possible to solve by script, since it's coming most probably from the macos itself/converter.