klattimer / LGWebOSRemote

Command line webOS remote for LGTVs
MIT License
502 stars 97 forks source link

lgtv tv on sends request to the TVs IP address and not 255.255.255.255 #167

Closed cbirchinger closed 1 month ago

cbirchinger commented 1 month ago

More recent versions started to send the magic wakeonlan packet to the TV's IP address instead of the broadcast IP

tcpdump comparison:

FAIL: $ ~/.virtualenv/lgtv/bin/lgtv --name tv on 17:27:33.826836 IP 192.168.1.7.49369 > 192.168.1.21.9: UDP, length 102

WORKING: ~/.virtualenv/lgtv/bin/wakeonlan b4:b2:91:xx:xx:xx 17:28:29.942674 IP 192.168.1.7.54168 > 255.255.255.255.9: UDP, length 102 (So the wakeonlan pulled as dependency is capable of doing the right thing)

Wake on LAN only works when the packet is sent to the broadcast address because the IP of the TV is not active while the TV is in standby.

Python 3.12.3 Installed with: pip install git+https://github.com/klattimer/LGWebOSRemote (VirtualEnv) Install date: 2024-07-07 18:02

~ % pip list
Package            Version
------------------ --------
certifi            2024.7.4
charset-normalizer 3.3.2
getmac             0.9.4
idna               3.7
LGTV               0.3
pip                24.1.1
requests           2.32.3
urllib3            2.2.2
wakeonlan          3.1.0
ws4py              0.5.1
cbirchinger commented 1 month ago

This fixes it for me. Removing the ip_address argument makes wakeonlan default to 255.255.255.255

--- remote.py.orig      2024-07-08 18:16:59.269962415 +0200
+++ remote.py   2024-07-08 18:17:12.390222230 +0200
@@ -182,7 +182,7 @@
     def on(self):
         if not (self.__macAddress) and not (self.__ip):
             print ("Client must have been powered on and paired before power on works")
-        send_magic_packet(self.__macAddress, ip_address=self.__ip)
+        send_magic_packet(self.__macAddress)

     def off(self):
         self.__send_command("request", "ssap://system/turnOff")
klattimer commented 1 month ago

Please make a pr I'll approve it.

cbirchinger commented 1 month ago

Please make a pr I'll approve it.

Done. https://github.com/klattimer/LGWebOSRemote/pull/168