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:
What happens:Code:curl -X POST -d '{"id":0,"params":["00:15:xx:xx:xx:xx",["button","play"]],"method":"slim.request"}' http://localhost:9000/jsonrpc.js
Nothing
Command line shows:
(blinking cursor)Code:_
server.log:
For the life of me I can't find the error in the JSON-statement.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)
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.
Results 1 to 8 of 8
-
2021-01-18, 08:33 #1
- Join Date
- Feb 2009
- Posts
- 12
Control LMS via cmd-line and JSON
-
2021-01-18, 08:41 #2
- Join Date
- Apr 2005
- Location
- UK/London
- Posts
- 3,599
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), KCRW, Supla Finland, ABC Australia, CBC/Radio-Canada and RTE Ireland
-
2021-01-18, 12:35 #3
- Join Date
- Jul 2020
- Posts
- 243
A bit odd though. How are you using this?
In shell script this should work, and would not send the quotes..
-
2021-01-19, 07:26 #4
- Join Date
- Jan 2010
- Posts
- 741
If you run this on the Windows command line, try escaping the double quotes. See here.
-
2021-01-19, 13:12 #5
- Join Date
- Feb 2009
- Posts
- 12
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
-
2021-02-01, 09:07 #6
- 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":{}}
-
2021-02-01, 10:12 #7
- 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.
-
2021-02-01, 12:36 #8
- 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.