kdschlosser / samsungctl

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

TypeError: list indices must be integers or slices, not NoneType #120

Open henriz opened 5 years ago

henriz commented 5 years ago

Hello,

I have been trying to get my Samsung TV to work with home assistant. This is a maddening experience. Makes you want to burn stuff.

Anyway, I have figured out the issue is with samsungctl. So I got to this repo.

I have installed the development branch, now trying to use it:

samsungctl` --config-file samsungctl.conf KEY_MENU --name myremote

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 "/home/henri/python/bin/samsungctl", line 11, in load_entry_point('samsungctl==0.8.65b0', 'console_scripts', 'samsungctl')() File "/home/henri/python/lib/python3.7/site-packages/samsungctl-0.8.65b0-py3.7.egg/samsungctl/main.py", line 237, in main logger.setLevel(log_levels[args.verbose])

I tried the master branch as well. This simply hangs without ever returning, multiple CTRL-C's are needed to get it to quit.

The TV is a Samsung (duh) UE48H6240AWXXN

henriz commented 5 years ago

The error is on a line configuring the logger. If I comment out the line, the tool produces:

Unable to discover any TV's

henriz commented 5 years ago

Oh, to be clear, If i do:

http://192.168.1.26:8080/ws/app/Netflix

the TV starts netflix.

henriz commented 5 years ago

Addendum, this does work: https://github.com/eclair4151/SmartCrypto

So basically it should be able to control this TV..

gbrissey commented 5 years ago

@henriz I altered the utils.py directly, the way it was formatting the log message (to add a timestamp) was throwing a Key exception. Now there are no exceptions but, it discovers NO TV as you mentioned. The log shows it trying to discover via upnp at most of the IPs on the subnet. Not sure why it's doing this since I gave it the IP of the TV. And strange enough the log never shows an attempt to access the IP I gave it. Wish I could turn off upnp discover (must be a way).

I did write a simple python script using websocket-client accessing the TV on port 8002 , the TV requests permission for the device (it's consistent through) and I get the token from the TV. So I know the TV will respond.

Very frustrating.

gbrissey commented 4 years ago

Don't know about other TVs but my Q8FN has blocked port 1900, which UPNP uses. samsungctl use UPNP to discover the TVs, this is why my TV is never found. Too bad all that UPNP work is now blocked, no doubt due to security concerns by Samsung. A lot of work here, but I seem to just keep going down the rabbit hole trying to figure out how to get this to work. I may just write my own stripped down version of samsungctl for controlling my TV from my Home Assitant on a RPi base on the code here.

jkempson commented 4 years ago

Having exactly this issue. @henriz can you post the code you changed in utils.py?

There are obviously other issues here. Would probably help to post model numbers.

I'm trying to run on Samsung NU7000

gbrissey commented 4 years ago

in Utils.py in the class DebugLogger(object): approx. Line 111

       if msg.startswith('DEBUG*;*'):
            tstamp = time.strftime(r'%x  %X   ',time.localtime(time.time()))
            # this was the original line below
            # msg = time.strftime(msg.format('%%x  %%X'), time.localtime(time.time())) 
            msg = tstamp + msg

Hope this helps.

xchwarze commented 4 years ago

discover.py seems broken in develop branch. Never populate self._devices...

v0d0r commented 4 years ago

I seem to have a similar issue on a Samsung N5300 model. Checked out latest development branch. Am I missing something?

samsungctl --config-file samsungctl.conf KEY_MENU --name myremote 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.wake_on_lan get_logger_name: samsungctl.upnp.discover get_logger_name: samsungctl.upnp 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/bin/samsungctl", line 11, in load_entry_point('samsungctl==0.8.65b0', 'console_scripts', 'samsungctl')() File "/usr/local/lib/python2.7/dist-packages/samsungctl-0.8.65b0-py2.7.egg/samsungctl/main.py", line 237, in main logger.setLevel(log_levels[args.verbose]) TypeError: list indices must be integers, not NoneType