|
Page 1 of 3
|
[ 36 posts ] |
Go to page: 1, 2, 3 Next |
| Author |
Message |
|
dtich
Joined: Sep 24, 2005 Posts: 502
|
 squeezebox control
has anyone any experience with scripting control of a slim devices squeezebox server, slim server?
if you don't know what this is, it's a fantastic music server interface:
www.slimdevices.com
the only things i'm interested in really are telling the squeezebox to stop playback, turn off... things like that. i emailed support at slim devices and they didn't have any info... oddly. so, if anyone out there does, like an applescript library for slim server or similar... would be great.
tia.
|
| Thu Feb 16, 2006 9:12 pm |
|
 |
|
macpro
Joined: Dec 29, 2005 Posts: 585 Location: Third byte on the right
|
You can control the SlimServer software via URLs.
So all you have to do is write some AppleScripts that fire URLs to the SlimServer and it should work.
Take a look at the AppleScript for changing the iChat status.
Although it no longer works with the current iChat, it shows how to use the SqueezeBox via AppleScript.
_________________ "I tawt I taw a puddy tat!" Tweety
|
| Fri Feb 17, 2006 3:24 am |
|
 |
|
ajturner
Joined: Jul 10, 2005 Posts: 160 Location: Northville, Michigan
|
I wrote a script for play, pause, next track, and displaying text on the Squeezebox. For more information, and to add any notes, modifications, etc, go to the Squeezebox Script on AutomationWiki. I'll also post the script below. Let me know if it's what you had in mind.
There are probably some nicities that could be added. Also, having a client running on the Squeezebox to send Indigo commands would be tremendous. Alas, Perl is one of the programming languages I don't know - and don't really want to have to learn.  If there is another Perl programmer out there, it would probably be a great project to write a Squeezebox plugin to control devices/action groups from a Squeezebox.
Think being able to turn your house into "Movie mode" or "Party Mode" the Squeezebox in your living room.
Andy
- Code: Select all
--SlimServer control attachment -- -- This script provides functions for easily controlling -- a SlimDevices Squeezebox from IndigoActions -- -- Author: Andrew Turner (software@highearthorbit.com) -- -- Examples: -- SlimServerCommand("play") -- SlimServerDisplay("Security Alarm Set") -- -- Available commands: play, pause, stop, sleep
property defaultHost : "192.168.0.3" property defaultPort : "9000" (* How long to display text *) property defaultSeconds : "10"
SlimServerDisplay("Andy Office lamp turned on")
using terms from application "Indigo" on SlimServerCommand(theCommand) SendToSlimServer(theCommand, 0, 0, 0) end SlimServerCommand on SlimServerDisplay(displayString) set lineOne to searchReplaceText(" ", "%20", "Indigo") set lineTwo to searchReplaceText(" ", "%20", displayString) SendToSlimServer("display", lineOne, lineTwo, defaultSeconds) end SlimServerDisplay on SlimServerVolume(volume) SendToSlimServer("mixer", "volume", volume, 0) end SlimServerVolume on SlimServerPlaySong(songName) SendToSlimServer("playlist", "play", songName, 0) end SlimServerPlaySong end using terms from
on SendToSlimServer(p0, p1, p2, p3) set h to "http://" & defaultHost & ":" & defaultPort & "/status.txt" set d to h & "?p0=" & p0 if p1 is not equal to 0 then set d to d & "&p1=" & p1 end if if p2 is not equal to 0 then set d to d & "&p2=" & p2 end if if p3 is not equal to 0 then set d to d & "&p3=" & p3 end if set responseText to do shell script "curl --get -d --url \"" & d & "\" " --alert("Server says: " & responseText) end SendToSlimServer
(* searchReplaceText(searchTerm, replaceTerm, theText) Replaces a string found in a text by another string. This handle supports lists of search/replace terms.
Parameters: searchTerm: the text to search for replaceTerm: the text to use as replacement theText: the text to search/replace
Examples: searchReplaceText("foo", "bar", "You are a foo") --> "You are a bar" searchReplaceText({"foo", " a "}, {"bar", " one "}, "You are a foo") --> "You are one bar" *)
to searchReplaceText(searchTerm, replaceTerm, theText) set searchTerm to searchTerm as list set replaceTerm to replaceTerm as list set theText to theText as text set oldTID to AppleScript's text item delimiters repeat with i from 1 to count searchTerm set AppleScript's text item delimiters to searchTerm's item i set theText to theText's text items set AppleScript's text item delimiters to replaceTerm's item i set theText to theText as text end repeat set AppleScript's text item delimiters to oldTID return theText end searchReplaceText
_________________ Share and read automation tips and setups:
http://automation.highearthorbit.com/wiki
Control Indigo from anywhere in the world:
http://highearthorbit.com/software/indigowidget
|
| Fri Feb 17, 2006 6:58 am |
|
 |
|
dtich
Joined: Sep 24, 2005 Posts: 502
|
hey thanks guys. andy, i'll pick through that, thanks!
|
| Fri Feb 17, 2006 5:18 pm |
|
 |
|
dtich
Joined: Sep 24, 2005 Posts: 502
|
hey andy: how do i implement user:password for the slim server? (i'm trying the usual eppc://user:pass@ipaddress, but that's machine control, i'm not sure how to login to slim server remotely...) and if i have more than one squeezebox, how do i specify the device to control?
|
| Sat Feb 18, 2006 12:57 am |
|
 |
|
dtich
Joined: Sep 24, 2005 Posts: 502
|
ok, figured a couple things out:
logging in at each command i did something like this:
- Code: Select all
on slimserverlogin(user,psswrd) sendtoslimserver("login","%20",user,"%20",psswrd) end slimserverlogin
that seemed to help. then, the server now requires player id's at the beginning of each command, so i added to your curl string: - Code: Select all
set d to h & "[" & playerid & "]" & "%20"
and obviously added a - Code: Select all
property playerid : "playerid"
..which is generally the mac address.
also, port 9090 might be more effective than 9000 for this command line stuff, i can't tell because slim server is reloading my itunes library every 3600 seconds and it all but locks up doing that each hour. i am changing that to 604800 seconds.
i hope i have figured this out a bit, we'll see tomorrow when i'm awake.... thanks for the help.
|
| Sat Feb 18, 2006 2:34 am |
|
 |
|
macpro
Joined: Dec 29, 2005 Posts: 585 Location: Third byte on the right
|
Great script!
I've got it running right now so I can start and stop my SLIMP3 using my X10 remote.
I while ago, I made a common log routine in AppleScript for sending messages to the IndigoLog file.
I've changed this routine to send messages to the SLIMP3 also.

_________________ "I tawt I taw a puddy tat!" Tweety
|
| Sat Feb 18, 2006 1:17 pm |
|
 |
|
ajturner
Joined: Jul 10, 2005 Posts: 160 Location: Northville, Michigan
|
Great update to the scripts - I wrote it awhile ago and I have just 1 squeezebox. I'm sure it needs updates to multiple squeezeboxes, etc.
Can you post your edited copy(ies) to the AutomationWiki?
_________________ Share and read automation tips and setups:
http://automation.highearthorbit.com/wiki
Control Indigo from anywhere in the world:
http://highearthorbit.com/software/indigowidget
|
| Mon Feb 20, 2006 7:29 am |
|
 |
|
dtich
Joined: Sep 24, 2005 Posts: 502
|
i can't seem to post to your autowiki site, but here's what i've currently got:
indigo attachment script for controlling slimserver and multiple squeezeboxes. works using the cli via terminal.
this works, albeit clunkily. i can't spend much more time on it as it does what i'm after at this point. for some reason the dislpay handler isn't working, haven't figured out why yet. but this is easily modded for any of the cli commands that are currently enabled.
- Code: Select all
-- SlimServer control attachment -- -- This script provides functions for easily controlling -- a SlimDevices Squeezebox from IndigoActions -- -- Author: Andrew Turner (software@highearthorbit.com) -- mods by dtich -- -- asterisks for security, replace as nec.
property defaultHost : "127.0.0.1" property defaultPort : "9090" property playerid : "**:**:**:**:**:**" property playername : "North Knoll Bedroom" property defaultSeconds : "6"
slimserverlogin("dtich", "****")
SlimServerDisplay("Indigo Online")
(* --test commands:
--SlimServerVolume("5") SlimServerCommand("play") --SlimServerCommand("display", "this is a test", "finally working", "6") *)
using terms from application "IndigoServer" on slimserverlogin(user, psswrd) with timeout of 10 seconds try set connect to "telnet " & defaultHost & " 9090" set login to playerid & " login " & user & " " & psswrd & "%A0" tell application "Terminal" do script connect delay 2 do script login in window "telnet" --window "telnet" is zoomed end tell end try end timeout end slimserverlogin on SlimServerCommand(theCommand) SendToSlimServer(theCommand, 0, 0, 0) end SlimServerCommand on SlimServerDisplay(displayString) set lineOne to "from Indigo:" set lineTwo to displayString SendToSlimServer("display", lineOne, lineTwo, defaultSeconds) end SlimServerDisplay on SlimServerVolume(volume) SendToSlimServer("mixer", "volume", volume, 0) end SlimServerVolume on SlimServerPlaySong(songName) SendToSlimServer("playlist", "play", songName, 0) end SlimServerPlaySong --log (value of variable responseText) as string using type "SlimServer:" --on error log "Error" using type "SlimServer:" end using terms from
on SendToSlimServer(p0, p1, p2, p3) with timeout of 6 seconds try --add playerid set s to playerid --add parameters set s to s & " " & p0 if p1 is not equal to 0 then set s to s & " " & p1 end if if p2 is not equal to 0 then set s to s & " " & p2 end if if p3 is not equal to 0 then set s to d & " " & p3 end if --if p4 is not equal to 0 then --set d to d & "&p4=" & p4 --end if --add player --set s to s & "&player=" & playerid --add LF --set s to s & "%0A" tell application "Terminal" do script s in window "telnet" end tell end try end timeout --get responseText --set serverreply to responseText end SendToSlimServer
(* searchReplaceText(searchTerm, replaceTerm, theText) Replaces a string found in a text by another string. This handle supports lists of search/replace terms.
Parameters: searchTerm: the text to search for replaceTerm: the text to use as replacement theText: the text to search/replace
Examples: searchReplaceText("foo", "bar", "You are a foo") --> "You are a bar" searchReplaceText({"foo", " a "}, {"bar", " one "}, "You are a foo") --> "You are one bar" *)
to searchReplaceText(searchTerm, replaceTerm, theText) set searchTerm to searchTerm as list set replaceTerm to replaceTerm as list set theText to theText as text set oldTID to AppleScript's text item delimiters repeat with i from 1 to count searchTerm set AppleScript's text item delimiters to searchTerm's item i set theText to theText's text items set AppleScript's text item delimiters to replaceTerm's item i set theText to theText as text end repeat set AppleScript's text item delimiters to oldTID return theText end searchReplaceText
|
| Thu Jul 27, 2006 6:15 pm |
|
 |
|
nsosnicki
Joined: Nov 14, 2004 Posts: 155 Location: Boston, MA, US
|
Here is my contribution...
I modified the script:
-added error trapping to shell scripts -set the curl connect timeout to 5 seconds and the curl transaction time limit to 10 seconds (these can be increased if needed; for example, with these values, I sometimes still get timeouts if the SlimServer is doing a library rescan) -added option to ping SlimServer and Squeezebox to see if they are there before sending commands -added support for multiple Squeezeboxes through a nick name/IP address definition; this requires an extra parm for each command -to support multiple Squeezebox status, multiple status variables are used; these will be created automatically if needed -changed slim server display function to allow dynamic control of the time to display
The reason for the timeout changes and ping tests is that if your Squeezebox is not reachable, Indigo can get hung up waiting for a response from SlimServer.
Note that to use this script, you will have to add a Squeezebox nickname to every SlimServer function call you have in your Indigo applescripts. For example, SlimServerVolume(40) will have to be changed to SlimServerVolume(40,"Bedroom")
Also, there seem to be multiple branches of this script floating around. This branch does not include the login function.
I've run this for a few weeks with no problems in Indigo 2.0b8/SlimServer 6.5.0.
- Code: Select all
--SlimServer control attachment -- -- This script provides functions for easily controlling -- a SlimDevices SLIMP3 or Squeezebox from IndigoActions -- -- Author: Andrew Turner (software at highearthorbit dot com) -- Changes: Paul Roomberg (paul at pasaro dot nl) -- Nick Sosnicki - 30 Oct 2006 - v1.2 -- -tested on Indigo 2.0b8, SlimServer 6.5.0 -- -added error trapping to shell scripts -- -set the curl connect timeout to 5 seconds -- and the curl transaction time limit to -- 10 seconds (these can be increased if needed) -- - added option to ping server and Squeezebox to -- see if they are there before sending commands -- -added support for multiple Squeezeboxes through -- a nick name/IP address definition; this requires -- an extra parm for each command -- -to support multiple Squeezebox status, multiple -- status variables are used; these will be created -- automatically if needed -- -changed slim server display function to allow -- dynamic control of the time to display -- -- Available Functions: -- (if the squeezebox nick name is blank, the first one defined in the map will be used) -- SlimServerDisplay("Line 1", "Line 2", seconds to display, "Squeeze Nickname") -- SlimServerVolume(volume, "Squeeze Nickname") -- volume: 0-100 -- SlimServerPlaySong("Song Name", "Squeeze Nickname") -- SlimServerSkipFwd("Squeeze Nickname") -- SlimServerSkipRew("Squeeze Nickname") -- SlimServerPower(On or Off, "Squeeze Nickname") -- On or Off: 0 is off, 1 is on -- SlimServerCommand("Command","Squeeze Nickname") -- Available commands: "play", "pause", "stop", "sleep" -- -- Status variable are named "SlimStatus" and the Squeezebox's nick name -- for example, "SlimStatusupBath1" and "SlimStatusupBath2"
property slimIP : "192.168.1.100" --slimserver IP address property slimPort : "9000" --slimserver web port
-- Map of Squeezebox nicknames and their IP addresses. MAC addresses -- can be used instead, but you must set pingSqueeze to false (the ping -- test cnnot be used with MAC addresses). -- Add a new pair for every Squeezebox you want to control. property squeezeMap : {¬ {"upBath", "192.168.2.10"}, ¬ {"upBed", "192.168.2.11"} ¬ }
property pingSlim : true --if true, ping slimserver before commands property pingSqueeze : true --if true, ping squeezebox before commands
property responseText : ""
using terms from application "IndigoServer" on SlimServerCommand(theCommand, squeezeNick) SendToSlimServer(theCommand, 0, 0, 0, squeezeNick) end SlimServerCommand on SlimServerDisplay(displayString1, displayString2, displaySeconds, squeezeNick) set lineOne to searchReplaceText(" ", "%20", displayString1) set lineTwo to searchReplaceText(" ", "%20", displayString2) SendToSlimServer("display", lineOne, lineTwo, displaySeconds, squeezeNick) end SlimServerDisplay on SlimServerVolume(volume, squeezeNick) SendToSlimServer("mixer", "volume", volume, 0, squeezeNick) end SlimServerVolume on SlimServerPlaySong(songName, squeezeNick) SendToSlimServer("playlist", "play", songName, 0, squeezeNick) getSlimStatus(squeezeNick) end SlimServerPlaySong on SlimServerSkipFwd(squeezeNick) SendToSlimServer("button", "jump_fwd", 1, 0, squeezeNick) getSlimStatus(squeezeNick) end SlimServerSkipFwd on SlimServerSkipRew(squeezeNick) SendToSlimServer("button", "jump_rew", 0, 0, squeezeNick) getSlimStatus(squeezeNick) end SlimServerSkipRew on SlimServerPower(onOff, squeezeNick) SendToSlimServer("power", onOff, 0, 0, squeezeNick) getSlimStatus(squeezeNick) end SlimServerPower on SlimServerGetStatus(squeezeNick) SendToSlimServer("status", 0, 0, 0, squeezeNick) getSlimStatus(squeezeNick) end SlimServerGetStatus on getSlimStatus(squeezeNick) tell application "IndigoServer" -- if a status variable pair does not exisit for this Squeeze's nick name, create it set statusVar1 to "SlimStatus" & squeezeNick & "1" set statusVar2 to "SlimStatus" & squeezeNick & "2" if not (variable statusVar1 exists) then make new variable with properties {name:statusVar1, value:first paragraph of responseText} else set value of variable statusVar1 to the first paragraph of responseText end if if not (variable statusVar2 exists) then make new variable with properties {name:statusVar2, value:last paragraph of responseText} else set value of variable statusVar2 to the last paragraph of responseText end if end tell end getSlimStatus on SendToSlimServer(p0, p1, p2, p3, squeezeNick) --lookup IP for Squuezebox nickname if provided, else use first entry if squeezeNick is "" then set squeezeIP to item 2 of item 1 of mapEntry if squeezeIP is "" then tell application "IndigoServer" log "Squeezebox nickname/IP address map is empty" using type "SlimServer" end tell return end if else set squeezeIP to "" repeat with mapEntry in squeezeMap if item 1 of mapEntry is squeezeNick then set squeezeIP to item 2 of mapEntry end repeat if squeezeIP is "" then tell application "IndigoServer" log "Squeezebox nickname " & squeezeNick & " is not defined" using type "SlimServer" end tell return end if end if set pingTest to true if pingSlim then --try to ping slimserver if not PingAddress(slimIP) then set pingTest to false set responseText to "SlimServer at " & slimIP & " not reachable" tell application "IndigoServer" log "SlimServer at " & slimIP & " not reachable" using type "SlimServer" end tell end if end if if pingSqueeze then --try to ping squeezebox if not PingAddress(squeezeIP) then set pingTest to false set responseText to "Squeezebox at " & squeezeIP & " not reachable" tell application "IndigoServer" log "Squeezebox at " & squeezeIP & " not reachable" using type "SlimServer" end tell end if end if if pingTest then set h to "http://" & slimIP & ":" & slimPort & "/status.txt" set d to h & "?p0=" & p0 if p1 is not equal to 0 then set d to d & "&p1=" & p1 end if if p2 is not equal to 0 then set d to d & "&p2=" & p2 end if if p3 is not equal to 0 then set d to d & "&p3=" & p3 end if set d to d & "&player=" & squeezeIP try set responseText to doShellScript("curl --connect-timeout 5 --max-time 10 --get -d --url \"" & d & "\" ") on error errStatement number errNum set responseText to "Connection error (CURL): " & errNum tell application "IndigoServer" log "Connection error (CURL) with SlimServer at " & slimIP & "; error number: " & errNum using type "SlimServer" end tell end try end if end SendToSlimServer end using terms from
(* searchReplaceText(searchTerm, replaceTerm, theText) Replaces a string found in a text by another string. This handle supports lists of search/replace terms.
Parameters: searchTerm: the text to search for replaceTerm: the text to use as replacement theText: the text to search/replace
Examples: searchReplaceText("foo", "bar", "You are a foo") --> "You are a bar" searchReplaceText({"foo", " a "}, {"bar", " one "}, "You are a foo") --> "You are one bar" *)
to searchReplaceText(searchTerm, replaceTerm, theText) set searchTerm to searchTerm as list set replaceTerm to replaceTerm as list set theText to theText as text set oldTID to AppleScript's text item delimiters repeat with i from 1 to count searchTerm set AppleScript's text item delimiters to searchTerm's item i set theText to theText's text items set AppleScript's text item delimiters to replaceTerm's item i set theText to theText as text end repeat set AppleScript's text item delimiters to oldTID return theText end searchReplaceText
-- Pings given address and returns true if there were no errors, false if there were errors on PingAddress(IPAddress) set errTest to true try set ping_result to doShellScript("ping -o -q -n -t 3 " & IPAddress) on error errStatement number errNum set errTest to false end try return errTest end PingAddress
--glue for shell scripts to ensure correct environmental vars are used on doShellScript(scriptStr) tell application "Finder" set returnVal to do shell script scriptStr end tell return returnVal end doShellScript
|
| Mon Nov 20, 2006 2:42 pm |
|
 |
|
matt (support)
Site Admin
Joined: Jan 27, 2003 Posts: 11698 Location: Texas
|
Awesome improvements. Thanks Nick!
Matt
|
| Mon Nov 20, 2006 11:28 pm |
|
 |
|
macpro
Joined: Dec 29, 2005 Posts: 585 Location: Third byte on the right
|
Great enhancement and the timing is just right.
Had some major Indigo issues tonight because of the SlimServer software not working ok.
So I'll impliment your changes soon.
_________________ "I tawt I taw a puddy tat!" Tweety
|
| Wed Nov 22, 2006 1:35 pm |
|
 |
|
morps
Joined: Nov 01, 2003 Posts: 117
|
I just tried updating the original Squeezebox script to the one in this thread and have run into the following error:
- Code: Select all
Error script error: {} doesn't match the parameters {squeezeNick} for SlimServerGetStatus. Error error dispatching event to attachment script (-1753) Error script error: {} doesn't match the parameters {squeezeNick} for SlimServerGetStatus.
...when my "Slim Status" Time/Date Action runs. By the way, I am still running the original embedded Applescript in this Action: if value of variable "SlimPower" = "on" then SlimServerGetStatus() else set value of variable "SlimStatus1" to "" set value of variable "SlimStatus2" to "" -- log "Slim Power: " & ("SlimPower") as string -- log "Slim Status 1: " & ("SlimStatus1") as string -- log "Slim Status 2: " & ("SlimStatus2") as string -- log "Slim Volume: " & ("SlimVolume") as string end if
My variables are still SlimPower, SlimStatus1, SlimStatus2, SlimVolume (not sure if that plays into my challenge(s) or not. Finally, in the spirit of disclosing information to people smarter than me who are kind enough to help out, I do have two Squeezeboxes on my network and setup those to boxes in the script above as follows: - Code: Select all
property squeezeMap : {¬ {"FamilyRoom", "192.168.123.103"}, ¬ {"Garage", "192.168.2.123.107"} ¬ }
Any pointers on how to unravel my mess are greatly appreciated
Cheers and thanks in advance...
|
| Fri Nov 24, 2006 6:15 pm |
|
 |
|
macpro
Joined: Dec 29, 2005 Posts: 585 Location: Third byte on the right
|
One small but important detail: this is the real original Squeezebox script and it was written bij Andrew Turner. I modified it a bit to get the script you're referring to.  You might try the following in your SlimServer Time/Date Action: if value of variable "SlimPower" = "on" then SlimServerGetStatus("<SqueezeBoxNickname>") else ...
_________________ "I tawt I taw a puddy tat!" Tweety
|
| Sat Nov 25, 2006 1:27 am |
|
 |
|
morps
Joined: Nov 01, 2003 Posts: 117
|
macpro wrote:I modified it a bit to get the script you're referring to.  You might try the following in your SlimServer Time/Date Action: if value of variable "SlimPower" = "on" then SlimServerGetStatus("<SqueezeBoxNickname>") else ...
Hi macpro,
Thanks for responding. I did try your suggestion, but no dice. So I'm thinking... instead of trying to debug my way out of my situation, maybe I will start "fresh" so-to-speak.
Therefore a few questions:
1. How do you initiate and call your script from within Indigo?
2. What variables do you have setup in Indigo?
3. I have two Squeezeboxes... do you setup your indigo variables as "SlimStatus<SqueezeboxNickname>1" and "SlimStatus<SqueezeboxNickname>2"?
4. What else should I be asking you that I am not bright enough to know I should be asking
Thanks...
|
| Sat Nov 25, 2006 8:55 am |
|
|
|
Page 1 of 3
|
[ 36 posts ] |
Go to page: 1, 2, 3 Next |
Who is online |
Users browsing this forum: No registered users and 1 guest |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot post attachments in this forum
|
|