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.

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>

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.

EDIT: And Kodi Matrix v19.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.101: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.101:8080/jsonrpc -d \'{"jsonrpc": "2.0", "method": "Player.PlayPause", "params": { "playerid": 0 }, "id": 1}\'')

Navigation

UP

os.execute('curl -X POST -H "content-type:application/json" http://username:password@192.168.1.101:8080/jsonrpc -d \'{"jsonrpc":"2.0","id":1,"method":"Input.Up"}\'')

DOWN

os.execute('curl -X POST -H "content-type:application/json" http://username:password@192.168.1.101:8080/jsonrpc -d \'{"jsonrpc":"2.0","id":1,"method":"Input.Down"}\'')

LEFT

os.execute('curl -X POST -H "content-type:application/json" http://username:password@192.168.1.101:8080/jsonrpc -d \'{"jsonrpc":"2.0","id":1,"method":"Input.Left"}\'')

RIGHT

os.execute('curl -X POST -H "content-type:application/json" http://username:password@192.168.1.101:8080/jsonrpc -d \'{"jsonrpc":"2.0","id":1,"method":"Input.Right"}\'')

INPUT SELECT

os.execute('curl -X POST -H "content-type:application/json" http://username:password@192.168.1.101:8080/jsonrpc -d \'{"jsonrpc":"2.0","id":1,"method":"Input.Select"}\'')

INPUT BACK

os.execute('curl -X POST -H "content-type:application/json" http://username:password@192.168.1.101:8080/jsonrpc -d \'{"jsonrpc":"2.0","id":1,"method":"Input.Back"}\'')

INPUT INFO

os.execute('curl -X POST -H "content-type:application/json" http://username:password@192.168.1.101:8080/jsonrpc -d \'{"jsonrpc":"2.0","id":1,"method":"Input.Info"}\'')

INPUT HOME

os.execute('curl -X POST -H "content-type:application/json" http://username:password@192.168.1.101:8080/jsonrpc -d \'{"jsonrpc":"2.0","id":1,"method":"Input.Home"}\'')

INPUT CONTEXT MENU

os.execute('curl -X POST -H "content-type:application/json" http://username:password@192.168.1.101:8080/jsonrpc -d \'{"jsonrpc":"2.0","id":1,"method":"Input.ContextMenu"}\'')

INPUT SHOW OSD

os.execute('curl -X POST -H "content-type:application/json" http://username:password@192.168.1.101:8080/jsonrpc -d \'{"jsonrpc":"2.0","id":1,"method":"Input.ShowOSD"}\'')

INPUT SHOW PLAYER PROCESS INFO

os.execute('curl -X POST -H "content-type:application/json" http://username:password@192.168.1.101:8080/jsonrpc -d \'{"jsonrpc":"2.0","id":1,"method":"Input.ShowPlayerProcessInfo"}\'')

INPUT SHOW CODEC

os.execute('curl -X POST -H "content-type:application/json" http://username:password@192.168.1.101:8080/jsonrpc -d \'{"jsonrpc":"2.0","id":1,"method":"Input.ShowCodec"}\'')

Launch Kodi Add-on
(Change the addonid to your addon)

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

Disable Kodi Add-on
(Change the addonid to your addon)

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

Enable Kodi Add-on
(Change the addonid to your addon)

os.execute('curl -X POST -H "content-type:application/json" http://username:password@192.168.1.:1018080/jsonrpc -d \'{"jsonrpc":"2.0","method":"Addons.SetAddonEnabled","params":{"addonid":"script.kodi.hue.ambilight","enabled":true},"id":1}\'')

Send a popup Notification to Kodi

os.execute('curl -X POST -H "content-type:application/json" http://username:password@192.168.1.101:8080/jsonrpc -d \'{"jsonrpc": "2.0", "method": "GUI.ShowNotification", "params": { "title": "HERE ADD THE TITLE", "message": "ADD THE MESSAGE HERE" }, "id": 1}\'')

Shutdown Kodi System

os.execute('curl -X POST -H "content-type:application/json" http://username:password@192.168.1.101:8080/jsonrpc -d \'{"jsonrpc":"2.0","id":1,"method":"System.Shutdown"}\'')
1 Like