kdschlosser / samsungctl

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

Remote poweron (KEY_POWER) suddenly broken #95

Closed twf75 closed 5 years ago

twf75 commented 5 years ago

Since one of the latest commits, the KEY_POWER has stopped working. In the earlier versions, KEY_POWER worked for turning on my Q7. Now it fails with:

Max retries exceeded with url: /rcr/ (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x73c9d430>: Failed to establish a new connection: [Errno 113] No route to host',))

Using wake_on_lan.py with the ip works fine, and it worked fine on earlier commits.

kdschlosser commented 5 years ago

ok I need to tinker with setting the power.. I am trying to get the best and fastest mechanism in place..

I think the biggest crutch is this.. I do not know what TV's use what command.. I am thinking about modifying the behavior of the power keys.. and turning them into what they should be. and exposing them to the user that way.

KEY_POWER = power toggle. KEY_POWERON = power on KEY_POWEROFF = power off

the user would use the keys in this fashion. plain and simple the library will handle what needs to be sent to the TV.

this will remove a slew of confusion about those keys.. right now it all depends on what TV supports what key.. my way is it will not matter. the library will hash out what to use. and the user will get the proper thing happening.

yeah that is what I am going to do.. I will work on that right now.

twf75 commented 5 years ago

No rush man! But yeah, that sounds logical to me (so much so that I thought that was the way it works right now...)

kdschlosser commented 5 years ago

I know that is what people thought. that is the way it should work...

the library has been updated.

kdschlosser commented 5 years ago

Samsung TV's do not have the ability to be powered on from a key code.. I know I know do not ask me why there is a KEY_POWERON. but samsung goes have that keycode... the keycodes are not just for their TV's it is for all of their devices..

on some TV's the KEY_POWEROFF will turn the TV off. while on others the KEY_POWER will turn it off. the KEY_POWERON did nothing.

so now the behavior is as such..

KEY_POWER = toggle KEY_POWERON = power on KEY_POWEROFF - power off.

the library will handle what needs to be done. so the user will not have to worry about it.

twf75 commented 5 years ago

Just updated. Same result:

requests.exceptions.ConnectionError: HTTPConnectionPool(host='192.168.1.16', port=7676): Max retries exceeded with url: /rcr/ (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x73d43490>: Failed to establish a new connection: [Errno 113] No route to host',))

for KEY_POWERON and KEY_POWER

While the TV is on, the KEY_POWER and KEY_POWEROFF commands now causes the TV to cycle between power on and power off, until I send a break to the script.

The happy news is that whatever is causing the TV to powercycle from an on state IS able to turn ON the TV ;)

kdschlosser commented 5 years ago

While the TV is on, the KEY_POWER and KEY_POWEROFF commands now causes the TV to cycle between power on and power off, until I send a break to the script.

explain this better.. is it looping between power on and off over and over again??

kdschlosser commented 5 years ago

i fixed this issue.

requests.exceptions.ConnectionError: HTTPConnectionPool(host='192.168.1.16', port=7676): Max retries exceeded with url: /rcr/ (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x73d43490>: Failed to establish a new connection: [Errno 113] No route to host',))

the library has been updated.

twf75 commented 5 years ago

While the TV is on, the KEY_POWER and KEY_POWEROFF commands now causes the TV to cycle between power on and power off, until I send a break to the script.

explain this better.. is it looping between power on and off over and over again??

Other way round.

I'll try the new version!

twf75 commented 5 years ago

Same behaviour for POWER/POWEROFF (the cycle):

pi@raspberrypi:~/samsungctl $ samsungctl KEY_POWEROFF --config-file /home/pi/woonkamer.conf ^CTraceback (most recent call last): File "/usr/local/bin/samsungctl", line 11, in load_entry_point('samsungctl==0.8.0b0', 'console_scripts', 'samsungctl')() File "/usr/local/lib/python2.7/dist-packages/samsungctl-0.8.0b0-py2.7.egg/samsungctl/main.py", line 353, in main key(remote) File "/usr/local/lib/python2.7/dist-packages/samsungctl-0.8.0b0-py2.7.egg/samsungctl/key_mappings.py", line 12, in call remote.control(self.key) File "/usr/local/lib/python2.7/dist-packages/samsungctl-0.8.0b0-py2.7.egg/samsungctl/utils.py", line 24, in wrapper return func(*args, *kwargs) File "/usr/local/lib/python2.7/dist-packages/samsungctl-0.8.0b0-py2.7.egg/samsungctl/remote_websocket.py", line 306, in control self.power = False File "/usr/local/lib/python2.7/dist-packages/samsungctl-0.8.0b0-py2.7.egg/samsungctl/utils.py", line 24, in wrapper return func(args, **kwargs) File "/usr/local/lib/python2.7/dist-packages/samsungctl-0.8.0b0-py2.7.egg/samsungctl/remote_websocket.py", line 281, in power event.wait(2.0) File "/usr/lib/python2.7/threading.py", line 614, in wait self.__cond.wait(timeout) File "/usr/lib/python2.7/threading.py", line 359, in wait _sleep(delay) KeyboardInterrupt

twf75 commented 5 years ago

Also same behavior for POWER_ON / POWER from an OFF state:

pi@raspberrypi:~/samsungctl $ samsungctl KEY_POWER --config-file /home/pi/woonkamer.conf Traceback (most recent call last): File "/usr/local/bin/samsungctl", line 11, in load_entry_point('samsungctl==0.8.0b0', 'console_scripts', 'samsungctl')() File "/usr/local/lib/python2.7/dist-packages/samsungctl-0.8.0b0-py2.7.egg/samsungctl/main.py", line 338, in main with Remote(config) as remote: File "/usr/local/lib/python2.7/dist-packages/samsungctl-0.8.0b0-py2.7.egg/samsungctl/remote.py", line 82, in call return RemoteWrapper(conf) File "/usr/local/lib/python2.7/dist-packages/samsungctl-0.8.0b0-py2.7.egg/samsungctl/remote.py", line 69, in init self File "/usr/local/lib/python2.7/dist-packages/samsungctl-0.8.0b0-py2.7.egg/samsungctl/upnp/init.py", line 20, in init UPNPObject.init(self, ip, locations) File "/usr/local/lib/python2.7/dist-packages/samsungctl-0.8.0b0-py2.7.egg/samsungctl/upnp/UPNP_Device/upnp_class.py", line 35, in init response = requests.get(location) File "/usr/local/lib/python2.7/dist-packages/requests-2.21.0-py2.7.egg/requests/api.py", line 75, in get return request('get', url, params=params, kwargs) File "/usr/local/lib/python2.7/dist-packages/requests-2.21.0-py2.7.egg/requests/api.py", line 60, in request return session.request(method=method, url=url, kwargs) File "/usr/local/lib/python2.7/dist-packages/requests-2.21.0-py2.7.egg/requests/sessions.py", line 533, in request resp = self.send(prep, send_kwargs) File "/usr/local/lib/python2.7/dist-packages/requests-2.21.0-py2.7.egg/requests/sessions.py", line 646, in send r = adapter.send(request, kwargs) File "/usr/local/lib/python2.7/dist-packages/requests-2.21.0-py2.7.egg/requests/adapters.py", line 516, in send raise ConnectionError(e, request=request) requests.exceptions.ConnectionError: HTTPConnectionPool(host='192.168.1.16', port=7676): Max retries exceeded with url: /rcr/ (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x73d5e490>: Failed to establish a new connection: [Errno 113] No route to host',))

kdschlosser commented 5 years ago

OK here is what I am going to do. right now I have the library set up so it keeps on retrying to send the commands..

I am willing to bet you any amount of money.. this is the shit ass thing samsung did. because I do not know which key works on what TV's either the KEY_POWER or the KEY_POWEROFF i am sending both of them...

Samsung actually does have the KEY_POWER set up as a toggle. this is the hoot.. because I am doing a loop and retrying to the keys. it is happening to fast. and the KEY_POWER is toggling the TV off. and then before the websocket gets a chance to close the KEY_POWER gets sent again.. and the TV turns back on.. LOL

So.. I am going to fire the KEY_POWER first.. then the KEY_POWEROFF and each one will get fired only a single time. no looping..

I am going to have to keep the loop with the WOL packets. this is because a WOL packet is a broadcast an the TV may not get the packet.. broadcasting can have that issue. and it should be expected that a packet may not get where it is supposed to go. and the programming code should account for this.

as far as that last error.... I never thought about the UPNP and the TV being off. LOL.. i will have to fix that as well.

the old version of samsungctl will simply error out if the TV is off. I have expanded it's functionality to handle the TV being off so I need to make the library fully capable of dealing with the TV when it is off. and this is did not do with the upnp side of things...

it is going to take me a whiile to hammer that out, so give me a half a day or so.

twf75 commented 5 years ago

Again, no rush! Just very happy that you are doing this, so I'm the last one that'll make demands on your time.

And while you are in there (and I haven't checked myself) : Does the --start-app check power state?

kdschlosser commented 5 years ago

every command does. if the TV power is on but the websocket connection is not made. it will make it. of the power is off. it will print a log statement saying the TV is off and continue along it's merry way.

kdschlosser commented 5 years ago

if you want to test out the new power handling.. clone the develop branch.

twf75 commented 5 years ago

Cloned the develop branch with: git clone https://github.com/kdschlosser/samsungctl.git develop cd develop/ sudo python setup.py install

Verified /usr/local/bin/samsungctl is the current date/time

KEY_POWER and KEY_POWEROFF still cycle from on to off to on etc

pi@raspberrypi:/usr/local/bin $ samsungctl KEY_POWEROFF --config-file /home/pi/woonkamer.conf ^CTraceback (most recent call last): File "/usr/local/bin/samsungctl", line 11, in load_entry_point('samsungctl==0.8.0b0', 'console_scripts', 'samsungctl')() File "/usr/local/lib/python2.7/dist-packages/samsungctl-0.8.0b0-py2.7.egg/samsungctl/main.py", line 353, in main key(remote) File "/usr/local/lib/python2.7/dist-packages/samsungctl-0.8.0b0-py2.7.egg/samsungctl/key_mappings.py", line 12, in call remote.control(self.key) File "/usr/local/lib/python2.7/dist-packages/samsungctl-0.8.0b0-py2.7.egg/samsungctl/utils.py", line 24, in wrapper return func(*args, kwargs) File "/usr/local/lib/python2.7/dist-packages/samsungctl-0.8.0b0-py2.7.egg/samsungctl/remote_websocket.py", line 306, in control self.power = False File "/usr/local/lib/python2.7/dist-packages/samsungctl-0.8.0b0-py2.7.egg/samsungctl/utils.py", line 24, in wrapper return func(args, kwargs) File "/usr/local/lib/python2.7/dist-packages/samsungctl-0.8.0b0-py2.7.egg/samsungctl/remote_websocket.py", line 279, in power self.send("ms.remote.control", power) File "/usr/local/lib/python2.7/dist-packages/samsungctl-0.8.0b0-py2.7.egg/samsungctl/utils.py", line 24, in wrapper return func(args, kwargs) File "/usr/local/lib/python2.7/dist-packages/samsungctl-0.8.0b0-py2.7.egg/samsungctl/remote_websocket.py", line 233, in send self.send_event.wait(0.3) File "/usr/lib/python2.7/threading.py", line 614, in wait self.__cond.wait(timeout) File "/usr/lib/python2.7/threading.py", line 359, in wait _sleep(delay) KeyboardInterrupt

twf75 commented 5 years ago

New behaviour for KEY_POWERON:

pi@raspberrypi:/usr/local/bin $ samsungctl KEY_POWERON --config-file /home/pi/woonkamer.conf Traceback (most recent call last): File "/usr/local/bin/samsungctl", line 11, in load_entry_point('samsungctl==0.8.0b0', 'console_scripts', 'samsungctl')() File "/usr/local/lib/python2.7/dist-packages/samsungctl-0.8.0b0-py2.7.egg/samsungctl/main.py", line 338, in main with Remote(config) as remote: File "/usr/local/lib/python2.7/dist-packages/samsungctl-0.8.0b0-py2.7.egg/samsungctl/remote.py", line 82, in call return RemoteWrapper(conf) File "/usr/local/lib/python2.7/dist-packages/samsungctl-0.8.0b0-py2.7.egg/samsungctl/remote.py", line 69, in init self File "/usr/local/lib/python2.7/dist-packages/samsungctl-0.8.0b0-py2.7.egg/samsungctl/upnp/init.py", line 20, in init UPNPObject.init(self, ip, locations) File "/usr/local/lib/python2.7/dist-packages/samsungctl-0.8.0b0-py2.7.egg/samsungctl/upnp/UPNP_Device/upnp_class.py", line 35, in init response = requests.get(location) File "/usr/local/lib/python2.7/dist-packages/requests-2.21.0-py2.7.egg/requests/api.py", line 75, in get return request('get', url, params=params, kwargs) File "/usr/local/lib/python2.7/dist-packages/requests-2.21.0-py2.7.egg/requests/api.py", line 60, in request return session.request(method=method, url=url, kwargs) File "/usr/local/lib/python2.7/dist-packages/requests-2.21.0-py2.7.egg/requests/sessions.py", line 533, in request resp = self.send(prep, send_kwargs) File "/usr/local/lib/python2.7/dist-packages/requests-2.21.0-py2.7.egg/requests/sessions.py", line 646, in send r = adapter.send(request, kwargs) File "/usr/local/lib/python2.7/dist-packages/requests-2.21.0-py2.7.egg/requests/adapters.py", line 516, in send raise ConnectionError(e, request=request) requests.exceptions.ConnectionError: HTTPConnectionPool(host='192.168.1.16', port=9119): Max retries exceeded with url: /screen_sharing (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x73cab450>: Failed to establish a new connection: [Errno 111] Connection refused',))

twf75 commented 5 years ago

Behaviour for KEY_POWER (also from off state) seems unchanged to the main branch.

kdschlosser commented 5 years ago

try it now,

kdschlosser commented 5 years ago

also your first error is because of you interrupting the script. it is going to take a bit for the TV to power down. so the script waits until it is off before it will exit. it will look like it is doing nothing for up to 10 seconds.

twf75 commented 5 years ago

also your first error is because of you interrupting the script. it is going to take a bit for the TV to power down. so the script waits until it is off before it will exit. it will look like it is doing nothing for up to 10 seconds.

The interrupt is because at that point the TV went off, then on again. As the plan was 'turn off', I've taken 'turning on again' as 'not working' ;-)

twf75 commented 5 years ago

pi@raspberrypi:~/develop/develop $ samsungctl KEY_POWERON --config-file /home/pi/woonkamer.conf Traceback (most recent call last): File "/usr/local/bin/samsungctl", line 11, in load_entry_point('samsungctl==0.8.0b0', 'console_scripts', 'samsungctl')() File "/usr/local/lib/python2.7/dist-packages/samsungctl-0.8.0b0-py2.7.egg/samsungctl/main.py", line 338, in main with Remote(config) as remote: File "/usr/local/lib/python2.7/dist-packages/samsungctl-0.8.0b0-py2.7.egg/samsungctl/remote.py", line 81, in call return RemoteWrapper(conf) File "/usr/local/lib/python2.7/dist-packages/samsungctl-0.8.0b0-py2.7.egg/samsungctl/remote.py", line 68, in init config.upnp_locations File "/usr/local/lib/python2.7/dist-packages/samsungctl-0.8.0b0-py2.7.egg/samsungctl/upnp/init.py", line 19, in init self.name = self.name File "/usr/local/lib/python2.7/dist-packages/samsungctl-0.8.0b0-py2.7.egg/samsungctl/upnp/UPNP_Device/upnp_class.py", line 130, in getattr if item in self._devices: File "/usr/local/lib/python2.7/dist-packages/samsungctl-0.8.0b0-py2.7.egg/samsungctl/upnp/UPNP_Device/upnp_class.py", line 130, in getattr

Last 3 lines repeated a couple of hunderd times

RuntimeError: maximum recursion depth exceeded while calling a Python object

TV was off, command was KEY_POWERON. KEY_POWER behaves the same.

kdschlosser commented 5 years ago

ahh ok.. yes that would be not working. But the traceback does not help because of the interruption

I just updated the develop branch again.

twf75 commented 5 years ago

Same result for KEY_POWEROFF from an ON state.

twf75 commented 5 years ago

Pulling the new one now :)

kdschlosser commented 5 years ago

pull this one.. i just fixed that last traceback.

twf75 commented 5 years ago

Same response as above. But now the script hangs up at the end. Can't be interrupted even...

File "/usr/local/lib/python2.7/dist-packages/samsungctl-0.8.0b0-py2.7.egg/samsungctl/upnp/UPNP_Device/upnp_class.py", line 130, in getattr if item in self._devices: File "/usr/local/lib/python2.7/dist-packages/samsungctl-0.8.0b0-py2.7.egg/samsungctl/upnp/UPNP_Device/upnp_class.py", line 130, in getattr if item in self._devices: RuntimeError: maximum recursion depth exceeded while calling a Python object ^C

KEY_POWEROFF in this case, from an ON state.

kdschlosser commented 5 years ago

try it now.

twf75 commented 5 years ago

Sorry :(

File "/usr/local/lib/python2.7/dist-packages/samsungctl-0.8.0b0-py2.7.egg/samsungctl/upnp/UPNP_Device/upnp_class.py", line 130, in getattr if item in self._devices: File "/usr/local/lib/python2.7/dist-packages/samsungctl-0.8.0b0-py2.7.egg/samsungctl/upnp/UPNP_Device/upnp_class.py", line 130, in getattr if item in self._devices: File "/usr/local/lib/python2.7/dist-packages/samsungctl-0.8.0b0-py2.7.egg/samsungctl/upnp/UPNP_Device/upnp_class.py", line 130, in getattr if item in self._devices: File "/usr/local/lib/python2.7/dist-packages/samsungctl-0.8.0b0-py2.7.egg/samsungctl/upnp/UPNP_Device/upnp_class.py", line 130, in getattr if item in self._devices: RuntimeError: maximum recursion depth exceeded while calling a Python object ^C ^C

kdschlosser commented 5 years ago

i need to see the beginning of the error

twf75 commented 5 years ago

My bad:

pi@raspberrypi:~/develop/develop $ samsungctl KEY_POWEROFF --config-file /home/pi/woonkamer.conf Traceback (most recent call last): File "/usr/local/bin/samsungctl", line 11, in load_entry_point('samsungctl==0.8.0b0', 'console_scripts', 'samsungctl')() File "/usr/local/lib/python2.7/dist-packages/samsungctl-0.8.0b0-py2.7.egg/samsungctl/main.py", line 338, in main with Remote(config) as remote: File "/usr/local/lib/python2.7/dist-packages/samsungctl-0.8.0b0-py2.7.egg/samsungctl/remote.py", line 83, in call return RemoteWrapper(conf) File "/usr/local/lib/python2.7/dist-packages/samsungctl-0.8.0b0-py2.7.egg/samsungctl/remote.py", line 70, in init config.upnp_locations File "/usr/local/lib/python2.7/dist-packages/samsungctl-0.8.0b0-py2.7.egg/samsungctl/upnp/init.py", line 23, in init self.connect_upnp() File "/usr/local/lib/python2.7/dist-packages/samsungctl-0.8.0b0-py2.7.egg/samsungctl/upnp/UPNP_Device/upnp_class.py", line 130, in getattr if item in self._devices: File "/usr/local/lib/python2.7/dist-packages/samsungctl-0.8.0b0-py2.7.egg/samsungctl/upnp/UPNP_Device/upnp_class.py", line 130, in getattr if item in self._devices:

kdschlosser commented 5 years ago

I updated it again.

twf75 commented 5 years ago

pi@raspberrypi:~/develop/develop $ samsungctl KEY_POWEROFF --config-file /home/pi/woonkamer.conf Traceback (most recent call last): File "/usr/local/bin/samsungctl", line 11, in load_entry_point('samsungctl==0.8.0b0', 'console_scripts', 'samsungctl')() File "/usr/local/lib/python2.7/dist-packages/samsungctl-0.8.0b0-py2.7.egg/samsungctl/main.py", line 338, in main with Remote(config) as remote: File "/usr/local/lib/python2.7/dist-packages/samsungctl-0.8.0b0-py2.7.egg/samsungctl/remote.py", line 73, in call return RemoteWrapper(conf) File "/usr/local/lib/python2.7/dist-packages/samsungctl-0.8.0b0-py2.7.egg/samsungctl/remote.py", line 60, in init config.upnp_locations File "/usr/local/lib/python2.7/dist-packages/samsungctl-0.8.0b0-py2.7.egg/samsungctl/upnp/init.py", line 29, in init self.connect_upnp() File "/usr/local/lib/python2.7/dist-packages/samsungctl-0.8.0b0-py2.7.egg/samsungctl/upnp/UPNP_Device/upnp_class.py", line 134, in getattr raise AttributeError(item) AttributeError: connect_upnp ^C

Script hangs at this point, had to kill -9 it.

kdschlosser commented 5 years ago

OK I think i have it solved this time.

twf75 commented 5 years ago

In the sense that the TV actually turned off this time: YES!

However...

pi@raspberrypi:~/develop/develop $ samsungctl KEY_POWEROFF --config-file /home/pi/woonkamer.conf Traceback (most recent call last): File "/usr/local/bin/samsungctl", line 11, in load_entry_point('samsungctl==0.8.0b0', 'console_scripts', 'samsungctl')() File "/usr/local/lib/python2.7/dist-packages/samsungctl-0.8.0b0-py2.7.egg/samsungctl/main.py", line 408, in main remote.source = args.source File "/usr/local/lib/python2.7/dist-packages/samsungctl-0.8.0b0-py2.7.egg/samsungctl/remote.py", line 71, in exit self.close() File "/usr/local/lib/python2.7/dist-packages/samsungctl-0.8.0b0-py2.7.egg/samsungctl/websocket_base.py", line 140, in close raise NotImplementedError NotImplementedError

(Script again hangs, ^C does nothing)

twf75 commented 5 years ago

POWER_ON works too, other than hanging up the script (which may be at my end)

twf75 commented 5 years ago

Gave it a couple minutes after hanging:

pi@raspberrypi:~/develop/develop $ samsungctl KEY_POWERON --config-file /home/pi/woonkamer.conf ^CTraceback (most recent call last): File "/usr/local/bin/samsungctl", line 11, in load_entry_point('samsungctl==0.8.0b0', 'console_scripts', 'samsungctl')() File "/usr/local/lib/python2.7/dist-packages/samsungctl-0.8.0b0-py2.7.egg/samsungctl/main.py", line 408, in main remote.source = args.source File "/usr/local/lib/python2.7/dist-packages/samsungctl-0.8.0b0-py2.7.egg/samsungctl/remote.py", line 71, in exit self.close() File "/usr/local/lib/python2.7/dist-packages/samsungctl-0.8.0b0-py2.7.egg/samsungctl/websocket_base.py", line 140, in close raise NotImplementedError NotImplementedError

The TV does turn on though!

kdschlosser commented 5 years ago

close error should now be fixed.

twf75 commented 5 years ago

OFF works, and gracefully exits, still waiting on ON (tv turned on, script still running)

kdschlosser commented 5 years ago

I think there was an issue with the command line arguments. I have tinkered with them and updated the code.

twf75 commented 5 years ago

ON does work (in that the TV turns on) but hangs:

pi@raspberrypi:~/develop/develop $ samsungctl KEY_POWERON --config-file /home/pi/woonkamer.conf ^CTraceback (most recent call last): File "/usr/local/bin/samsungctl", line 11, in load_entry_point('samsungctl==0.8.0b0', 'console_scripts', 'samsungctl')() File "/usr/local/lib/python2.7/dist-packages/samsungctl-0.8.0b0-py2.7.egg/samsungctl/main.py", line 353, in main key(remote) File "/usr/local/lib/python2.7/dist-packages/samsungctl-0.8.0b0-py2.7.egg/samsungctl/key_mappings.py", line 12, in call remote.control(self.key) File "/usr/local/lib/python2.7/dist-packages/samsungctl-0.8.0b0-py2.7.egg/samsungctl/utils.py", line 24, in wrapper return func(*args, *kwargs) File "/usr/local/lib/python2.7/dist-packages/samsungctl-0.8.0b0-py2.7.egg/samsungctl/remote_websocket.py", line 279, in control self.power = True File "/usr/local/lib/python2.7/dist-packages/samsungctl-0.8.0b0-py2.7.egg/samsungctl/utils.py", line 24, in wrapper return func(args, **kwargs) File "/usr/local/lib/python2.7/dist-packages/samsungctl-0.8.0b0-py2.7.egg/samsungctl/remote_websocket.py", line 225, in power event.wait(2.0) File "/usr/lib/python2.7/threading.py", line 614, in wait self.__cond.wait(timeout) File "/usr/lib/python2.7/threading.py", line 359, in wait _sleep(delay) KeyboardInterrupt

twf75 commented 5 years ago

Finished processing dependencies for samsungctl==0.8.0b0 pi@raspberrypi:~/develop/develop $ samsungctl KEY_POWEROFF --config-file /home/pi/woonkamer.conf pi@raspberrypi:~/develop/develop $ samsungctl KEY_POWERON --config-file /home/pi/woonkamer.conf

Looks about the same. Execution time on OFF is about 10 to 15 seconds, works and exits. ON works, but hangs:

pi@raspberrypi:~/develop/develop $ samsungctl KEY_POWERON --config-file /home/pi/woonkamer.conf ^CTraceback (most recent call last): File "/usr/local/bin/samsungctl", line 11, in load_entry_point('samsungctl==0.8.0b0', 'console_scripts', 'samsungctl')() File "/usr/local/lib/python2.7/dist-packages/samsungctl-0.8.0b0-py2.7.egg/samsungctl/main.py", line 360, in main key(remote) File "/usr/local/lib/python2.7/dist-packages/samsungctl-0.8.0b0-py2.7.egg/samsungctl/key_mappings.py", line 12, in call remote.control(self.key) File "/usr/local/lib/python2.7/dist-packages/samsungctl-0.8.0b0-py2.7.egg/samsungctl/utils.py", line 24, in wrapper return func(*args, *kwargs) File "/usr/local/lib/python2.7/dist-packages/samsungctl-0.8.0b0-py2.7.egg/samsungctl/remote_websocket.py", line 279, in control self.power = True File "/usr/local/lib/python2.7/dist-packages/samsungctl-0.8.0b0-py2.7.egg/samsungctl/utils.py", line 24, in wrapper return func(args, **kwargs) File "/usr/local/lib/python2.7/dist-packages/samsungctl-0.8.0b0-py2.7.egg/samsungctl/remote_websocket.py", line 225, in power event.wait(2.0) File "/usr/lib/python2.7/threading.py", line 614, in wait self.__cond.wait(timeout) File "/usr/lib/python2.7/threading.py", line 359, in wait _sleep(delay) KeyboardInterrupt

(left it running for ~3 minutes)

kdschlosser commented 5 years ago

try it again,

twf75 commented 5 years ago

OFF works. TV almost immidiately turns off. Script runs for 10 seconds after.

ON works, takes the TV about 10 seconds to actually turn on.

Both now exit gracefully!

KEY_POWER works for OFF, not for ON:

pi@raspberrypi:~/develop/develop $ samsungctl KEY_POWER --config-file /home/pi/woonkamer.conf http://192.168.1.16:9119/screen_sharing Traceback (most recent call last): File "/usr/local/bin/samsungctl", line 11, in load_entry_point('samsungctl==0.8.0b0', 'console_scripts', 'samsungctl')() File "/usr/local/lib/python2.7/dist-packages/samsungctl-0.8.0b0-py2.7.egg/samsungctl/main.py", line 345, in main with Remote(config) as remote: File "/usr/local/lib/python2.7/dist-packages/samsungctl-0.8.0b0-py2.7.egg/samsungctl/remote.py", line 73, in call return RemoteWrapper(conf) File "/usr/local/lib/python2.7/dist-packages/samsungctl-0.8.0b0-py2.7.egg/samsungctl/remote.py", line 60, in init config.upnp_locations File "/usr/local/lib/python2.7/dist-packages/samsungctl-0.8.0b0-py2.7.egg/samsungctl/upnp/init.py", line 23, in init self._connect_upnp() File "/usr/local/lib/python2.7/dist-packages/samsungctl-0.8.0b0-py2.7.egg/samsungctl/upnp/init.py", line 36, in _connect_upnp UPNPObject.init(self, self.ip_address, self._locations) File "/usr/local/lib/python2.7/dist-packages/samsungctl-0.8.0b0-py2.7.egg/samsungctl/upnp/UPNP_Device/upnp_class.py", line 34, in init response = requests.get(location) File "/usr/local/lib/python2.7/dist-packages/requests-2.21.0-py2.7.egg/requests/api.py", line 75, in get return request('get', url, params=params, kwargs) File "/usr/local/lib/python2.7/dist-packages/requests-2.21.0-py2.7.egg/requests/api.py", line 60, in request return session.request(method=method, url=url, kwargs) File "/usr/local/lib/python2.7/dist-packages/requests-2.21.0-py2.7.egg/requests/sessions.py", line 533, in request resp = self.send(prep, send_kwargs) File "/usr/local/lib/python2.7/dist-packages/requests-2.21.0-py2.7.egg/requests/sessions.py", line 646, in send r = adapter.send(request, kwargs) File "/usr/local/lib/python2.7/dist-packages/requests-2.21.0-py2.7.egg/requests/adapters.py", line 516, in send raise ConnectionError(e, request=request) requests.exceptions.ConnectionError: HTTPConnectionPool(host='192.168.1.16', port=9119): Max retries exceeded with url: /screen_sharing (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x73d09af0>: Failed to establish a new connection: [Errno 111] Connection refused',))

(script hangs, unbreakable)

kdschlosser commented 5 years ago

what is the error from?

twf75 commented 5 years ago

Sorry, should have said.

Error is after samsungctl KEY_POWER --config-file /home/pi/woonkamer.conf with the TV in an OFF state.

The rest work fine!

kdschlosser commented 5 years ago

try it again.

kdschlosser commented 5 years ago

also when the TV is on use your browser and go to this URL..

http://192.168.1.16:9119/screen_sharing

see if it is valid

twf75 commented 5 years ago

From an OFF state: KEY_POWER works, TV turns on (and is quite fast) From an ON state: KEY_POWER works , TV turns off (less fast, but acceptable) From an OFF state: KEY_POWERON works, TV turns on (feels slower than KEY_POWER) From an ON state: KEY_POWEROFF works, TV turns off (about the same as KEY_POWER)

All commands exit gracefully. So this feels fixed :)

http://192.168.1.16:9119/screen_sharing is a valid URL with the TV on. Times out while the TV is off.

kdschlosser commented 5 years ago

try it now...

I am trying to shrink thee power on time.

kdschlosser commented 5 years ago

KEY_POWER should operate at the same speed as KEY_POWERON and KEY_POWEROFF. it is running the same code as those keys do.