Kodi V18 Leia breaks all my http json commands sent from Vera

Hi

I just updated my Kodi PC to V18 Leia only to discover all my http URL json commands no longer work.

Seems Kodi does now not accept simple one line http Get commands. You have to use Post instead.

This was the command that previously worked to update the Kodi video library.

http://192.168.1.5:8080/jsonrpc?request={ "jsonrpc": "2.0", "method": "VideoLibrary.Scan", "id": "mybash"

And in the LUA code area of a Vera scene I use this code:

luup.inet.wget("http://192.168.1.5:8080/jsonrpc?request={ "jsonrpc": "2.0", "method": "VideoLibrary.Scan", "id": "mybash"}")

I saw this Kodi wiki page: https://kodi.wiki/view/HOW-TO:Remotely_update_library

But how do you now send (Post) json commands from Vera to Kodi now?

1 Like

There’s a new luup function [tt]luup.inet.request()[/tt] documented here…

http://wiki.mios.com/index.php/Luup_Lua_extensions#function:_request

This will allow you to do POST requests and you can use the [tt]dkjson[/tt] module to encode Lua tables into JSON.

Hi Akbooer

Thank you for your reply.

I am not a coder and just about managed previously to send that video library update command from Vera to Kodi.

Seems they have now made it much harder to send commands to Kodi.

I was hoping to find some working examples of how to create a Vera scene or PLEG action with code to send a command to Kodi.

I did search the forum via Google for Kodi v18 leia but didn’t find anything.

The Kodi wiki pages says this is the new format of the command:

  1. HTTP (does not work in v18 Leia)
    To add new content to the library (Update):

Video: http://:@:/jsonrpc?request={“jsonrpc”:“2.0”,“method”:“VideoLibrary.Scan”}

On my Windows PC using CURL this command works and starts the video library update scan on the Kodi V18 Leia PC.

[code]C:\curl>curl -i -X POST -d “{“jsonrpc”: “2.0”, “method”: “VideoLibrary.Scan”, “id”: “mybash”}” -H “content-type:application/json” http://user:password@192.168.1.5:8080/jsonrpc
HTTP/1.1 200 OK
Connection: Keep-Alive
Content-Length: 45
Content-Type: application/json
Cache-Control: private, max-age=0, no-cache
Accept-Ranges: none
Date: Wed, 13 Feb 2019 17:52:30 GMT

{“id”:“mybash”,“jsonrpc”:“2.0”,“result”:“OK”}
C:\curl>[/code]

Maybe it would be easier to send a curl command from Vera to Kodi ?

You can issue any shell command from a scene Lua script with a one-liner, simply wrapping the command string with [tt]os.execute()[/tt].

os.execute "any shell command you like, eg. curl"

[quote=“akbooer, post:2, topic:200589”]There’s a new luup function [tt]luup.inet.request()[/tt] documented here…

http://wiki.mios.com/index.php/Luup_Lua_extensions#function:_request

This will allow you to do POST requests and you can use the [tt]dkjson[/tt] module to encode Lua tables into JSON.[/quote]
Hi,

I had a look at the new luup.request and it is very buggy and takes down luup all the time. On a Lite it does not work at all, on an Edge a little. I reported this to Vera and they admitted the implementation is still incomplete. I would stay away from it for now.

Cheers Rene

Good advice. I haven’t implemented in openLuup, yet. Obviously best to use the LuaSocket library.

So how do I run that Curl command from a Vera scene to update the video library in Kodi ?

I’ve tried this but it doesn’t work: In the Vera test code area, it says Code was sent successfully but nothing happens in Kodi.

os.execute(‘curl -i -X POST -d “{“jsonrpc”: “2.0”, “method”: “VideoLibrary.Scan”, “id”: “mybash”}” -H “content-type:application/json” “http://user:password@192.168.1.5:8080/jsonrpc”’)

And no code insert feature on this new forum ?

Thanks

What happens if you run that curl from a command line?

C

os.execute(‘curl -i -X POST -d “{“jsonrpc”: “2.0”, “method”: “VideoLibrary.Scan”, “id”: “mybash”}” -H “content-type:application/json” “http://user:password@192.168.1.5:8080/jsonrpc”’)

Works for me, but I have to say that the font size is too large.

The Curl command works from my Windows PC and starts the library scan on Kodi OK.

Just not from the Vera scene.

Vera uses WRT so the syntax is subtly different. If you get it working from the CLI on Vera then you’ll be in a better position.
Make sense?

C

Yeah I know how to get in to Terminal on Vera using Putty, I’ll try the command from there like you say.

Cheers

The example commands below work from Vera for me.

All the other Kodi Leia v18.X API commands can be seen here.

Update Video Library

os.execute(‘curl -X POST -H “content-type:application/json” http://username:password@192.168.1.5:8080/jsonrpc -d ‘{“jsonrpc”:“2.0”,“id”:1,“method”:“VideoLibrary.Scan”}’’)

Pause / Play

os.execute(‘curl -X POST -H “content-type:application/json” http://username:password@192.168.1.5:8080/jsonrpc -d ‘{“jsonrpc”: “2.0”, “method”: “Player.PlayPause”, “params”: { “playerid”: 0 }, “id”: 1}’’)

Navigation

os.execute(‘curl -X POST -H “content-type:application/json” http://username:password@192.168.1.5:8080/jsonrpc -d ‘{“jsonrpc”:“2.0”,“id”:1,“method”:“Input.Up”}’’)

os.execute(‘curl -X POST -H “content-type:application/json” http://username:password@192.168.1.5:8080/jsonrpc -d ‘{“jsonrpc”:“2.0”,“id”:1,“method”:“Input.Down”}’’)

os.execute(‘curl -X POST -H “content-type:application/json” http://username:password@192.168.1.5:8080/jsonrpc -d ‘{“jsonrpc”:“2.0”,“id”:1,“method”:“Input.Left”}’’)

os.execute(‘curl -X POST -H “content-type:application/json” http://username:password@192.168.1.5:8080/jsonrpc -d ‘{“jsonrpc”:“2.0”,“id”:1,“method”:“Input.Right”}’’)

os.execute(‘curl -X POST -H “content-type:application/json” http://username:password@192.168.1.5:8080/jsonrpc -d ‘{“jsonrpc”:“2.0”,“id”:1,“method”:“Input.Select”}’’)

os.execute(‘curl -X POST -H “content-type:application/json” http://username:password@192.168.1.5:8080/jsonrpc -d ‘{“jsonrpc”:“2.0”,“id”:1,“method”:“Input.Back”}’’)

os.execute(‘curl -X POST -H “content-type:application/json” http://username:password@192.168.1.5:8080/jsonrpc -d ‘{“jsonrpc”:“2.0”,“id”:1,“method”:“Input.Info”}’’)

os.execute(‘curl -X POST -H “content-type:application/json” http://username:password@192.168.1.5:8080/jsonrpc -d ‘{“jsonrpc”:“2.0”,“id”:1,“method”:“Input.Home”}’’)

os.execute(‘curl -X POST -H “content-type:application/json” http://username:password@192.168.1.5:8080/jsonrpc -d ‘{“jsonrpc”:“2.0”,“id”:1,“method”:“Input.ContextMenu”}’’)

os.execute(‘curl -X POST -H “content-type:application/json” http://username:password@192.168.1.5:8080/jsonrpc -d ‘{“jsonrpc”:“2.0”,“id”:1,“method”:“Input.ShowOSD”}’’)

os.execute(‘curl -X POST -H “content-type:application/json” http://username:password@192.168.1.5:8080/jsonrpc -d ‘{“jsonrpc”:“2.0”,“id”:1,“method”:“Input.ShowPlayerProcessInfo”}’’)

os.execute(‘curl -X POST -H “content-type:application/json” http://username:password@192.168.1.5:8080/jsonrpc -d ‘{“jsonrpc”:“2.0”,“id”:1,“method”:“Input.ShowCodec”}’’)

Launch Kodi Add-on

os.execute(‘curl -X POST -H “content-type:application/json” http://username:password@192.168.1.5:8080/jsonrpc -d ‘{“jsonrpc”:“2.0”,“id”:1,“method”:“Addons.ExecuteAddon”,“params”:{“addonid”:“script.frontgardencam”},“id”:“1”}’’)

Disable Kodi Add-on

os.execute(‘curl -X POST -H “content-type:application/json” http://username:password@192.168.1.5:8080/jsonrpc -d ‘{“jsonrpc”:“2.0”,“method”:“Addons.SetAddonEnabled”,“params”:{“addonid”:“script.kodi.hue.ambilight”,“enabled”:false},“id”:1}’’)

Enable Kodi Add-on

os.execute(‘curl -X POST -H “content-type:application/json” http://username:password@192.168.1.5:8080/jsonrpc -d ‘{“jsonrpc”:“2.0”,“method”:“Addons.SetAddonEnabled”,“params”:{“addonid”:“script.kodi.hue.ambilight”,“enabled”:true},“id”:1}’’)

1 Like

Best Home Automation shopping experience. Shop at getvera!

© 2020 Vera Control Ltd., All Rights Reserved. Terms of Use | Privacy Policy | Forum Rules