T3m3z / pyvesteltv

Python 3 library to control Vestel based TV sets.
MIT License
16 stars 3 forks source link

question about tv connection #4

Closed theRemoter closed 1 month ago

theRemoter commented 3 years ago

first, thanks for building this library! I can see the you are connecting to the tv at start, but at the end, all we need to do in order to send commands to the tv, is just use the sendkey method right? (https://github.com/T3m3z/pyvesteltv/blob/master/pyvesteltv/pyvesteltv.py#L120)

What I'm trying to say is that I don't need to init a connection first or to maintain some connection with the television right? I just need to send a post request to my tv's ip (and port which I guess is always the same in all tvs?) followed by vr/remote with the body of: "<?xml version=\"1.0\" ?><remote><key code=\"{}\"/></remote>" and that it? no need to auth the user or something

I want to see if I understood the flow of the lib.

T3m3z commented 3 years ago

Hello!

Yes, you can send http post requests to the TV without any authentication. And there is no need to maintain any other connection with the TV if you just want to send virtual key presses to the TV. This library is using TCP connection to port 1981, websocket connection and HTTP GET requests to obtain information about the state of the TV but you can send virtual key presses without any of these "extra" connections.

Only caveat here is that the port for virtual remote seems to be random (at least on my TV) on every boot. My TV switches between 3 ports. My library uses SSDP to detect the active URL and port.

Best regards, Teemu

la 2. tammik. 2021 klo 16.49 theRemoter (notifications@github.com) kirjoitti:

first, thanks for building this library! I can see the you are connecting to the tv at start, but at the end, all we need to do in order to send commands to the tv, is just use the sendkey method right? ( https://github.com/T3m3z/pyvesteltv/blob/master/pyvesteltv/pyvesteltv.py#L120 )

What I'm trying to say is that I don't need to init a connection first or to maintain some connection with the television right? I just need to send a post request to my tv's ip (and port which I guess is always the same in all tvs?) followed by vr/remote with the body of: "<?xml version=\"1.0\" ?><key code=\"{}\"/>" and that it? no need to auth the user or something

I want to see if I understood the flow of the lib.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/T3m3z/pyvesteltv/issues/4, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABRGTAESEMBLHAN4EBFUIJTSX4W7XANCNFSM4VRDMTTQ .

theRemoter commented 3 years ago

Hello! Yes, you can send http post requests to the TV without any authentication. And there is no need to maintain any other connection with the TV if you just want to send virtual key presses to the TV. This library is using TCP connection to port 1981, websocket connection and HTTP GET requests to obtain information about the state of the TV but you can send virtual key presses without any of these "extra" connections. Only caveat here is that the port for virtual remote seems to be random (at least on my TV) on every boot. My TV switches between 3 ports. My library uses SSDP to detect the active URL and port. Best regards, Teemu la 2. tammik. 2021 klo 16.49 theRemoter (notifications@github.com) kirjoitti: first, thanks for building this library! I can see the you are connecting to the tv at start, but at the end, all we need to do in order to send commands to the tv, is just use the sendkey method right? ( https://github.com/T3m3z/pyvesteltv/blob/master/pyvesteltv/pyvesteltv.py#L120 ) What I'm trying to say is that I don't need to init a connection first or to maintain some connection with the television right? I just need to send a post request to my tv's ip (and port which I guess is always the same in all tvs?) followed by vr/remote with the body of: "<?xml version=\"1.0\" ?><key code=\"{}\"/>" and that it? no need to auth the user or something I want to see if I understood the flow of the lib. — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub <#4>, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABRGTAESEMBLHAN4EBFUIJTSX4W7XANCNFSM4VRDMTTQ .

Thanks What part of your code scans for the correct port and how it determines if it is indeed the port? ps- do you have an email or an FB or maybe discord account I can consult with you about it?

T3m3z commented 1 month ago

Oh, I have totally missed this question here. It might not help anymore ("sorry for the delay") but I will try to answer anyway if it helps someone else.

https://github.com/T3m3z/pyvesteltv/blob/b11b178b377140e6f85023aff39e929ba56e3f83/pyvesteltv/pyvesteltv.py#L51-L56 start to listen for new messages sent by the television. These messages contain the URL in the headers of the message and function datagram_received / handle_url are used to extract this URL. That URL contains the port also if I remember correctly.

Closing this issue, feel free to reopen if you feel so and I'm sorry for this 3 year delay.