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 13 forks source link

Screenoff works but the screen does not turn off or on after applying script #36

Closed BawlerPepsi closed 9 months ago

BawlerPepsi commented 9 months ago

So after checking that Screenoff works, I went to my Applications folder, "show[ed] package contents" of Hammerspoon and put in the script from this post.

NOthing.

I put my mac to sleep, my oled tv goes to "no signal" screen with changing backgrounds. Just as before applying anything to the computer.

I was so happy about being able to connect the tv to the computer and screenoff-ing it, now idk what to do..

: suspended /opt/homebrew/bin/python3 x@simseungdoui-MacBookPro ~ % brew install --cask hammerspoon

brew install --cask hammerspoon

Running brew update --auto-update... ==> Auto-updated Homebrew! Updated 2 taps (homebrew/core and homebrew/cask). ==> New Formulae dotter opensca-cli purr ==> New Casks blockstream-green imazing-profile-editor roam creality-print keyboard-cowboy sakura egovframedev lw-scanner salt heynote reader xact

You have 1 outdated formula installed.

Warning: Not upgrading hammerspoon, the latest version is already installed -MacBookPro ~ % brew install --cask hammerspoon Warning: Not upgrading hammerspoon, the latest version is already installed -MacBookPro ~ % brew install python@3.8

==> Downloading https://ghcr.io/v2/homebrew/core/python/3.8/manifests/3.8.18_1 ######################################################################### 100.0% ==> Fetching dependencies for python@3.8: gdbm and tcl-tk ==> Downloading https://ghcr.io/v2/homebrew/core/gdbm/manifests/1.23 ######################################################################### 100.0% ==> Fetching gdbm ==> Downloading https://ghcr.io/v2/homebrew/core/gdbm/blobs/sha256:a7321472cc9ff ######################################################################### 100.0% ==> Downloading https://ghcr.io/v2/homebrew/core/tcl-tk/manifests/8.6.13_5 ######################################################################### 100.0% ==> Fetching tcl-tk ==> Downloading https://ghcr.io/v2/homebrew/core/tcl-tk/blobs/sha256:9954fa13ce6 ######################################################################### 100.0% ==> Fetching python@3.8 ==> Downloading https://ghcr.io/v2/homebrew/core/python/3.8/blobs/sha256:ec8c706 ######################################################################### 100.0% ==> Installing dependencies for python@3.8: gdbm and tcl-tk ==> Installing python@3.8 dependency: gdbm ==> Downloading https://ghcr.io/v2/homebrew/core/gdbm/manifests/1.23 Already downloaded: /Users/x/Library/Caches/Homebrew/downloads/ce78100f130177bffd255fda9df551477edd224a5080cb86cac12818954a7438--gdbm-1.23.bottle_manifest.json ==> Pouring gdbm--1.23.arm64_ventura.bottle.tar.gz 🍺 /opt/homebrew/Cellar/gdbm/1.23: 24 files, 1MB ==> Installing python@3.8 dependency: tcl-tk ==> Downloading https://ghcr.io/v2/homebrew/core/tcl-tk/manifests/8.6.13_5 Already downloaded: /Users/x/Library/Caches/Homebrew/downloads/37d4c98d33cbcc1d4c78fd424a96623554b669eca5da2698a376d9b993fd1a86--tcl-tk-8.6.13_5.bottle_manifest.json ==> Pouring tcl-tk--8.6.13_5.arm64_ventura.bottle.tar.gz 🍺 /opt/homebrew/Cellar/tcl-tk/8.6.13_5: 3,064 files, 53.1MB ==> Installing python@3.8 ==> Pouring python@3.8--3.8.18_1.arm64_ventura.bottle.tar.gz ==> /opt/homebrew/Cellar/python@3.8/3.8.18_1/bin/python3.8 -s setup.py --no-user ==> /opt/homebrew/Cellar/python@3.8/3.8.18_1/bin/python3.8 -s setup.py --no-user ==> /opt/homebrew/Cellar/python@3.8/3.8.18_1/bin/python3.8 -s setup.py --no-user ==> Caveats Python has been installed as /opt/homebrew/bin/python3.8

Unversioned and major-versioned symlinks python, python3, python-config, python3-config, pip, pip3, etc. pointing to python3.8, python3.8-config, pip3.8, etc., respectively, have been installed into /opt/homebrew/opt/python@3.8/libexec/bin

You can install Python packages with pip3.8 install They will install into the site-package directory /opt/homebrew/lib/python3.8/site-packages

If you do not need a specific version of Python, and always want Homebrew's python3 in your PATH: brew install python3

See: https://docs.brew.sh/Homebrew-and-Python ==> Summary 🍺 /opt/homebrew/Cellar/python@3.8/3.8.18_1: 5,036 files, 81.9MB ==> Running brew cleanup python@3.8... Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP. Hide these hints with HOMEBREW_NO_ENV_HINTS (see man brew). ==> Caveats ==> python@3.8 Python has been installed as /opt/homebrew/bin/python3.8

Unversioned and major-versioned symlinks python, python3, python-config, python3-config, pip, pip3, etc. pointing to python3.8, python3.8-config, pip3.8, etc., respectively, have been installed into /opt/homebrew/opt/python@3.8/libexec/bin

You can install Python packages with pip3.8 install They will install into the site-package directory /opt/homebrew/lib/python3.8/site-packages

If you do not need a specific version of Python, and always want Homebrew's python3 in your PATH: brew install python3

See: https://docs.brew.sh/Homebrew-and-Python x~ % pip install pipx zsh: command not found: pip x~ % pip3.8 install pipx DEPRECATION: Configuring installation scheme with distutils config files is deprecated and will no longer work in the near future. If you are using a Homebrew or Linuxbrew Python, please see discussion at https://github.com/Homebrew/homebrew-core/issues/76621 Collecting pipx Using cached pipx-1.3.3-py3-none-any.whl.metadata (17 kB) Collecting argcomplete>=1.9.4 (from pipx) Using cached argcomplete-3.2.1-py3-none-any.whl.metadata (16 kB) Collecting packaging>=20 (from pipx) Using cached packaging-23.2-py3-none-any.whl.metadata (3.2 kB) Collecting platformdirs>=2.1 (from pipx) Using cached platformdirs-4.1.0-py3-none-any.whl.metadata (11 kB) Collecting tomli (from pipx) Downloading tomli-2.0.1-py3-none-any.whl (12 kB) Collecting userpath!=1.9.0,>=1.6 (from pipx) Using cached userpath-1.9.1-py3-none-any.whl.metadata (3.0 kB) Collecting click (from userpath!=1.9.0,>=1.6->pipx) Using cached click-8.1.7-py3-none-any.whl.metadata (3.0 kB) Using cached pipx-1.3.3-py3-none-any.whl (63 kB) Using cached argcomplete-3.2.1-py3-none-any.whl (42 kB) Using cached packaging-23.2-py3-none-any.whl (53 kB) Using cached platformdirs-4.1.0-py3-none-any.whl (17 kB) Using cached userpath-1.9.1-py3-none-any.whl (9.1 kB) Using cached click-8.1.7-py3-none-any.whl (97 kB) Installing collected packages: tomli, platformdirs, packaging, click, argcomplete, userpath, pipx DEPRECATION: Configuring installation scheme with distutils config files is deprecated and will no longer work in the near future. If you are using a Homebrew or Linuxbrew Python, please see discussion at https://github.com/Homebrew/homebrew-core/issues/76621 DEPRECATION: Configuring installation scheme with distutils config files is deprecated and will no longer work in the near future. If you are using a Homebrew or Linuxbrew Python, please see discussion at https://github.com/Homebrew/homebrew-core/issues/76621 DEPRECATION: Configuring installation scheme with distutils config files is deprecated and will no longer work in the near future. If you are using a Homebrew or Linuxbrew Python, please see discussion at https://github.com/Homebrew/homebrew-core/issues/76621 DEPRECATION: Configuring installation scheme with distutils config files is deprecated and will no longer work in the near future. If you are using a Homebrew or Linuxbrew Python, please see discussion at https://github.com/Homebrew/homebrew-core/issues/76621 DEPRECATION: Configuring installation scheme with distutils config files is deprecated and will no longer work in the near future. If you are using a Homebrew or Linuxbrew Python, please see discussion at https://github.com/Homebrew/homebrew-core/issues/76621 DEPRECATION: Configuring installation scheme with distutils config files is deprecated and will no longer work in the near future. If you are using a Homebrew or Linuxbrew Python, please see discussion at https://github.com/Homebrew/homebrew-core/issues/76621 DEPRECATION: Configuring installation scheme with distutils config files is deprecated and will no longer work in the near future. If you are using a Homebrew or Linuxbrew Python, please see discussion at https://github.com/Homebrew/homebrew-core/issues/76621 DEPRECATION: Configuring installation scheme with distutils config files is deprecated and will no longer work in the near future. If you are using a Homebrew or Linuxbrew Python, please see discussion at https://github.com/Homebrew/homebrew-core/issues/76621 Successfully installed argcomplete-3.2.1 click-8.1.7 packaging-23.2 pipx-1.3.3 platformdirs-4.1.0 tomli-2.0.1 userpath-1.9.1 x ~ % pip3.8 install pipx git+https://github.com/klattimer/LGWebOSRemote.git DEPRECATION: Configuring installation scheme with distutils config files is deprecated and will no longer work in the near future. If you are using a Homebrew or Linuxbrew Python, please see discussion at https://github.com/Homebrew/homebrew-core/issues/76621 Collecting git+https://github.com/klattimer/LGWebOSRemote.git Cloning https://github.com/klattimer/LGWebOSRemote.git to /private/var/folders/9l/_7wzz91d2wxgd23x6btvyrd80000gn/T/pip-req-build-xjbgvunr Running command git clone --filter=blob:none --quiet https://github.com/klattimer/LGWebOSRemote.git /private/var/folders/9l/_7wzz91d2wxgd23x6btvyrd80000gn/T/pip-req-build-xjbgvunr Resolved https://github.com/klattimer/LGWebOSRemote.git to commit 0ff499b50a83051f4837669662f11f958411f029 Preparing metadata (setup.py) ... done Requirement already satisfied: pipx in /opt/homebrew/lib/python3.8/site-packages (1.3.3) Requirement already satisfied: argcomplete>=1.9.4 in /opt/homebrew/lib/python3.8/site-packages (from pipx) (3.2.1) Requirement already satisfied: packaging>=20 in /opt/homebrew/lib/python3.8/site-packages (from pipx) (23.2) Requirement already satisfied: platformdirs>=2.1 in /opt/homebrew/lib/python3.8/site-packages (from pipx) (4.1.0) Requirement already satisfied: tomli in /opt/homebrew/lib/python3.8/site-packages (from pipx) (2.0.1) Requirement already satisfied: userpath!=1.9.0,>=1.6 in /opt/homebrew/lib/python3.8/site-packages (from pipx) (1.9.1) Collecting wakeonlan (from LGTV==0.3) Using cached wakeonlan-3.1.0-py3-none-any.whl.metadata (4.3 kB) Collecting ws4py (from LGTV==0.3) Using cached ws4py-0.5.1.tar.gz (51 kB) Preparing metadata (setup.py) ... done Collecting requests (from LGTV==0.3) Using cached requests-2.31.0-py3-none-any.whl.metadata (4.6 kB) Collecting getmac (from LGTV==0.3) Using cached getmac-0.9.4-py2.py3-none-any.whl.metadata (35 kB) Requirement already satisfied: click in /opt/homebrew/lib/python3.8/site-packages (from userpath!=1.9.0,>=1.6->pipx) (8.1.7) Collecting charset-normalizer<4,>=2 (from requests->LGTV==0.3) Downloading charset_normalizer-3.3.2-cp38-cp38-macosx_11_0_arm64.whl.metadata (33 kB) Collecting idna<4,>=2.5 (from requests->LGTV==0.3) Using cached idna-3.6-py3-none-any.whl.metadata (9.9 kB) Collecting urllib3<3,>=1.21.1 (from requests->LGTV==0.3) Using cached urllib3-2.1.0-py3-none-any.whl.metadata (6.4 kB) Collecting certifi>=2017.4.17 (from requests->LGTV==0.3) Using cached certifi-2023.11.17-py3-none-any.whl.metadata (2.2 kB) Using cached getmac-0.9.4-py2.py3-none-any.whl (35 kB) Using cached requests-2.31.0-py3-none-any.whl (62 kB) Using cached wakeonlan-3.1.0-py3-none-any.whl (5.0 kB) Using cached certifi-2023.11.17-py3-none-any.whl (162 kB) Downloading charset_normalizer-3.3.2-cp38-cp38-macosx_11_0_arm64.whl (119 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 119.1/119.1 kB 3.7 MB/s eta 0:00:00 Using cached idna-3.6-py3-none-any.whl (61 kB) Using cached urllib3-2.1.0-py3-none-any.whl (104 kB) Building wheels for collected packages: LGTV, ws4py Building wheel for LGTV (setup.py) ... done Created wheel for LGTV: filename=LGTV-0.3-py3-none-any.whl size=12035 sha256=b7ea9132b193b36de2309e8befe3dc1c3b820ffabc8e64d31e65395af14cc47e Stored in directory: /private/var/folders/9l/_7wzz91d2wxgd23x6btvyrd80000gn/T/pip-ephem-wheel-cache-57jp5hkk/wheels/52/29/48/010486c758897b5a3e8ac6a34581a7437efbcd0da13f0122bc Building wheel for ws4py (setup.py) ... done Created wheel for ws4py: filename=ws4py-0.5.1-py3-none-any.whl size=45227 sha256=44c57f1ca8f41426382e4c505e323e282a63a0067e772112a04618aba23f83fb Stored in directory: /Users/x/Library/Caches/pip/wheels/ea/f9/a1/34e2943cce3cf7daca304bfc35e91280694ced9194a487ce2f Successfully built LGTV ws4py Installing collected packages: ws4py, wakeonlan, urllib3, idna, getmac, charset-normalizer, certifi, requests, LGTV DEPRECATION: Configuring installation scheme with distutils config files is deprecated and will no longer work in the near future. If you are using a Homebrew or Linuxbrew Python, please see discussion at https://github.com/Homebrew/homebrew-core/issues/76621 DEPRECATION: Configuring installation scheme with distutils config files is deprecated and will no longer work in the near future. If you are using a Homebrew or Linuxbrew Python, please see discussion at https://github.com/Homebrew/homebrew-core/issues/76621 DEPRECATION: Configuring installation scheme with distutils config files is deprecated and will no longer work in the near future. If you are using a Homebrew or Linuxbrew Python, please see discussion at https://github.com/Homebrew/homebrew-core/issues/76621 DEPRECATION: Configuring installation scheme with distutils config files is deprecated and will no longer work in the near future. If you are using a Homebrew or Linuxbrew Python, please see discussion at https://github.com/Homebrew/homebrew-core/issues/76621 DEPRECATION: Configuring installation scheme with distutils config files is deprecated and will no longer work in the near future. If you are using a Homebrew or Linuxbrew Python, please see discussion at https://github.com/Homebrew/homebrew-core/issues/76621 DEPRECATION: Configuring installation scheme with distutils config files is deprecated and will no longer work in the near future. If you are using a Homebrew or Linuxbrew Python, please see discussion at https://github.com/Homebrew/homebrew-core/issues/76621 DEPRECATION: Configuring installation scheme with distutils config files is deprecated and will no longer work in the near future. If you are using a Homebrew or Linuxbrew Python, please see discussion at https://github.com/Homebrew/homebrew-core/issues/76621 DEPRECATION: Configuring installation scheme with distutils config files is deprecated and will no longer work in the near future. If you are using a Homebrew or Linuxbrew Python, please see discussion at https://github.com/Homebrew/homebrew-core/issues/76621 DEPRECATION: Configuring installation scheme with distutils config files is deprecated and will no longer work in the near future. If you are using a Homebrew or Linuxbrew Python, please see discussion at https://github.com/Homebrew/homebrew-core/issues/76621 DEPRECATION: Configuring installation scheme with distutils config files is deprecated and will no longer work in the near future. If you are using a Homebrew or Linuxbrew Python, please see discussion at https://github.com/Homebrew/homebrew-core/issues/76621 Successfully installed LGTV-0.3 certifi-2023.11.17 charset-normalizer-3.3.2 getmac-0.9.4 idna-3.6 requests-2.31.0 urllib3-2.1.0 wakeonlan-3.1.0 ws4py-0.5.1 x ~ % pipx3.8 ensurepath zsh: command not found: pipx3.8 x ~ % pipx ensurepath /Users/x/.local/bin is already in PATH.

⚠️ All pipx binary directories have been added to PATH. If you are sure you want to proceed, try again with the '--force' flag.

Otherwise pipx is ready to go! ✨ 🌟 ✨ x@x-MacBookPro ~ % lgtv scan ssl

{"result": "ok", "count": 1, "list": [{"uuid": "1345987b-3a10-e8dc-b5c7-d0999b993084", "tv_name": "[LG] webOS TV OLED42C2KNB", "address": "192.168.1.12"}]} x@x-MacBookPro ~ % lgtv auth <192.168.1.12> MyTV --ssl

zsh: no such file or directory: 192.168.1.12 x@x-MacBookPro ~ % lgtv --ssl auth 192.168.1.12 MyTV

Please accept the pairing request on your LG TV {"closing": {"code": 1000, "reason": ""}} Wrote config file: /Users/x/.lgtv/config.json x@x-MacBookPro ~ % lgtv --name MyTV --ssl screenOff

{"type": "response", "id": "0", "payload": {"returnValue": true, "state": "Screen Off"}} {"closing": {"code": 1000, "reason": ""}} x@x-MacBookPro ~ % lgtv --name MyTV --ssl screenOff

{"type": "response", "id": "0", "payload": {"returnValue": true, "state": "Screen Off"}} {"closing": {"code": 1000, "reason": ""}} x@x-MacBookPro ~ % mkdir -p ~/.hammerspoon touch ~/.hammerspoon/init.lua echo "require \"lgtv_init\"" >> ~/.hammerspoon/init.lua x@x-MacBookPro ~ % mkdir -p ~/.hammerspoon touch ~/.hammerspoon/init.lua

BawlerPepsi commented 9 months ago

weird, i changed my HDMI cable from HDMI-HDMI to C-type - HDMI and it works without changing anything... ?? Thank you for the coder, the people who uploaded modified versions to help me go through the steps that I got stuck on.