Where can I find the CLI documentation?

Collapse
This is a sticky topic.
X
X
 
  • Time
  • Show
Clear All
new posts
  • mherger
    Babelfish's Best Boy
    • Apr 2005
    • 24633

    Where can I find the CLI documentation?

    > Am I correct in concluding that there is not much of an error handler
    > for the jsonrpc interface? If, for example, I request the *status* of a


    I think that's correct, yes.
    Michael

    "It doesn't work - what shall I do?" - "Please check your server.log and/or scanner.log file!"
    (LMS: Settings/Information)
  • mherger
    Babelfish's Best Boy
    • Apr 2005
    • 24633

    #2
    Where can I find the CLI documentation?

    On your LMS: http://localhost:9000/html/docs/cli-api.html (replace "localhost" with your server's address).

    Don't have LMS running? What are you doing here then, anyway? The documentation is on github, of course. Read it online. It's not nicely laid out, but hey, it's available!
    Michael

    "It doesn't work - what shall I do?" - "Please check your server.log and/or scanner.log file!"
    (LMS: Settings/Information)

    Comment

    • d6jg
      Senior Member
      • Feb 2011
      • 8946

      #3
      Originally posted by mherger
      On your LMS: http://localhost:9000/html/docs/cli-api.html (replace "localhost" with your server's address).

      Don't have LMS running? What are you doing here then, anyway? The documentation is on github, of course. Read it online. It's not nicely laid out, but hey, it's available!
      Is there similar documentation for the JSON interface somewhere?
      Jim



      pCP9.0 / LMS 9.x storage QNAP TS419p (NFS)
      Living Room Joggler & Pi4/Khadas -> Onkyo TXNR686 -> Celestion F20s
      Office Joggler & Pi3 -> Onkyo CRN775 -> Wharfedale Modus Cubes
      Kitchen WiiM Pro -> Topping MX3 - B&W In Ceiling speakers
      Bedroom (Bedside) Pi Zero+DAC ->ToppingTP21 ->AKG Headphones
      Bedroom (TV) & Bathroom SB Touch ->Denon AVR ->Mordaunt Short M10s + Kef ceiling speakers
      Guest Room Joggler > Denon RCFN8 -> Celestions F10s

      Comment

      • karlek
        Senior Member
        • Apr 2015
        • 857

        #4
        It's basically the same.
        You'll have to put the command JSON formatted to LMS-IP:9000/jsonrpc.js

        To set the volume to 25 (CLI: "04:20:00:12:23:45 mixer volume 25<LF>" )you could POST it like this:

        Code:
        curl -X POST -d '{ "method": "slim.request", "params":["00:04:20:xx:xx:xx", ["mixer", "volume", "25"]]}' 192.168.178.37:9000/jsonrpc.js
        The JSON part ist embraced by ' followed by {. The latter for handling it as a dictionary.
        The command itself is a list consisting of the player ID (MAC) and another list with the parameters p0 to p5.

        see also here for a good overview:

        Comment

        • d6jg
          Senior Member
          • Feb 2011
          • 8946

          #5
          Originally posted by karlek
          It's basically the same.
          You'll have to put the command JSON formatted to LMS-IP:9000/jsonrpc.js

          To set the volume to 25 (CLI: "04:20:00:12:23:45 mixer volume 25<LF>" )you could POST it like this:

          Code:
          curl -X POST -d '{ "method": "slim.request", "params":["00:04:20:xx:xx:xx", ["mixer", "volume", "25"]]}' 192.168.178.37:9000/jsonrpc.js
          The JSON part ist embraced by ' followed by {. The latter for handling it as a dictionary.
          The command itself is a list consisting of the player ID (MAC) and another list with the parameters p0 to p5.

          see also here for a good overview:
          https://gist.github.com/samtherussel...d2470b8689d9f2
          Thanks
          Jim



          pCP9.0 / LMS 9.x storage QNAP TS419p (NFS)
          Living Room Joggler & Pi4/Khadas -> Onkyo TXNR686 -> Celestion F20s
          Office Joggler & Pi3 -> Onkyo CRN775 -> Wharfedale Modus Cubes
          Kitchen WiiM Pro -> Topping MX3 - B&W In Ceiling speakers
          Bedroom (Bedside) Pi Zero+DAC ->ToppingTP21 ->AKG Headphones
          Bedroom (TV) & Bathroom SB Touch ->Denon AVR ->Mordaunt Short M10s + Kef ceiling speakers
          Guest Room Joggler > Denon RCFN8 -> Celestions F10s

          Comment

          • eradicatore
            Member
            • Dec 2005
            • 39

            #6
            a general command to jsonrpc.js

            Thanks all for sharing! This really helped me get started. I was having some trouble figuring out how to send some other commands though until I saw somewhere that if you want to send a "general" command for example you still need to give a mac address for some reason? So I got this to work for example. Not sure also if/why the "id":0 is needed but I put that in there too

            Code:
            {
                "method": "slim.request",
                "params": [
                    "FF:FF:FF:FF",
                    [
                        "player",
                        "count",
                        "?"
                    ]
                ],
                "id": 0
            }
            Question, does anyone know how to interact with apps? Such as spotify or pandora? I got the list to work:

            Code:
            {
                "method": "slim.request",
                "params": [
                    "FF:FF:FF:FF",
                    [
                        "apps",
                        "0",
                        "15"
                    ]
                ],
                "id": 0
            }
            And I get something like this:

            Code:
            {
                "method": "slim.request",
                "id": 0,
                "result": {
                    "count": 13,
                    "appss_loop": [
                        {
                            "type": "xmlbrowser",
                            "icon": "plugins/Spotty/html/images/93aac68fb06348598c1e67734dfaceee.png",
                            "weight": 1,
                            "cmd": "spotty",
                            "name": "Spotty"
                        },
                        {
                            "icon": "plugins/Pandora/html/images/icon.png",
                            "type": "xmlbrowser",
                            "weight": 10,
                            "cmd": "pandora",
                            "name": "Pandora"
                        },
            ...

            Comment

            • eradicatore
              Member
              • Dec 2005
              • 39

              #7
              I think I found it here:



              I just got this to work (have to talk to one specific player...)

              Code:
              {
                  "method": "slim.request",
                  "params": [
                      "aa:bb:eb:zz:yy:xx",
                      [
                      	"myapps",
                      	"items",
                      	"0",
                      	"9"
                      ]
                  ],
                  "id": 0
              }
              Then, you get an item id in the response and use it like this to go down that path:

              Code:
              {
                  "method": "slim.request",
                  "params": [
                      "aa:bb:eb:zz:yy:xx",
                      [
                      	"myapps",
                      	"items",
                      	"0",
                      	"9",
                      	"item_id:xyz859.0"
                      ]
                  ],
                  "id": 0
              }

              Comment

              • philchillbill
                Senior Member
                • Jan 2019
                • 1085

                #8
                Am I correct in concluding that there is not much of an error handler for the jsonrpc interface? If, for example, I request the status of a player but provide an incorrect playerid, instead of a nice JSON response error string along the lines of 'unknown playerid' or 'player offline', all I get is a http disconnect. If accessing LMS via ngrok then it's a 502 Proxy Error I see with "The proxy server received an invalid response from an upstream server". Any way to get 'nicer' error responses from jsonrpc.js ?

                Comment

                • daksol
                  Member
                  • Dec 2011
                  • 52

                  #9
                  CLI documentation is now available in the lyrion.org repository.

                  Migration:
                  • This was migrated from the legacy /HTML/DOCS/cli-api.html which was bundled with the LMS Distro.
                  • Original very long HTML page now divided up into about 9 files.
                  • Legacy Sections "plugins", "deprecated" were not migrated.

                  New Location
                  Further Work

                  Some further work should be done on this content over next month or so. Should include:-
                  • method by which you can navigate from the documentation for a given Command over to the relevant source code
                    • will be based on info already available
                      • locate pm source xxx/Slim/Control/Request.pm
                      • search for for sub init{} which has a line for 90%+ of the CLI commands
                      • info in addDispatch() function calls give info for the command on parameters, source code filename, related Perl function name
                  • more examples in JSON format for the complex queries
                  • some sample Python code for using the CLI via the jsonrpc.js functionality
                  • pointers to the relevant namespaces which are used for certain input parameter

                  Feedback
                  • Please provide feedback if you see opportunities for improvement of existing content, plus where it could be usefully extended,

                  Comment

                  • Anwen
                    Junior Member
                    • Jan 2023
                    • 13

                    #10
                    daksol
                    Feedback: I just very briefly started looking at the CLI documentation and noticed a typo under CLI Introduction in the Supported Commands section: “Compound” is incorrectly shown as “Coumpound”. Thanks for all your work on the new documentation!
                    LMS in Docker on Ubuntu Server; PiCorePlayer, Squeezelite-X, SqueezePlay; AirPlay Bridge

                    Comment

                    • mherger
                      Babelfish's Best Boy
                      • Apr 2005
                      • 24633

                      #11
                      Originally posted by Anwen
                      daksol
                      Feedback: I just very briefly started looking at the CLI documentation and noticed a typo under CLI Introduction in the Supported Commands section: “Compound” is incorrectly shown as “Coumpound”. Thanks for all your work on the new documentation!
                      Thanks, fixed.
                      Michael

                      "It doesn't work - what shall I do?" - "Please check your server.log and/or scanner.log file!"
                      (LMS: Settings/Information)

                      Comment

                      • daksol
                        Member
                        • Dec 2011
                        • 52

                        #12
                        Originally posted by Anwen
                        daksol
                        Feedback: I just very briefly started looking at the CLI documentation and noticed a typo under CLI Introduction in the Supported Commands section: “Compound” is incorrectly shown as “Coumpound”. Thanks for all your work on the new documentation!
                        Thanks - if that is as bad as it gets, we are doing great!

                        Comment

                        Working...