T3m3z / pyvesteltv

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

Connect call failed - but still receives some messages #1

Closed edent closed 5 years ago

edent commented 5 years ago

Thank you for your work on this library. I'm trying to use this on a Toshiba branded 49V6863DB.

When I run python3 tv_on_off.py with the TV already turned on and connected to Ethernet, I get this error.

Give TV IP address: 192.168.0.85
Update called
Not discovered -> turned off
Update called
Trying to connect WS...
WS connect succesful!
!
Trying to connect TCP...
TCP connect/read error: [Errno 111] Connect call failed ('192.168.0.85', 1986)
Trying to read state of applications...
Application states updated!
Update called
!

So the WebSocket connects successfully, but not the TCP?

When I turn the TV off using the remote, the script picks it up:

Trying to connect TCP...
TCP connect/read error: [Errno 111] Connect call failed ('192.168.0.85', 1986)
Trying to read state of applications...
Application states updated!
<event><tv_state value='PLAYER_PORTAL'/></event>
Received WS msg: <event><tv_state value='PLAYER_PORTAL'/></event>
<event><tv_state value='PLAYER_PORTAL'/></event>
Received WS msg: <event><tv_state value='PLAYER_PORTAL'/></event>
<event>tv_status:1</event>
Received WS msg: <event>tv_status:1</event>
<event>tv_status:1</event>
Received WS msg: <event>tv_status:1</event>
Update called
!
Trying to connect TCP...
TCP connect/read error: [Errno 111] Connect call failed ('192.168.0.85', 1986)
Trying to read state of applications...
Application states updated!

So, it is getting some messages!

Is this something I'm doing wrong?

T3m3z commented 5 years ago

Hello!

I believe that you are doing everything right but our TV sets might have some differences. I had to reverse engineer functionality of my TV so it might not be the best approach or work with other TV models.

I used Websocket connection to get some status information from tv. For example turning TV off or opening media library causes TV to send some information through this websocket connection. TCP connection is used to retrieve some information not available through websocket connection (for example volume levels and mute state).

What you could try:

Unfortunately it seems that you have to do some reverse engineering also as our TVs seem to use a bit different messages indicating TV on status (your tv sends xml formatted <event>tv_status:1</event> and my sends just tv_status:1 ). You can use this library as starting point but some tweaking is needed. Hopefully this helps you on right track :)

Best Regards, Teemu

edent commented 5 years ago

Thank you for this. It would be too easy if Vestel provided documentation, eh?!

I couldn't telnet in on 1986, and nmap found no open ports.

So I'm decompiling the Android remote to see if that will help.

Thanks for providing this library, it has been useful :-)

T3m3z commented 5 years ago

Hmmm, but did nmap find websocket port open? I mean that if you didn't find that, then you might have to check nmap parameters.

I would be excited, if you can find an approach which is generalizes better than mine :)

Cheers, Teemu

edent commented 5 years ago

I'll have to play around with nmap - I can connect to the websocket in JavaScript using

var myWebSocket = new WebSocket("ws://192.168.0.85:7681/)
myWebSocket.onmessage = function (event) { console.log(event.data); }

Looking through the APK, it appears that the TCP port is on 2000.

edent commented 5 years ago

Aha!

2870/tcp open unknown 4660/tcp open mosmig 4661/tcp open unknown 4725/tcp open unknown 7681/tcp open unknown 56789/tcp open unknown 56790/tcp open unknown 57707/tcp open unknown

If I telnet into 4660 and then send 1012 I can toggle the TV on and off! The GETMUTE command didn't return anything, but did make the TV's screen flash...