Posts Tagged ‘Squeezecenter’

Send text to Squeezecenter

September 18th, 2009

This VBScript will send a text to your squeezecenter and the text will be displayed on your Squeezebox.

I use it to show who is calling.

It uses w3Sockets from http://www.dimac.com/default3.asp?M=FreeDownloads/Menu.asp&P=FreeDownloads/FreeDownloadsstart.asp, so download and register it before trying this out.

Option Explicit
Dim i, oTelnet, outString, slimHost, slimPort, txtDuration, sendStop, headString, maxLengthHead, headPaddingChar, headPadding

slimHost = "192.168.100.50"	' IP-address to Squeezecenter
slimPort = "9090" ' Portnumber on the Squeezecenter (Standard is 9090)
txtDuration = "120" ' Seconds to show the text
sendStop = False ' Stop music?

headString = "Incoming call" ' Text to show on top row
maxLengthHead = 44 ' Max-length on top row
headPaddingChar = "*" ' On the sides of the text

Dim playerMac(1) ' Se example below
playerMac(0) = "00:04:20:00:aa:bb"	' Kitchen
playerMac(1) = "4d:22:6a:00:aa:bb"	' Soft squeeze
' ------------------------------------------------------------------------------------------------
' Example for 1 player
' Dim playerMac(0)
' playerMac(0) = "11:22:33:44:55:66"
'
' Example for 3 players
' Dim playerMac(2)
' playerMac(0) = "11:22:33:44:55:66"
' playerMac(1) = "aa:bb:cc:dd:ee:ff"
' playerMac(2) = "77:88:99:00:aa:bb"
' ------------------------------------------------------------------------------------------------

' Create top row
headString = " " & headString & " "
headPadding = ""
For i = 0 to (Round((maxLengthHead-Len(headString)) / 2))
	headPadding = headPadding & headPaddingChar
Next
outString = Replace(headPadding & headString & headPadding, " ", "%20") & " "

' Create row to show
if wScript.Arguments.Count <> 0 then
	For i = 0 to (wScript.Arguments.Count-1)
		outString = outString & wScript.Arguments(i) & "%20"
	Next
Else
	outString = outString & "Saknar%20parametrar%20till%20scriptet"
End if

set oTelnet = CreateObject("Socket.TCP")
With oTelnet
	.DoTelnetEmulation = True
	.TelnetEmulation = "TTY"
	.Host = slimHost & ":" & slimPort
	.Open

	' Loop thru all players
	For i = 0 to uBound(playerMac)
		' Skickar stop-kommandot
		if sendStop then
			' Stop the music
			.SendLine playerMac(i) & " button stop"
		end if

		' Send display-command
		.SendLine playerMac(i) & " display " & outString & " " & txtDuration

	Next

	.SendLine "exit"
	.Close
End With
Set oTelnet = Nothing