We have moved at community.getvera.com

Author Topic: How I added Squeezebox control to my 'go to bed scene'  (Read 7957 times)

Offline Klunket

  • Sr. Newbie
  • *
  • Posts: 34
  • Karma: +0/-0
How I added Squeezebox control to my 'go to bed scene'
« on: July 12, 2010, 10:06:02 am »
I thought I'd post this here as someone else may find it useful.

I have a Squeezebox Boom next to my bed that my wife and I listen to every night. We use iPeng on our iPhones to control it, and every night I had to set the sleep to an hour manually.

Seeing Ap15e's posts on using the Squeezebox Server CLI via a socket connection, I decided to extend some of his examples to do exactly what I was looking for.

As part of my 'Bedtime' scene that sets the lights, etc, ready for bed and turns on our reading lamps, I have now added the following Luup code:

Code: [Select]
socket=require('socket')

-- Store the identifier for the bedroom player:
local mac = "00:04:20:1e:4e:2a"

local client = socket.connect('192.168.1.3', 9090)

-- Make sure the player is on:
client:send(mac .. " power 1\n")
local result=client:receive()

-- Make it go to sleep in 60 minutes (3600 seconds):
client:send(mac .. " sleep 3600\n")
local result=client:receive()

-- Play Bedtime Playlist
-- TODO: Can't work out how to play playlist.. url for now.
client:send(mac .. " playlist play http://opml.radiotime.com/Tune.ashx?id=s16841&formats=aac,mp3,wma,wmpro,wmvoice,wmvideo,ogg&partnerId=16\n")
local result=client:receive()

Simply changing the string that mac is set to at the top to the player's mac address that you want to control, and replacing 192.168.1.3 with the ip of your squeezebox server, it should work for you.

In short it:
* Turns the player on
* Sets the player to sleep in an hour
* Plays an internet jazz station

As you can see from the todo I struggled to get it to play a playlist (examples in the CLI doc weren't working for me). For now I'm happy to have it go to a nice relaxing starting channel and we can change it if required. Down the track I'd like to have a 'Bedtime' play list that I can throw songs onto that make for good bedtime listening.

I'm hoping to make a plugin to allow control of multiple squeezeboxen down the track so that they actually appear as devices in Vera. This would also have error detection, etc, instead of just the basic implementation I have at the moment.

Offline 325xi

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1101
  • Karma: +0/-0
  • V1, V2, still V2...
Re: How I added Squeezebox control to my 'go to bed scene'
« Reply #1 on: July 12, 2010, 11:22:50 am »
This is great! I can imagine programing few buttons on the regular z-wave controller to switch playlists... once we figure it out

Offline Trempels

  • Newbie
  • *
  • Posts: 8
  • Karma: +0/-0
Re: How I added Squeezebox control to my 'go to bed scene'
« Reply #2 on: June 04, 2011, 04:31:00 pm »
Hi,

Have you find a solution to say the squeezebox to play a mp3 or a playlist ?
The syntax "playlist play /music/file.mp3/n" doesn't work for me.

Any idea ?

Thanks

Offline Ap15e

  • Beta Testers
  • Hero Member
  • *****
  • Posts: 1998
  • Karma: +12/-0
Re: How I added Squeezebox control to my 'go to bed scene'
« Reply #3 on: June 06, 2011, 01:32:27 pm »
The correct syntax (for SBS for Windows) is:

Code: [Select]
77:d3:XX:XX:XX:XX playlist play file:///I:/NewMusic/Schwanensee%20(aus%20Kinderbuch)/Content/01%20-%20Track%201.flac

Offline Trempels

  • Newbie
  • *
  • Posts: 8
  • Karma: +0/-0
Re: How I added Squeezebox control to my 'go to bed scene'
« Reply #4 on: June 06, 2011, 02:32:30 pm »
It works...
Thanks a lot for your help Ap15e. (daf├╝r bedanke ich mich sehr)

To be complete, my SBS in on a NAS Synology.
The syntax is becoming :
Mac playlist play file:///disk1/music/file.mp3

Offline ChrisAZ

  • Full Member
  • ***
  • Posts: 104
  • Karma: +1/-0
Re: How I added Squeezebox control to my 'go to bed scene'
« Reply #5 on: February 02, 2012, 12:45:17 pm »
Did you ever figure out how to specify a playlist? I've tried with no luck. To complicate things, I have Squeezebox use my iTunes playlists.

Offline Ap15e

  • Beta Testers
  • Hero Member
  • *****
  • Posts: 1998
  • Karma: +12/-0
Re: How I added Squeezebox control to my 'go to bed scene'
« Reply #6 on: February 02, 2012, 05:39:43 pm »
The CLI commands listed at http://forums.slimdevices.com/archive/index.php/t-73113.html might be worth a try.

Offline ChrisAZ

  • Full Member
  • ***
  • Posts: 104
  • Karma: +1/-0
Re: How I added Squeezebox control to my 'go to bed scene'
« Reply #7 on: February 15, 2012, 11:44:23 pm »
I was able to get Squeezebox to play a playlist that I had created in the Logitech Media Server and saved to a disk. I haven't found anyone who has figured out how to use the CLI to load an iTunes playlist.

If you have a LMS playlist, the command is simply:
client:send(mac .. " playlist play MyPlaylist\n")
 or in pure CLI:
00:04:20:xx:xx:xx playlist play MyPlaylist

I have this triggered off my door lock, so when I enter a special PIN code it not only turns on the lights in my house but starts my favorite playlist.

The only drawback to this method is that I have to manage the playlist in LMS instead of iTunes.

Offline cw-kid

  • Beta Testers
  • Hero Member
  • *****
  • Posts: 1612
  • Karma: +18/-2
Re: How I added Squeezebox control to my 'go to bed scene'
« Reply #8 on: June 24, 2014, 07:11:39 am »
Hi

I cannot get this to work for some reason. I turned off the firewall on my LMS server to be sure and also running this command:
netstat -an | find "9090" reports that port 9090 is listening and that Vera has established a connection to it, so its not a port / firewall issue.

Here is my code:

Code: [Select]
local mac = "00:00:00:00:00:fe"

local client = socket.connect('192.168.1.00', 9090)

-- Make sure the player is on:
client:send(mac .. " power 1\n")
local result=client:receive()

-- Play BBC Radio 1 URL
client:send(mac .. " playlist play http://bbc.co.uk/radio/listen/live/r1.asx\n")
local result=client:receive()

When I run this in a Vera scene the Squeezebox (SqueezeLite) doesn't do anything or start playing the BBC Radio 1 stream.

If I tune in that BBC Radio 1 url in LMS it works fine and plays OK.

Help!

Thanks

EDIT: Doh.. I missed this part off the start of the code:

socket=require('socket')

Works now!
« Last Edit: June 24, 2014, 07:17:15 am by cw-kid »

Offline holger_40

  • Sr. Newbie
  • *
  • Posts: 33
  • Karma: +0/-0
Re: How I added Squeezebox control to my 'go to bed scene'
« Reply #9 on: November 14, 2017, 07:20:09 pm »
Hello.  This works well, but I'm trying to figure out how to pass login credentials to LMS as part of the code.  I normally have password protection turned on in my LMS settings/Advanced/Security tab.  I had to turn it off in order for the code to work.  I'm trying to understand the syntax to pass username and password to the LMS in the Luup code so I can leave on password protection.  The slimdevices wiki has the following CLI example:
Quote
If you secured your Squeezebox Server with a password, you have to login first with
login username password
If correct it's repeated as
login username ********
Anyone know how to pass this in the Luup code?