Results 1 to 5 of 5

Thread: anyone fluent in Kodi JSON RPC API?

  1. #1
    Join Date
    Jul 2011
    Location
    VA US
    Posts
    188

    anyone fluent in Kodi JSON RPC API?

    I know this is a bit outside the NextPVR realm, but I'm hoping some of you smart folks who are fluent in Kodi might be able to help me out.

    I'm running Kodi 17.5 and found a neat little addon script which when triggered opens a small overly of a security camera and then closes it after a set period of time. The script works great, but it needs to be triggered from a JSON RPC API command to kodi from an external source. My security camera system has the capability of executing a command on motion detection and which works, but the only way I've found to trigger it is with a http command.

    Code:
     http://192.168.1.20:8081/jsonrpc?request={"jsonrpc":"2.0","method":"Addons.ExecuteAddon","params":{"addonid":"script.securitycam"},"id":"1"}}
    It works, but the drawback is it opens a browser session every time the VSR triggers it. So that led me down the path of looking for a cleaner solution which brought me to curl...

    I've googled for hours and spent the better part of the last 2 evenings trying to get this to work to no avail. Here's the curl command I've come up with but it kicks an error. It's somewhere in the parameter string I think (note the id:null should be a 1). I've tried every conceivable combination of quotes, double quotes, no quotes, single quotes to no avail... for the life of me I can't figure it out.

    Code:
    C:\PROGRA~1\curl\bin\curl.exe -s -H "Content-type: application/json" -d '{"jsonrpc":"2.0","method":"Addons.ExecuteAddon","params":{"addonid":"script.securitycam"},"id":1}}' http://192.168.1.20:8081/jsonrpc
    Code:
    {"error":{"code":-32700,"message":"Parse error."},"id":null,"jsonrpc":"2.0"}
    I'm guessing it's something simple, but I'm to the point of admitting defeat. I'm way outside of my knowledge zone and I'm in desperate need of some help, anyone got any ideas? Just thinking out loud as I typing this, maybe I'm on the wrong track? I'm not married to curl, if ther's another way to reach the same goal I'm all ears!
    NPVR 3.9.2/Win7ProX64/Intel Core i7-4790 Haswell Quad-Core 3.6GHz /HDHRPrime X2/Schedules Direct

  2. #2
    Join Date
    Jun 2015
    Location
    Dutchess County, NY USA
    Posts
    209
    FWIW, but I believe that the final curly-brace is not paired and should be dropped. Also the 1 in "id":1 should be quoted: "id":"1".

    Hope this helps.
    Later...JohnC

    System Status: Humming
    Desktop: Intel DX38BT MB - Intel Q9650 3GHz Quad - AMD HD6670 Video
    Software: Win 10 Pro(Creators) - NextPVR - WinTV8 - Total Media Extreme - VLC
    Video: Verizon FiOS - Hauppauge DCR-3250 - Hauppauge 1512 HDPVR2

  3. #3
    Join Date
    Jul 2011
    Location
    VA US
    Posts
    188
    Just to close the loop on this and maybe help someone else who stumbles onto this post, I finally got it working. It seems curl, at least the windows version, is really picky in the http formatting. Encoding the url is the secret which made everything work.

    Code:
    curl -g 192.168.1.20:8081/jsonrpc?request=%7B%22jsonrpc%22%3A%222.0%22%2C%22method%22%3A%22Addons.ExecuteAddon%22%2C%22params%22%3A%7B%22addonid%22%3A%22script.securitycam%22%7D%2C%22id%22%3A1%7D
    NPVR 3.9.2/Win7ProX64/Intel Core i7-4790 Haswell Quad-Core 3.6GHz /HDHRPrime X2/Schedules Direct

  4. #4
    Join Date
    May 2006
    Location
    Canada
    Posts
    25,775
    Are you sure it is curl? You might need to escape the quotes with a ^ in any command line.

    Martin

  5. #5
    Join Date
    Jul 2011
    Location
    VA US
    Posts
    188
    You may be right Martin, but at least encoding the url worked. At this point I'm just happy to get it working!
    NPVR 3.9.2/Win7ProX64/Intel Core i7-4790 Haswell Quad-Core 3.6GHz /HDHRPrime X2/Schedules Direct

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •