Req CEC Control via JSON API
#31
Thanks for the addon, Joshjowen. I wrote some simple bash scripts to issue the JSON commands to my RPi (Openelec - Gotham) and the 'standby' and 'toggle' command works to turn the TV off. However, I can't seem to turn the TV on with 'activate' or 'toggle' even though the command is successfully issued. Perhaps this is a limitation of my TV (Sony Bravia (KDL-40EX650); I poked around the TV settings and all CEC options were enabled. What are your CEC settings on XBMC? Thanks again for the addon.
Reply
#32
My Panasonic Viera also only turns off with toggle but activate turns it on fine. my settings are attached. I hope they help Image
Reply
#33
I managed to get activate working now. Toggle is the same for me - turns the TV off fine but won't turn it on. It's not a big problem now that activate works. Many thanks for this addon...it's added functionality to my setup that I've been looking for for quite a while.
Reply
#34
A eventghost user called kasinator created a plugin for the cec adapter from pulse eight
http://www.eventghost.net/forum/viewtopi...f=9&t=5907

I have a dual monitor set up and I am just using it to launch xbmc on tv when selecting the xbmc source on the samsung remote.
But if you don't care about installing eventghost, possibilities are quite infinite now.

It looks something like that. Of course you have to desactivate the plugin when launching xbmc since cec-client and xbmc cannot run at the same time

Image
Reply
#35
Hi
I have a RaspPi with openelec and installed the json cec addon. It is listed under activated addons. I am also able to send different json request to my xbmc successfully. But every time I try an URL like at the bottom I get a json parsing error. Someone an idea?

http://192.168.1.10:8080/jsonrpc?request={“jsonrpc":"2.0","method":"Addons.ExecuteAddon","params":{"addonid":"script.json-cec”,”params":{"command":"activate"}},"id":1}

EDIT: CEC is working fine. I use it with an IR Remote for over 1 Year to Start and stop my TV. But now I want to Control it over Network.
Reply
#36
Siggi85sn when I copy and paste the URL that you have posted I get a parse error as well, but when I remove the quotation marks and retype them it works, I think it is a formatting error with the quotes.
Reply
#37
That was it! 3 Quotation marks were wrong. Thanks for your help und your addon! Smile
Reply
#38
Hey there.
First off this is awesome, I have been looking for away to get around not being able to turn my tv on from IP (why did Samsung decide that turning the nic off was a good idea I will never know).
I am trying to implement this in my Crestron setup at home.
I was wondering how can I send this command with the username and password included if possible.
Code:
http://localhost:8080/jsonrpc?request={"jsonrpc":"2.0","method":"Addons.ExecuteAddon","params":{"addonid":"script.json-cec","params":{"command":"activate"}},"id":1}

If I send the command from a browser it pops up asking for username and password, once I have put them in it works fine.
But when I send the command from the Crestron processor it does not work, I can only assume that I am needing to send username and password as well.
Any help on this would be much appreciated thanks.
Reply
#39
(2014-08-12, 08:38)Holdengts Wrote: Hey there.
First off this is awesome, I have been looking for away to get around not being able to turn my tv on from IP (why did Samsung decide that turning the nic off was a good idea I will never know).
I am trying to implement this in my Crestron setup at home.
I was wondering how can I send this command with the username and password included if possible.
Code:
http://localhost:8080/jsonrpc?request={"jsonrpc":"2.0","method":"Addons.ExecuteAddon","params":{"addonid":"script.json-cec","params":{"command":"activate"}},"id":1}

If I send the command from a browser it pops up asking for username and password, once I have put them in it works fine.
But when I send the command from the Crestron processor it does not work, I can only assume that I am needing to send username and password as well.
Any help on this would be much appreciated thanks.

See http://en.wikipedia.org/wiki/Basic_acces...entication for how to send the username and password in the HTTP header.
Always read the online manual (wiki), FAQ (wiki) and search the forum before posting.
Do not e-mail Team Kodi members directly asking for support. Read/follow the forum rules (wiki).
Please read the pages on troubleshooting (wiki) and bug reporting (wiki) before reporting issues.
Reply
#40
I also would like to be able to use XBMC's libcec interface in an addon, so I'd like to make a suggestion for a simple way to provide such a facility.

The way libcec implements its C (as opposed to C++) API is to maintain a pointer to the C++ interface (ICECAdapter) in the global variable 'cec_parser'. The cec_initialise function creates an ICECAdapter, stores its address in cec_parser, and returns success if it worked. All the other functions just invoke the corresponding methods in that interface, using the saved pointer to it.

If a Python module had access to the address of XBMC's ICECAdapter interface, it could use ctypes to store it in cec_parser and then use libcec functions other than cec_initialise with impunity, without needing a restart to restore XBMC's CEC features. That pointer is hidden in the CEC peripheral context, so some amount of code would have to be written to expose it.

Or, the CEC peripheral initialization code could be modified to store its pointer in cec_parser when it gets it, assuming that the copy of libcec's data that the Python engine gets is the same as what the CEC peripheral gets.
Reply
#41
(2014-09-11, 01:44)CP6er Wrote: I also would like to be able to use XBMC's libcec interface in an addon, so I'd like to make a suggestion for a simple way to provide such a facility.

The way libcec implements its C (as opposed to C++) API is to maintain a pointer to the C++ interface (ICECAdapter) in the global variable 'cec_parser'. The cec_initialise function creates an ICECAdapter, stores its address in cec_parser, and returns success if it worked. All the other functions just invoke the corresponding methods in that interface, using the saved pointer to it.

If a Python module had access to the address of XBMC's ICECAdapter interface, it could use ctypes to store it in cec_parser and then use libcec functions other than cec_initialise with impunity, without needing a restart to restore XBMC's CEC features. That pointer is hidden in the CEC peripheral context, so some amount of code would have to be written to expose it.

Or, the CEC peripheral initialization code could be modified to store its pointer in cec_parser when it gets it, assuming that the copy of libcec's data that the Python engine gets is the same as what the CEC peripheral gets.

That's it! First of all it would be nice to have a way to pass the custom commands to the CEC Adapter. Basic stuff like powering on/off TV and AMP is always the same, so the sys args are simple.
But currently there is no way to pass this custom commands to the ICECAdapter, so a basic API would be great.
Once the system is ready to receive custom commands, a json api could extend this functions for wired/wireless LAN remotes and or upnp "keyword multiroom".

Edit:
This basic API also would be great for embedded systems who's always on. They could be stay powered on and just turn off the cec Peripherals such TV and AMP instead to shutdown the system.
Reply
#42
I would also love a way to send cec commands from python.

I'm planning to write a plugin where i can write my own custom logic when to turn on/off the tv and my amp.

I currently control the amp via tcp, but i can only control the tv via cec, and xbmc is hogging the libcec-device.
Reply
#43
any update on this ? I would love to have the possibility to send custom CEC commands through Kodi as it is my central hub for all my media stuff.
F.e. I would like to turn also my AVR and/or PS3 on with that (which I can do at the moment if I use cec-client directly but then my remote isn't working anymore as I also want to use the normal TV remote for Kodi).

So please add an open api to execute CEC commands via kodi Smile !
Reply
#44
I've been trying the script.json-cec plugin and I get it to work to turn the tv on (using a samsung tv with anynet). But no luck for turning it off (standby) or with toggle. Anyone have any ideas?
Reply
#45
Try changing:

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

to

Code:
<setting id="standby_devices" value="36037" />

in

Code:
~/.kodi/userdata/peripheral_data/rpi_2708_1001.xml

or similar. Then restart Kodi. Worked for me and my old Sony Bravia KDL32W4000, which i could only turn on but not turn off before this change.
Reply

Logout Mark Read Team Forum Stats Members Help
CEC Control via JSON API3