Closed twf75 closed 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.
No rush man! But yeah, that sounds logical to me (so much so that I thought that was the way it works right now...)
I know that is what people thought. that is the way it should work...
the library has been updated.
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.
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 ;)
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??
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.
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!
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
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
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.
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?
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.
if you want to test out the new power handling.. clone the develop branch.
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
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
Behaviour for KEY_POWER (also from off state) seems unchanged to the main branch.
try it now,
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.
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' ;-)
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
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.
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.
Same result for KEY_POWEROFF from an ON state.
Pulling the new one now :)
pull this one.. i just fixed that last traceback.
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.
try it now.
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
i need to see the beginning of the error
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
I updated it again.
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
Script hangs at this point, had to kill -9 it.
OK I think i have it solved this time.
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
(Script again hangs, ^C does nothing)
POWER_ON works too, other than hanging up the script (which may be at my end)
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
The TV does turn on though!
close error should now be fixed.
OFF works, and gracefully exits, still waiting on ON (tv turned on, script still running)
I think there was an issue with the command line arguments. I have tinkered with them and updated the code.
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
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
(left it running for ~3 minutes)
try it again,
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
(script hangs, unbreakable)
what is the error from?
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!
try it again.
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
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.
try it now...
I am trying to shrink thee power on time.
KEY_POWER should operate at the same speed as KEY_POWERON and KEY_POWEROFF. it is running the same code as those keys do.
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.