Ape / samsungctl

Remote control Samsung televisions via a TCP/IP connection
MIT License
716 stars 189 forks source link

Adds TV discovery #96

Closed kdschlosser closed 1 year ago

kdschlosser commented 5 years ago

I added the ability for the library to discover any TV's using UPNP. The UPNP detection sends out broadcast packets on all NIC's. This process runs a different thread for each NIC so it will speed up process. I have found that it can take up to 3 seconds for a TV to reply to the SSDP packet.

I also added the user being able to select the TV they wish to use if more then one is detected. the script will set up the config automatically

the config values are

host = found IP Address,
id = PC MAC Address,
name = 'samsungctl',
description = PC Host Name,
timeout = 0
method = 'websocket' if year >= 2015 else 'legacy'
port = 8001 if year >= 2015 else 55000

the automatic discovery process will take that 3 seconds, if the user does not want to wait they will have to make a config file or pass the settings from the command line.

I am able to pull all kinds of metrics from the UPNP SSDP request

model
panel type
msg region
size
year
max panel resolution
series
ip

I would say the serial number but i believe the serial number is always the same no matter what tv is detected.

kdschlosser commented 5 years ago

I wanted to mention that we might be able to get the firmware version from the UPNP SSDP response. This would aid in making any adjustments for the sll websocket on port 8002 if needed. I would need someone with a TV that uses the SSL websocket and token to run a modified version of this PR that will output all SSDP information. say the word and I will make the modifications.

kdschlosser commented 5 years ago

I am not sure what this is

socket.gaierror: [Errno -2] Name or service not known

I fixed the discover thing. that was my bad I copied the code from a version I had locally and I didn't think to change the name of he function

and not exactly sure what you mean by

python 3 dependency
kdschlosser commented 5 years ago

ok the socket error is a problem with your linux installation and not with the code

here is an explanation

https://stackoverflow.com/questions/51270047/socket-gaierror-error-2-name-or-service-not-known