Replies: 2 comments 1 reply
-
I didn't know this at all -- thanks so much! I thought fast-start option makes the TV listen for wakeonlan packets and nothing more. Did you establish a connection and then turn the TV off? In other words, can you confirm if you're able to establish a new WS connection to the TV that has the display turned off? |
Beta Was this translation helpful? Give feedback.
-
This trick unfortunately does not work. @supersaiyanmode is right. The TV turns off the network interface and listens only for magic WOL packets. I probably hit a time when some WebOS application was keeping the network connection even after the TV was turned off (maybe downloading updates). As a consolation, I wrote very simple code to wake up the TV, using the built-in modules and ping to check if the TV is already responding. from pywebostv.discovery import *
from pywebostv.connection import *
from pywebostv.controls import *
import socket, os, time
broadcast_adr = '192.168.1.255' #your broacast address
tv_adr = [
....{'ip': '192.168.1.65', 'mac': 'BBBBBBBBBBBB'}, #your lan
....{'ip': '192.168.1.64', 'mac': 'AAAAAAAAAAAA'}] #your wifi
....# 1. For the first run, pass in an empty dictionary object. Empty store leads to an Authentication prompt on TV. store = {}, note key
store = {'client_key': 'a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1'} #your key
soc = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
for _ in range(20):
....for adr in tv_adr:
........if os.system(f"ping -n 1 -w 300 {adr['ip']}")==0: #linux: ping -c 1 -w 1 #mac: ping -c 1 -t 1
............client = WebOSClient(adr['ip'])
............break
........# Wake On LAN
........soc.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST,1)
........soc.sendto(bytes.fromhex("F" * 12 + adr['mac'].upper() * 16), (broadcast_adr, 9))
....else:
........time.sleep(0.75)
........continue
....break
client.connect()
for status in client.register(store):
....if status == WebOSClient.PROMPTED:
........print("Please accept the connect on the TV!")
........print(store) # {'client_key': 'ACCESS_TOKEN_FROM_TV'}
....elif status == WebOSClient.REGISTERED:
........print("Registration successful!")
source_control = SourceControl(client)
sources = source_control.list_sources()
source_control.set_source(sources[0]) |
Beta Was this translation helpful? Give feedback.
-
Every (I think) TV turns on when you press the channel select key on the remote. I think it works with this library too, as long as the fast start option is enabled on the TV. E.g.:
Turn on
tv_control = TvControl(client)
tv_control.channel_down()
tv_control.channel_up()
and then select the source (HDMI1)
source_control = SourceControl(client)
source_control.set_source(sources[0])
Beta Was this translation helpful? Give feedback.
All reactions