Home of the Squeezebox™ & Transporter® network music players.
Results 1 to 8 of 8
  1. #1
    Junior Member
    Join Date
    Feb 2009
    Posts
    12

    Control LMS via cmd-line and JSON

    Hi all,

    I am trying in vain to post commands (e.g. play/pause) to LMS via JSON (or status.html for that matter).

    Configuration:
    • LMS 8.1.1 (previously tried with 7.9.3 as well) running on Win 10
    • players: squeezelite (on the same machine as LMS), Squeezebox Classic, Squeezebox Radio, Squeezebox Boom


    What I am doing:
    Code:
    curl -X POST -d '{"id":0,"params":["00:15:xx:xx:xx:xx",["button","play"]],"method":"slim.request"}' http://localhost:9000/jsonrpc.js
    What happens:
    Nothing

    Command line shows:
    Code:
    _
    (blinking cursor)

    server.log:
    Code:
    Slim::Networking::IO::Select::__ANON__ (130) Error: Select task failed calling Slim::Web::HTTP::processHTTP: malformed JSON string, neither array, object, number, string or atom, at character offset 0 (before "'{id:0,params:[00:15...") at /<C:\PROGRA~2\SQUEEZ~1\server\SqueezeSvr.exe>Slim/Web/JSONRPC.pm line 145.
    ; fh=Slim::Web::HTTP::ClientConn=GLOB(0xebb306c)
    For the life of me I can't find the error in the JSON-statement.

    If I use the hack via status.html, curl returns the content of the webpage, but the player status doesn't change.

    Any help greatly appreciated.

  2. #2
    Senior Member
    Join Date
    Apr 2005
    Location
    UK/London
    Posts
    3,940
    Looks like the single quote at the start and end is being sent ... and I presume it should not be.
    Paul Webster
    http://dabdig.blogspot.com
    Author of "Now Playing" plugins covering Radio France (FIP etc), PlanetRadio (Bauer - Kiss, Absolute, Scala, JazzFM etc), KCRW, Supla Finland, ABC Australia, CBC/Radio-Canada and RTE Ireland

  3. #3
    Senior Member
    Join Date
    Jul 2020
    Posts
    261
    Quote Originally Posted by Paul Webster View Post
    Looks like the single quote at the start and end is being sent ... and I presume it should not be.
    A bit odd though. How are you using this?
    In shell script this should work, and would not send the quotes..

  4. #4
    Senior Member
    Join Date
    Jan 2010
    Posts
    751
    If you run this on the Windows command line, try escaping the double quotes. See here.

  5. #5
    Junior Member
    Join Date
    Feb 2009
    Posts
    12
    Quote Originally Posted by reinholdk View Post
    If you run this on the Windows command line, try escaping the double quotes. See here.
    Thanks, escaping the " did the trick, Reinhold--that at least resolves the error in the server.log.

    But: no effect, music won't play or pause.

    cmd-line now shows
    Code:
    curl: (52) Empty reply from server
    So that I now know how to correctly send the code, any other clues to why LMS won't accept the commands?

  6. #6
    Senior Member
    Join Date
    May 2005
    Posts
    115
    Removing "button" from the json allowed the request to work for me (targeted device played as expected).
    https://gist.github.com/samtherussel...d2470b8689d9f2

    Code:
    $ curl -X POST -d '{"id":0,"params":["00:XX:XX:XX:XX:XX",["play"]],"method":"slim.request"}' http://192.168.1.7:9000/jsonrpc.js
    {"params":["00:XX:XX:XX:XX:XX",["play"]],"method":"slim.request","id":0,"result":{}}

  7. #7
    Junior Member
    Join Date
    Feb 2009
    Posts
    12
    Thank you--it works now. But I think this was rather to upgrading LMS to 8.1.1, b/c now with and without the "button" parameter I can control the server from the command-line.

  8. #8
    Senior Member
    Join Date
    May 2005
    Posts
    115
    Glad it works!

    I'm running Logitech Media Server Version: 7.9.3. I was getting the same response you received ("curl: (52) Empty reply from server") when I included "button" in the payload.

Posting Permissions

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