Users of Sonos ZonePlayers Needed for Testing

General HouseBot discussion. Any issues that don't fit into any of the other topics belong here.
Osler
HouseBot Guru
Posts: 742
Joined: Fri Feb 03, 2006 11:18 pm

Users of Sonos ZonePlayers Needed for Testing

Post by Osler »

If you own a Sonos system (http://www.sonos.com) your help would be appreciated. I have created a set of scripts that will allow HouseBot to control a Sonos system. Testing of the scripts would be greatly appreciated.

Whats included:

ZonePlayer_Discovery script that is used during inital set up to identify the ZonePlayers in the system and obtain information needed by the control scripts.

ZonePlayer_<ZoneName> scripts. Each zone requires its own script for control. Several zone scripts have been included as well as a generic script that can be modified for your particular zone naming scheme.

Each script requires its own Execute Program Device. Additionally, an External Control Device is also required (Port: 2525, IP: 127.0.0.1, Password: <none>).

Detailed instructions are included in the .zip file.

Current Capabilities:
Play
Pause
Stop
Next
Next Section
Previous
Previous Section
Volume (accepts a value from 0 to 100)
Treble (accepts a value from 0 to 10)
Bass (accepts a value from 0 to 10)
Mute
Loudness
Current Track (given as track number currently)
Track Length
Track Position

The next step is providing the ability to link zones. This will be easy to do, I just need to find the time.

I can access track metadata so I will also be adding track information (artist, album, song, etc.) - just need the time.

Queue population via HouseBot should be doable. However, this will be on down the line.

Enjoy,

Osler

(Scott, can you host this zip file?)
Download zip file here:
Last edited by Osler on Fri Feb 15, 2008 11:09 pm, edited 1 time in total.
ScottBot
Site Admin
Posts: 2790
Joined: Thu Feb 13, 2003 6:46 pm
Location: Georgia (USA)
Contact:

Post by ScottBot »

Now that I've finally fixed the forum so attachments work again, I'm just going to provide it in this message. Note, you must be logged in to see the attachment.
Attachments
Sonos_Control.zip
(302.93 KiB) Downloaded 390 times
Scott
Osler
HouseBot Guru
Posts: 742
Joined: Fri Feb 03, 2006 11:18 pm

Mute and Loudness

Post by Osler »

There are some problems with the code for set mute and loudness. Sorry I didn't catch this earlier, but I am just now having a chance to put the scripts through their paces via HouseBot. I will get the problem fixed and update the Sonos_Control.zip file. I'll post when its updated.

Osler
Osler
HouseBot Guru
Posts: 742
Joined: Fri Feb 03, 2006 11:18 pm

Post by Osler »

All fixed for now:

Fixes:
1) ZonePlayer not receiving boolean value for LoudnessStatus
2) ZonePlayer not receiving boolean value for MuteStatus
3) Treble defaulted to 0 no matter what value was entered
4) Bass defaulted to 0 no matter what value was entered

All appears to be working as advertised now. I download the .zip from the forum to my main system today and did the "installation" of the scripts. I am currently controlling two ZonePlayers from HouseBot.

I have figured out how to get music library information by Album, AlbumArtist, Genre, etc. from the ZonePlayer. This is the first step in being able to build a Queue from within HouseBot. The only problem is that this data comes from the ZonePlayer in xml format and I have never really had the need to learn how to parse this stuff (please see my poor attempt at a non-xml weather scraper). This also means I will have to learn about the HouseBot alpha-list and list control, which I have been avoiding like the plague.

Osler

Hmm....no attachment. Please see link in first post above for latest version.
gfarrar
Member
Posts: 1
Joined: Sun Nov 19, 2006 11:50 pm
Contact:

Check sonos forums too

Post by gfarrar »

Hi,

You may also want to check the Sonos forums for volunteers:

http://forums.sonos.com

Looks like a cool integration.

Best,
Graham
Manager, Sonos Support
Osler
HouseBot Guru
Posts: 742
Joined: Fri Feb 03, 2006 11:18 pm

Post by Osler »

Thanks Graham. I was planning to do this once a few more kinks are worked out. I am in the midst of rewriting the scripts to condense the code and fix a problem with the UPnPDeviceFinder.FindByUDN that I encountered. Once I get it to a relatively stable position I'll make the request there.

Osler
Osler
HouseBot Guru
Posts: 742
Joined: Fri Feb 03, 2006 11:18 pm

Post by Osler »

See link in first post for the latest scripts.

I have condensed the code and used only one CreateObject call for UPnPDeviceFinder for the entire script. The previous script acted a little squirrely when trying to attach to one of my ZonePlayers...not sure why but it appeared to be related to the multiple FindByUDN calls in the previous version. The script now attempts some error catching and if the CreateObject doesn't work, it will attempt it three additional times before producing an error and a message box.

Osler
Osler
HouseBot Guru
Posts: 742
Joined: Fri Feb 03, 2006 11:18 pm

Post by Osler »

Scripts updated with new functionality.

An additional property needs to be created called ZPCurrentAlbum (alphanumeric) and this property added to each ZonePlayer_<ZoneName> device. Scripts will now populated Album-Artist in this field and the ZPCurrentTrack property will display the track which is currently playing in the queue. This only works on queues >1 track in size....I haven't spent the time yet to figure out why a 1 track queue causes problems.

The main functionality of each script has been placed in a Do/Loop which occurs every 500 ms (thanks Richard for posting your scripts....much goodness is in those). This means that once the script is executed, it continues indefinately and allows for continuous polling of the physical ZonePlayer device. Benefits include:

1) CurrentPosition property increments as the track plays
2) Once you change a property value (TransportState, Mute, etc.) the change is automatically detected by the script and transferred to the ZonePlayer
3) Changes made by controllers external to HouseBot (Sonos Handheld Controller, Sonos Desktop Controller) are detected by the script and the property values in HouseBot are updated to reflect the current ZonePlayer state

Additional base scripts are now available to match every feasable zone name that is available to Sonos users in the US during inital zone set-up.

Please see the download link in the first post for the latest scripts.

Osler
Osler
HouseBot Guru
Posts: 742
Joined: Fri Feb 03, 2006 11:18 pm

UPDATE

Post by Osler »

I have successfully parsed through all of the media (tracks) available to the Sonos network and obtained basic information as well as the track URI and metadata (both needed to populate a queue or use the "play now" function of the ZonePlayer). I have to say that after learning to parse XML for the last few days, there comes a point where you say "DOH" and feel somewhat dense as understanding begins to dawn on you.

Additionally, I have figured out how to link ZonePlayers together....the most important function being to create a "Party Mode" where all ZonePlayers play the same thing simultaneously.

I am currently working on an integrated script to control all ZonePlayers on the network. This should simplify things considerably.

The ZonePlayer_Discovery script will undergo some changes as well.

I will write an additional script that will pull all data from media shares and populate a database file for queue population. This script will also serve to reindex the media shares/update the database as new albums/tracks are added.

This would be much easier if I had the Visual Basic SDK.....ahhh, to wish.

Hopefully I can get this completed in the next week or so.

Osler
Osler
HouseBot Guru
Posts: 742
Joined: Fri Feb 03, 2006 11:18 pm

UPDATE

Post by Osler »

I got a little side-tracked trying to write an AcitveX DLL to allow scripting using the UPnP.dll from within HouseBot. It worked to a point, but not all of the methods of the UPnP.dll are available in VB6....most importantly the capability to do device discovery. As a result, I have moved the code back to VBScript and written a class that allows for much simplifed control of a ZonePlayer via scripting. I will post the methods of the class soon. If you have a scripting tool such as VBsedit, it should expose the methods once the class object is created. The class exposes all ZonePlayer parameters I would conceivably want to control or perform a state query on.

Sample code using class:

My goal is to try to keep this modular and use .wsf files to pull in the class files. However, you can simply cut-and-paste the attached script into your current script and use it that way. THIS SCRIPT WILL NOT WORK FROM WITHIN HOUSEBOT. It has to be called with wscript.exe using command line paramters.

Download Class:



Osler
Last edited by Osler on Fri Feb 15, 2008 11:02 pm, edited 2 times in total.
Circe640
Advanced Member
Posts: 206
Joined: Tue Oct 07, 2003 10:01 am
Location: Columbus, OH
Contact:

Post by Circe640 »

Osler,
I still have the VB SDK and been using it to build my plugin so I know its capabilities well. I also have an integrated qplayer in the plugin about to be released. IF you use you XML to populate my plugin DB for song data the Qplayer in it could be used to drive your other parts. Let me know if you are interested.

Jim
Circe640
Advanced Member
Posts: 206
Joined: Tue Oct 07, 2003 10:01 am
Location: Columbus, OH
Contact:

Post by Circe640 »

Osler,
I have the VB SDK and know its capabilities well. As I have been using it to build MediaPro. MediaPRo has a Qplayer that would work extreme;y well for what you described. Let me know if you are interested

Jim
Circe640
Advanced Member
Posts: 206
Joined: Tue Oct 07, 2003 10:01 am
Location: Columbus, OH
Contact:

Post by Circe640 »

sorry for the double post but when I submit I am getting

Could not connect to smtp host : 10060 : A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.

DEBUG MODE

Line : 112
File : smtp.php
Osler
HouseBot Guru
Posts: 742
Joined: Fri Feb 03, 2006 11:18 pm

Post by Osler »

I'd be very interested. Building the XML parsing class is next on my list of things to do. You have pm.

Osler
ScottBot
Site Admin
Posts: 2790
Joined: Thu Feb 13, 2003 6:46 pm
Location: Georgia (USA)
Contact:

Post by ScottBot »

Circe640 wrote:sorry for the double post but when I submit I am getting

Could not connect to smtp host : 10060 : A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.

DEBUG MODE

Line : 112
File : smtp.php
Thanks for mentioning this Jim. I've been seeing double-posts and had no idea what was going on. If other users are seeing the same errors, it would explain things. I've started looking into this, but if anyone else has had similar issues, please let me know ASAP.
Scott
Post Reply