kdschlosser / samsungctl

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

Does not connect to UE55KS8090, TypeError on #develop #122

Open vogler opened 4 years ago

vogler commented 4 years ago

I'm currently using Ape/samsungctl but it only has KEY_HDMI which toggles HDMI inputs if one is already active. So I was happy to see this repo has KEY_HDMI1 as well. Sadly I can't get it to work.

Installed deps via pipenv (maybe add a Pipfile and Pipfile.lock (or poetry - IDK, not into Python)), and ran

$ pipenv run python -m samsungctl -v --host 192.168.178.24 --method websocket --name myremote KEY_VOLDOWN

but it just waits, doesn't output anything and the TV also shows no notification. (Aside: it needed ^C^C^C^C to kill (threading issue I guess), of course ^\ works.)

Then I tried the develop branch, but got a TypeError:

$ pipenv run python -m samsungctl
get_logger_name: samsungctl
get_logger_name: samsungctl.upnp.UPNP_Device
get_logger_name: samsungctl.upnp.UPNP_Device.adapter_addresses
get_logger_name: samsungctl.upnp.UPNP_Device.discover
get_logger_name: samsungctl.upnp.UPNP_Device.action
get_logger_name: samsungctl.upnp.UPNP_Device.icon
get_logger_name: samsungctl.upnp.UPNP_Device.service
get_logger_name: samsungctl.upnp.UPNP_Device.embedded_device
get_logger_name: samsungctl.upnp.UPNP_Device.upnp_class
get_logger_name: samsungctl.upnp.discover
get_logger_name: samsungctl.upnp
get_logger_name: samsungctl.wake_on_lan
get_logger_name: samsungctl.remote_legacy
get_logger_name: samsungctl.websocket_base
get_logger_name: samsungctl.art_mode
get_logger_name: samsungctl.application
get_logger_name: samsungctl.remote_websocket
get_logger_name: samsungctl.remote_encrypted.crypto
get_logger_name: samsungctl.remote_encrypted
Traceback (most recent call last):
  File "/usr/local/Cellar/python/3.7.4_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/local/Cellar/python/3.7.4_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/Users/voglerr/samsungctl/samsungctl/__main__.py", line 391, in <module>
    main()
  File "/Users/voglerr/samsungctl/samsungctl/__main__.py", line 237, in main
    logger.setLevel(log_levels[args.verbose])
TypeError: list indices must be integers or slices, not NoneType
vogler commented 4 years ago

Ok, seems like the develop branch crashes without -v (and it no longer accepts --method). Still, no luck:

$ pipenv run python -m samsungctl -v --host 192.168.178.24 --name myremote KEY_VOLDOWN
get_logger_name: samsungctl
get_logger_name: samsungctl.upnp.UPNP_Device
get_logger_name: samsungctl.upnp.UPNP_Device.adapter_addresses
get_logger_name: samsungctl.upnp.UPNP_Device.discover
get_logger_name: samsungctl.upnp.UPNP_Device.action
get_logger_name: samsungctl.upnp.UPNP_Device.icon
get_logger_name: samsungctl.upnp.UPNP_Device.service
get_logger_name: samsungctl.upnp.UPNP_Device.embedded_device
get_logger_name: samsungctl.upnp.UPNP_Device.upnp_class
get_logger_name: samsungctl.upnp.discover
get_logger_name: samsungctl.upnp
get_logger_name: samsungctl.wake_on_lan
get_logger_name: samsungctl.remote_legacy
get_logger_name: samsungctl.websocket_base
get_logger_name: samsungctl.art_mode
get_logger_name: samsungctl.application
get_logger_name: samsungctl.remote_websocket
get_logger_name: samsungctl.remote_encrypted.crypto
get_logger_name: samsungctl.remote_encrypted
Unable to discover any TV's
$ # returned without blocking
vogler commented 4 years ago

Seems like my TV does not accept KEY_HDMI1. I'm now back to using Ape:master with this workaround (cf. https://github.com/Ape/samsungctl/pull/95#issuecomment-539257769):

pipenv run python -m samsungctl -vv --host 192.168.178.24 --method websocket KEY_SOURCE KEY_DOWN KEY_RIGHT KEY_RIGHT KEY_ENTER
vogler commented 4 years ago

The original problem seems to be a deadlock:

$ pipenv run python -m samsungctl --host 192.168.178.24 --method websocket KEY_HDMI
Starting new HTTP connection (1): 192.168.178.24:8001
http://192.168.178.24:8001 "GET /api/v2/ HTTP/1.1" 200 1238
RemoteWrapper.__init__(config=<samsungctl.config.Config object at 0x104f68850>)
RemoteWrapper.__init__(config=<samsungctl.config.Config object at 0x104f68850>)
Starting new HTTP connection (1): 192.168.178.24:8001
http://192.168.178.24:8001 "GET /api/v2/ HTTP/1.1" 200 1238
RemoteWrapper.open()
RemoteWrapper.power()
RemoteWrapper.power => False
RemoteWrapper.power(value=True)
RemoteWrapper.power()
RemoteWrapper.power => False
RemoteWrapper.mac_address()
RemoteWrapper.mac_address => 'C0:97:27:19:F8:7E'
RemoteWrapper.mac_address()
RemoteWrapper.mac_address => 'C0:97:27:19:F8:7E'
RemoteWrapper.power()
RemoteWrapper.power => False
RemoteWrapper.open()
^CRemoteWrapper.mac_address()
RemoteWrapper.mac_address => 'C0:97:27:19:F8:7E'
RemoteWrapper.power()
RemoteWrapper.power => False
RemoteWrapper.open()
^CRemoteWrapper.mac_address()
RemoteWrapper.mac_address => 'C0:97:27:19:F8:7E'
RemoteWrapper.power()
RemoteWrapper.power => False
RemoteWrapper.open()