Hello everybody,
beginner here with just some basic knowledge of coding, so please bear with me.
From what I read online there is an API for the LMS that can be interacted with via Json. You can even find the documentation online with several different commands.
What I would like to make are different shortcuts I can use on my phone. For the start for example to activate standby for one of my squeezeboxes. Problem is I donÂ’t know how the syntax has to be to make it work.
For standby the command according to CLI documentation would be <playerid> power <0|1|?|>
If somebody can show me the coding for standby, that would greatly help me. If it is even possible.
Thanks in advance guys
Results 1 to 8 of 8
-
2020-07-09, 11:06 #1
- Join Date
- Jul 2020
- Posts
- 3
Sending commands to LMS via iOS app shortcuts
-
2020-07-09, 20:42 #2
Sending commands to LMS via iOS appshortcuts
> What I would like to make are different shortcuts I can use on my phone.
> For the start for example to activate standby for one of my
> squeezeboxes. Problem is I donÂ’t know how the syntax has to be to make
> it work.
You'll have to send a POST request to http://yourlms:9000/jsonrpc.js (or
whatever the port and/or host it is you're using). I'm not sure you can
do this with shortcuts, I'm not familiar with it. You'd have to ask this
else where.
> For standby the command according to CLI documentation would be
> <playerid> power <0|1|?|>
The body for this request would be:
{"id":0,"params":["00:04:20:...",["power", 1]],"method":"slim.request"}
Where you put the player's MAC address instead of 00:04:20....
--
Michael
-
2020-07-11, 12:12 #3
- Join Date
- Jul 2020
- Posts
- 3
-
2020-07-12, 04:13 #4
- Join Date
- Apr 2015
- Location
- Germany
- Posts
- 782
You should elaborate, what exactly you already tried. :-)
Works for me via my RasPi:
- Shortcuts
- "+"
- Scripts
- ... SSH ...
- credentials for SSHing into my RasPi
- script:
Code:curl -X POST -d '{ "id": 1, "method": "slim.request", "params":["00:04:20:xx:xx:xx", ["power", 0]]}' 192.168.178.37:9000/jsonrpc.js
Be sure that
- you have the right and matching pairs of paranthesis.
- the letters in the MAC-adress are all lower case
-
2020-07-12, 15:11 #5
- Join Date
- Apr 2015
- Location
- Germany
- Posts
- 782
Got it now working straight from iPad to LMS:
- New Shortcut
- Choose "Web"
- From Web Requests choose "Get Contents of URL"
- Follow my picture story
- URL has to start with http://
- Headers are not necessary
-
2020-07-30, 14:42 #6
- Join Date
- Apr 2015
- Location
- Germany
- Posts
- 782
See also there
-
2020-08-09, 07:03 #7
- Join Date
- Jul 2020
- Posts
- 3
Thanks Karlek,
really appreciate your help. I found an even easier way to get the commands working with some help on reddit:
You make a text function with the json command (like Michael suggested). So in this case this would be {"id":0,"params":["00:04:20:...",["power", 1]],"method":"slim.request"}.
Then you also use "get contents of URL" function but instead of selecting "json" as request body you choose "file" and select the text.
As header you write "Content-Type" and "application/json.
Hope this will help others that are trying to make it work.
-
2020-08-09, 09:19 #8
- Join Date
- Apr 2015
- Location
- Germany
- Posts
- 782
Sending commands to LMS via iOS app shortcuts
Thanks for your comment, Shau.
For a static command your way seems indeed easier.
After I tried my first solution above, I got interested and wanted more.
See here for a more dynamic Shortcut:
https://forums.slimdevices.com/showt...-mit-Shortcuts
I posted the link to my german post because of your screenshot.