joshjowen / script.json-cec

cec control for xbmc/kodi
GNU General Public License v2.0
71 stars 34 forks source link

DEBUG: ToggleDeviceState - putting CEC device on standby... - but nothing happenes #8

Open natterstefan opened 6 years ago

natterstefan commented 6 years ago

Hello,

first of all - thanks for making such a great script. It looks very promising. But I am not able to make it work. The following issue occurs (originally posted here):

(...) The Pi answers (get the following response) but the TV doesn't act (eg. turn on).

My Request and the Response:

{
  "id": 1,
  "jsonrpc": "2.0",
  "result": "OK"
}

Am I missing any setting (firewall) or something? Or should it work kind of out of the box?

Edit: Taking a look into the kodi.log reveals the following:

13:08:05.720 T:1491071984   DEBUG: CWebServer[80]: request received for /jsonrpc?request={%22jsonrpc%22:%222.0%22,%22method%22:%22Addons.ExecuteAddon%22,%22params%22:{%22addonid%22:%22script.json-cec%22,%22params%22:{%22command%22:%22standby%22}},%22id%22:1}
13:08:05.736 T:1305474032   DEBUG: Thread LanguageInvoker start, auto delete: false
13:08:05.737 T:1305474032    INFO: initializing python engine.
13:08:05.737 T:1305474032   DEBUG: CPythonInvoker(29, /home/osmc/.kodi/addons/script.json-cec/script.py): start processing
13:08:06.222 T:1305474032   DEBUG: -->Python Interpreter Initialized<--
13:08:06.223 T:1305474032   DEBUG: CPythonInvoker(29, /home/osmc/.kodi/addons/script.json-cec/script.py): the source file to load is "/home/osmc/.kodi/addons/script.json-cec/script.py"
13:08:06.224 T:1305474032   DEBUG: CPythonInvoker(29, /home/osmc/.kodi/addons/script.json-cec/script.py): setting the Python path to /home/osmc/.kodi/addons/script.json-cec:/usr/lib/python2.7:/usr/lib/python2.7/plat-arm-linux-gnueabihf:/usr/lib/python2.7/lib-tk:/usr/lib/python2.7/lib-old:/usr/lib/python2.7/lib-dynload:/usr/local/lib/python2.7/dist-packages:/usr/lib/python2.7/dist-packages:/usr/lib/python2.7/dist-packages/PILcompat:/usr/lib/python2.7/dist-packages/gtk-2.0
13:08:06.224 T:1305474032   DEBUG: CPythonInvoker(29, /home/osmc/.kodi/addons/script.json-cec/script.py): entering source directory /home/osmc/.kodi/addons/script.json-cec
13:08:06.225 T:1305474032   DEBUG: CPythonInvoker(29, /home/osmc/.kodi/addons/script.json-cec/script.py): instantiating addon using automatically obtained id of "script.json-cec" dependent on version 2.1.0 of the xbmc.python api
13:08:06.336 T:1305474032    INFO: CPythonInvoker(29, /home/osmc/.kodi/addons/script.json-cec/script.py): script successfully run
13:08:06.344 T:1305474032    INFO: Python script stopped
13:08:06.344 T:1305474032   DEBUG: Thread LanguageInvoker 1305474032 terminating
13:08:06.350 T:1958453248   DEBUG: ToggleDeviceState - putting CEC device on standby...

But nothing happened... Even though I see: 13:08:06.350 T:1958453248 DEBUG: ToggleDeviceState - putting CEC device on standby....

Any clues?

natterstefan commented 6 years ago

Hm. I guess it is something you are not able to fix, are you? Because I just saw this: https://github.com/joshjowen/script.json-cec/issues/1

joshjowen commented 6 years ago

Unfortunately, I don't think that there is much I can do about it as you have already noticed. I'll leave this issue open but if you take a look at the source code you will see that the script really does very little itself, it just passes through the commands to KODI's built in functions

natterstefan commented 6 years ago

@joshjowen Yeah, I read through your code and got that you are not responsible. Must be somewhere else, maybe also my TV does not support it (only turn on but not turn off via CEC). Another reason to buy a new TV ^^ Thanks though.

mattie47 commented 6 years ago

@natterstefan my old Samsung series 5 LCD could only turn on, and not off via CEC.

You should be able to confirm this just using the cec-client commands over SSH first.

Confirm that ON/OFF works with cec-client first, and then we can try narrow down what the problem is. Of course restart Kodi or your raspberry pi after using cec-client given it kills the libcec functionality within Kodi.

Personally I've found the 3rd kodi cec function toggle not to do anything super useful.

I think given you've confirmed that JSON-cec is correctly sending the commands, and Kodi seems to be doing some form of action on it, we can rule these variables out.

Thanks,

Matt

pittbull commented 6 years ago

@natterstefan @joshjowen

I found this code whilst implementing Kodi/Alexa and I thought "Hey!" what an excellent idea. Now - I did get the same response as you did in that the script successfully completes but nothing happens. But - I remembered a code snippet I used a few weeks back in relation to Kodi and CEC and there seem to be an issue with how you are calling the internal CEC function within Python.

I updated as follows:

if command and command[0] == 'activate':
        #xbmc.executebuiltin('CECActivateSource')
        xbmc.executebuiltin('CECActivateSource()')

elif command and command[0] == 'toggle':
        #xbmc.executebuiltin('CECToggleState')
        xbmc.executebuiltin('CECToggleState()')

elif command and command[0] == 'standby':
        #xbmc.executebuiltin('CECStandby')
          xbmc.executebuiltin('CECStandby()')

What I achieved was to atleast power ON my tv - but neither toggle nor standby works. Maybe this is something we can look into? :)

pittbull commented 6 years ago

I just found this as well but cannot test before I get home:

https://forum.kodi.tv/showthread.php?tid=149356&pid=2253184#pid2253184

Basically it states:

Change: <setting id="standby_devices" value="231" /> to <setting id="standby_devices" value="36037" /> in ~/.kodi/userdata/peripheral_data/rpi_2708_1001.xml (or equivalent)

natterstefan commented 6 years ago

@pittbull this sounds indeed promising. I am curious what you will tell us later.

pittbull commented 6 years ago

Hopefully I can tell you that it works because yesterday the WAF hit an all time high when I introduced Alexa controlled KODI - with automatic tv power on. ;)

pittbull commented 6 years ago

@natterstefan

I have now tested and achieved 100% success! 💃

This is what I did:

Before changing the above file execute: "systemctl stop kodi" If this is not done the change will be reverted by Kodi.

Happy testing. :)

natterstefan commented 6 years ago

Hi @pittbull, sounds really promising. I have some questions:

Question 1

Question 2

Before changing the above file execute: "systemctl stop kodi"

Question 3

I also changed the commands in the script.py for the addon as stated in my earlier post but I will retest this weekend if these can be reverted after the other changes.

mattie47 commented 6 years ago

@pittbull Thanks for posting above.

I just did a fresh install of osmc on my Rpi3 today, and struck the same problem as you and @natterstefan where standby would not do anything.

Making the above change you suggested has fixed the problem.

I haven't done a diff of upstream, but I suspect

<setting id="standby_devices" value="231" />

is a somewhat recent change as my previous install had the correct value of "36037"

@natterstefan Q1:

osmc@osmc:~$ sudo systemctl stop mediacenter
or
osmc@osmc:~$ sudo systemctl stop kodi

Then change ~/.kodi/userdata/peripheral_data/rpi_XXXX_XXXX.xml with the following:

-<setting id="standby_devices" value="231" />
+<setting id="standby_devices" value="36037" />

Q2:

I get the vibe no. I suspect it shouldn't get touched unless it's a fresh install of kodi. Changes to this have persisted for me with reboots etc.

danmed commented 6 years ago

I have the same problem but using a Vero 4K (OSMC)... i can't find the file you guys are talking about.. the peripheral_data folder is just empty

mattie47 commented 6 years ago

@danmed Did you manage to figure out your problem?

I can't imagine the Vero4k OSMC differing too much from the RaspberryPi image.

danmed commented 6 years ago

@mattie47 The problem is that in the peripherals settings in OSMC, the standby device is set to none.. if you change it in there it fixes the problem.. The onyl issue i have now is that it only responds if the Tv is on the OSMC source.. if i'm on another source nothing happens :'(

mattie47 commented 6 years ago

The onyl issue i have now is that it only responds if the Tv is on the OSMC source.. if i'm on another source nothing happens :'(

I think for me I solve this by sending "on" and then "off". Sending on (at least with whatever I have configured) forces it to change source to Kodi, and then send off to turn off.

There should be some workaround for you, it's just a case of spending time figuring out how/what it is.

Thanks,

Matt

danmed commented 6 years ago

That's an interesting idea... i'll give that a go

chriskol commented 5 years ago

I've encountered this (what @natterstefan had) with my new Samsung TV. When I get a chance, possibly this weekend, I'll try some of the tips above, but any chance of someone either merging into this code or forking their solution so a semi-luddite like me doesn't need to download, edit, install via zip, and can instead just not worry about me messing anything up? :D

wwwindisch commented 5 years ago

I can't turn off my TV, too. Turning it on works... The entry <setting id="standby_devices" value="36037" /> is in the file rpi_2708_1001.xml But I'm not sure, if there are other entries in this CEC settings file, which could cause this problem. Could someone, who successfully managed to turn the TV on and off, please post the complete content of the file here for comparison? Thank you!

FredrikWendt commented 4 years ago

With a fresh install of OSMC on a Raspberry Pi 3, connected to a 10 year old Sony, I got this to work after going into System > Input > Peripherals > CEC Adapter > "Devices to power off during shutdown". I also took additional steps (see #11 ) but I believe this one was the kicker.