Author Topic: Kodi V18 Leia breaks all my http json commands sent from Vera  (Read 216 times)

Offline cw-kid

  • Beta Testers
  • Hero Member
  • *****
  • Posts: 1612
  • Karma: +18/-2
Kodi V18 Leia breaks all my http json commands sent from Vera
« on: February 13, 2019, 12:21:53 pm »
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.

Code: [Select]
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:

Code: [Select]
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?
« Last Edit: February 13, 2019, 12:26:59 pm by cw-kid »

Offline akbooer

  • Beta Testers
  • Master Member
  • *****
  • Posts: 6343
  • Karma: +288/-70
  • "Less is more"
Re: Kodi V18 Leia breaks all my http json commands sent from Vera
« Reply #1 on: February 13, 2019, 12:27:04 pm »
There's a new luup function luup.inet.request() 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 dkjson module to encode Lua tables into JSON.
3x Vera Lite-UI5/Edge-UI7, 25x Fibaro, 23x TKB, 9x MiniMote, 2x NorthQ Power, 2x Netatmo, 1x Foscam FI9831P, 9x Philips Hue,
Razberry, MySensors Arduino, HomeWave, AltUI, AltHue, DataYours, Grafana, openLuup, ZWay, ZeroBrane Studio.

Offline cw-kid

  • Beta Testers
  • Hero Member
  • *****
  • Posts: 1612
  • Karma: +18/-2
Re: Kodi V18 Leia breaks all my http json commands sent from Vera
« Reply #2 on: February 13, 2019, 12:37:00 pm »
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:

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

Video: http://<User>:<Password>@<hostname>:<port>/jsonrpc?request={"jsonrpc":"2.0","method":"VideoLibrary.Scan"}


Offline cw-kid

  • Beta Testers
  • Hero Member
  • *****
  • Posts: 1612
  • Karma: +18/-2
Re: Kodi V18 Leia breaks all my http json commands sent from Vera
« Reply #3 on: February 13, 2019, 12:54:22 pm »
On my Windows PC using CURL this command works and starts the video library update scan on the Kodi V18 Leia PC.

Code: [Select]
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 ?
« Last Edit: February 13, 2019, 12:56:03 pm by cw-kid »

Offline akbooer

  • Beta Testers
  • Master Member
  • *****
  • Posts: 6343
  • Karma: +288/-70
  • "Less is more"
Re: Kodi V18 Leia breaks all my http json commands sent from Vera
« Reply #4 on: February 13, 2019, 01:05:57 pm »
You can issue any shell command from a scene Lua script with a one-liner, simply wrapping the command string with os.execute().

Code: [Select]
os.execute "any shell command you like, eg. curl"
3x Vera Lite-UI5/Edge-UI7, 25x Fibaro, 23x TKB, 9x MiniMote, 2x NorthQ Power, 2x Netatmo, 1x Foscam FI9831P, 9x Philips Hue,
Razberry, MySensors Arduino, HomeWave, AltUI, AltHue, DataYours, Grafana, openLuup, ZWay, ZeroBrane Studio.

Offline reneboer

  • Beta Testers
  • Hero Member
  • *****
  • Posts: 1549
  • Karma: +109/-31
Re: Kodi V18 Leia breaks all my http json commands sent from Vera
« Reply #5 on: February 14, 2019, 04:42:48 am »
There's a new luup function luup.inet.request() 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 dkjson module to encode Lua tables into JSON.
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
2xVeraLite, VeraEdge, openLuup, ALTUI, 20 switches, 10 dimmers, 20 sensors, 10 scene controllers, 1 Harmony Hub, many plug-ins. Not enough time.

Offline akbooer

  • Beta Testers
  • Master Member
  • *****
  • Posts: 6343
  • Karma: +288/-70
  • "Less is more"
Re: Kodi V18 Leia breaks all my http json commands sent from Vera
« Reply #6 on: February 14, 2019, 05:05:41 am »
Good advice.  I haven't implemented in openLuup, yet.  Obviously best to use the LuaSocket library.
3x Vera Lite-UI5/Edge-UI7, 25x Fibaro, 23x TKB, 9x MiniMote, 2x NorthQ Power, 2x Netatmo, 1x Foscam FI9831P, 9x Philips Hue,
Razberry, MySensors Arduino, HomeWave, AltUI, AltHue, DataYours, Grafana, openLuup, ZWay, ZeroBrane Studio.