v18 Leia Play/pause toggle example?
#1
Would be grateful for a hint on getting my remote woking with Leia. By way of making one example:
This worked in my iRule remote before with Krypton to execute play/toggle. Sorry about the quoting code bits. Rusty on this...

https://paste.kodi.tv/damoruwusa

What needs changing to make it work with Leia please, to get me on the right path. Many thanks.
Reply
#2
You are performing a GET request with the JSON as a parameter. This is still fine for retrieving information from Kodi. But to perform actions or make changes, you need to change the request type to POST. The url will be http://<yourKodiIP>/jsonrpc and the request body would be everything after "request=" in the URL you posted. I don't use iRule, so I don't know how exactly to do this in iRule.
Reply
#3
Thanks!

Well, this is what the play/pause command looks like in and up to krypton unencoded:

jsonrpc?request={"jsonrpc":"2.0","method":"Player.PlayPause","params":{"playerid":1},"id":1}

How exactly should I tweak the start for it to excute play/pause in Leia if anyone has a sec?

GET/POST/PUT is set in the gateway in iRule so I should probably not put that in the string for my purposes.
Grateful for any hints. Many thanks..
Reply
#4
So the gateway would need to be POST. The URL/endpoint or whatever iRule calls it would be http://<yourKodiIP>/jsonrpc. Then the request body of each POST would be the JSON. If you need more help, please post screenshots. I don't have an iRule and can't configure the app to test.
Reply
#5
Thanks Mr. Tarantula,

Help  much appreciated!
How about one working url for play/pause toggle in Leia that I can run in a browser to test? That would be a good start.
iRule basically just runs as a http gateway on a  specified port, so anything that has historically worked in a browser can then
be encoded for use in Kodi up to Krypton. Many thanks.
Reply
#6
You can't just type a POST request in the browser. Well, you can, but not the address bar. You can use the console to write JavaScript that sends a POST request:

javascript:

var xhttp = new XMLHttpRequest();

xhttp.open("POST", "http://<yourKodiIP>/jsonrpc", true);
xhttp.setRequestHeader("Content-type", "application/json");
xhttp.send("{\"jsonrpc\":\"2.0\",\"method\":\"Player.PlayPause\",\"params\":{\"playerid\":1},\"id\":1}");

From what I understand, this is probably not possible in iRule though.
Reply
#7
Thanks again,

So no simple urlsConfused then. No way to do it in one string, telnet, terminal style either?
You've been very helpful regardless and I appreciate it!
Reply
#8
Any command can be done in one string from the terminal. See this post for an example of using curl.
Reply
#9
Ok, I'll trying work with that. Rusty at this, as it worked great for 5-6 years when I did it at the time.
However, iRule wants you to put the IP adress, port, POST/GET/PUT and credentials in a separate gateway setting.
Could you kindly wrap up by checking this syntax and tell me how to, if possible leave out the IP adress and finish that string without it?
Then I'll regardless leave you alone and work on my own for a bit. Promise to report back if I get it working though!
Sorry about the non-quoting. can not find the tools for that either. Yup rusty at this.. Many thanks again.

curl -s --data-binary '{"jsonrpc":"2.0","method":"Player.PlayPause","params":{"playerid":1},"id":1},"id":1}' -H 'content-type: application/json;' http://xxx.xxx.xxx.x:8080/jsonrpc
Reply
#10
Looks like you need to remove  ,"id":1} from the end of the JSON (but leave the last single quote after it). Otherwise it looks fine.

But, you can't call curl without an IP address. How else would curl know where to send the request? Like I said, screenshots would really help.
Reply
#11
Not sure what to do screenshots of, but here is the gateway config of the client.

Image
Network gateways look the same, except they have TCP/UDP as a choice rather than get/post/put.
and then there is a web builder that basically will send the strings you put in for a device to that address, when the device is linked to the gateway.
I have a bunch of devices that work fine on either network or http gateways. Some modified from the shared pool. Some handbuilt.
I have already posted a typical Kodi JSON string encoded and decoded. Those strings were testable in a  regular browser.

Here is a telnet based string for another device that is play/pause toggle that can be run on SSH:
01/1/PLAY:\x0D
an here are another few example working strings that work and do the same or similar things for other devices:
\x02\x0A\x53\x4F\x4E\x59\X00\X17\X2E\x02\x00\x00
id Irule\x0D upmixer 1\x0D

Ah well. Maybe you get the picture?
Not sure if this is very helpful, but I wanted to do what you asked for. Many thanks again!
Reply
#12
Does choosing POST give you any other options when configuring either the gateway or the commands?

Long shot, but is there an option for websockets?
Reply
#13
No other options in the gateway than what you see in the pic. The rest must happen in the strings.
No web sockets.

I should probably mention that iRule is not the future, as they are shutting down their servers in a few years.
So unless there is a reasonably swift and smart way to convert the existing JSON library it is probably time to give up Sad
But Kodi is obviously  vital... Wink I will probably have to use the remote instead when that is upgraded..

Thanks again you have been very helpful!
Reply
#14
Any luck with this?  I have been unable to figure out how to make iRule work with Leia (Successful use with Krypton).  Hate it when new versions of software aren't backwards compatible with older control protocols.
Reply
#15
(2019-03-09, 05:12)phase_geek Wrote: Any luck with this?  I have been unable to figure out how to make iRule work with Leia (Successful use with Krypton).  Hate it when new versions of software aren't backwards compatible with older control protocols.
 Hi phase_geek,

Nope sorry, not so far. Staying on Krypton for now.  Not a crucial update at this time for me. Will do it later I guess.
Reply

Logout Mark Read Team Forum Stats Members Help
Leia Play/pause toggle example?0