Calling Sonos users

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

Re: Calling Sonos users

Post by Osler »

Find attached an addition to the Sonos ZonePlayer devices for HouseBot. The device is a media server device and will build an Access database of all of your stored music to facilitate power searches. It will allow you to view your music by Album, Artist, or Track and perform a real-time search for a keyword within each of these views. The search occurs as you build the search string, updating the list control device as you narrow your search down. Once a song is selected, it can be set to play on the associated ZonePlayer via property value substitution (this is demonstrated within the included single-panel theme).

Also, the device keeps track of when your ZonePlayer was last reindexed and will compare its stored reindex date to the current reindex date on the ZonePlayer once a day at a time specified by you (default is 12:00:00 am). If the reindex dates do not match, the device will automatically rebuild the database to include any new music that was added as a result of the reindex. A database rebuild can also be initiated by the user via the ZPBuildDatabase value (boolean).

The initial database build can take a minute or more, so be patient when first setting it to run. The user is notified of what the script is doing via the ZPMediaServerMessage property within the device.

The database is stored in the Scripts folder.

At present, each ZonePlayer will need a ZPMediaServer device and you will need to populate the UDN of this device with the same one used for the ZonePlayer device.

The included ZonePlayerController.wsc file needs to be used. It includes all of the old functionality plus the new database construction subroutines.

Enjoy and post any questions, comments, critiques.

Osler
Attachments
HouseBot ZonePlayer_MediaServer.zip
(16.91 KiB) Downloaded 421 times
Osler
HouseBot Guru
Posts: 742
Joined: Fri Feb 03, 2006 11:18 pm

Version 2.0.3

Post by Osler »

So after using the music server script, I found it to be slow and a bit clunky. As a result, I revamped the Music Menu functionality within the ZonePlayer_Device script itself to 1) incorporate the power scroll functionality via the ZonePlayer as opposed to an external database and 2) lay the foundation for adding RadioTime and other music services. In doing this, I also changed how the queue is displayed via the device (uses ZPBrowseList instead of ZPQueue) to streamline and optimize the code a bit. Everything still works the way it was, there is currently just additional code (i.e., the script won't "break" current themes). I plan to remove some code in the next release if all users are satisfied with the new functionality.

I have also provided the ability to go directly from one main Music Menu item to another without having to back completely out of the menu (i.e., you are drilled all the way down to a track via the Artist sub-menu and can now quickly move to the Album sub-menu to find an additional track).

In addition, I have broken out the ZPPlaymode functionality into two distinct boolean properties: ZPShuffle and ZPRepeat. This allows you to have control over each function individually.

Another thing that I finally finished was keeping track of how far down you are drilled into the Music Menu. This property is called ZPBrowsePercent and never worked correctly until now. The main reason for doing this was to keep the scrollbar from appearing in the list control. ZPBrowsePercent, in conjuction with 2 buttons for ZPBrowse (one for "Up" and one for "Down"), can be used to create a custom scrollbar that fits better with your theme. This keeps the system scrollbar out of your theme and still allows you to see how many items remain to be scrolled through via a visual cue.

I have included a sample theme with some new "eye-candy" to demonstrate the new functions. The theme is only for a single zone and doesn't include linking. The display is 800x480 and is similar in layout to the ipod touch.

NEW PROPERTIES:
ZPSearchType (alphanumeric) (A:ALBUM, A:ARTIST, A:TRACKS, A:GENRE, A:COMPOSER, A:PLAYLISTS, R:, AI:, S:, SQ:)
ZPSearchString (alphanumeric) (#, A-Z (upper case); single character)
ZPShuffle (boolean)
ZPRepeat (boolean)
ZPBrowseReturn (alphanumeric - value of 14 is optimal for the new theme)

A new .wsc file is included that is needed for the upgraded Music Menu functionality.

The new script is in the .hbx file.

Osler

Edit: Added property ZPBrowseReturn to list of new properties.
Attachments
ISonos800x480.zip
(363.4 KiB) Downloaded 404 times
ZonePlayerController.zip
(11.15 KiB) Downloaded 442 times
Last edited by Osler on Fri Jan 09, 2009 11:12 pm, edited 2 times in total.
Osler
HouseBot Guru
Posts: 742
Joined: Fri Feb 03, 2006 11:18 pm

Re: Calling Sonos users

Post by Osler »

Some screenshots of the new theme. The Music Menu shot demonstrates the quick navigation buttons on the left of the screen and also has the power scroll feature activated for the selected sub-menu.

Osler
Attachments
isonos_nowplaying.JPG
isonos_nowplaying.JPG (44.94 KiB) Viewed 8921 times
isonos_musicmenu.JPG
isonos_musicmenu.JPG (46.82 KiB) Viewed 8921 times
isonos_queue.JPG
isonos_queue.JPG (28.71 KiB) Viewed 8921 times
CouchPotatoe
Senior Member
Posts: 103
Joined: Sun Jul 31, 2005 2:43 pm
Location: Yorkshire UK

Re: Calling Sonos users

Post by CouchPotatoe »

Hi Osler,

I just wanted to let you know that , although I'm really busy at the moment and won't get a chance to play with these extra bits for a while, they look really great , and most useful.

I am using your HouseBot script all the time to effectively make all my Sonos players xAP enabled. The Sonos players then , via HB, become a xAP accesible player, accessible from everywhere, inparticular some tiny embedded controllers that couldn't handle UPnP directly but now can interact with Sonos really nicely.

Hope you have a great Xmas,

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

Re: Calling Sonos users

Post by Osler »

Kevin:

Can you give me some details on exactly what you have the script interacting with via xAP? I still can't quite wrap my head around xAP and how it can be useful to me in my set-up.

Osler
vcruz777
Member
Posts: 70
Joined: Sun Jul 08, 2007 9:39 pm

Re: Calling Sonos users

Post by vcruz777 »

Osler, I am not sure if I am doing something wrong but the ISonos file looks incomplete. I am not able to import it. (ConfigExport.xlm file is missing + I don't see the graphics within the file)

BTW, thanks for this new feature.

Victor


EDIT: Don't worry. I figured it out. when I extracted the zip file, the file extracted is also a zip file (double zipped). I change the extension of the extracted file to .hbx and now it works. Saludos.
CouchPotatoe
Senior Member
Posts: 103
Joined: Sun Jul 31, 2005 2:43 pm
Location: Yorkshire UK

Re: Calling Sonos users

Post by CouchPotatoe »

Osler wrote: Can you give me some details on exactly what you have the script interacting with via xAP? I still can't quite wrap my head around xAP and how it can be useful to me in my set-up.
Osler
If you have a HouseBot centric system ie only one central controller - and are not interested in adding new devices to it (that xAP might offer) then xAP really offers you no benefits. The xAP plugin will obviously allow you to add any xAP enabled devices to your system however it's main role is to provide a simple yet powerful common language that all your devices can use to talk to each other - an 'Esperato' for gadgets if you like. This provides a clarity and flexibility for building an automation model that will adapt as your expectations change.

A long post ensues - once I get going ;-)

xAP is a broadcast system - ie devices all talk to your home and not to specific other devices, controllers or software - they can also be controlled by all other devices so effectively they all become network devices attached and controllable (usually over Ethernet). So a light can listen to a switch(s) - or a switch can control light(s) or a controller eg HouseBot can take the middle role and manage this interaction , adding extra 'smarts' like timers etc. If you expand this you can have several independent controllers each performing different functions or indeed controllers that double check that things are working as expected and step in should something fail (redundant controllers - very powerful in more complex systems). This allows a really flexible system to be built up using the model you prefer. Then if your controller fails your light switches can still control your lights etc - which keeps everything running smoothly, and the wife happy. I cannot overemphasise how important ensuring a system works as expected all the time is for adoption by the less technically appreciative.

As an added benefit locally attached devices to a xAP enabled software application, usually implemented by bespoke plugins, become xAP enabled too. What you will see from this is that a device attached to a PC is no longer owned and monopolised by that application - it can be shared with other applications so basically your home becomes a patchpanel of inputs and outputs that you link together as you wish. CallerID spoken to your HiFi or weather displayed on your TV etc.

In my home I use this approach extensively as I have chosen 'best of breed' systems for key functionality. I have a Sonos music system, a C-Bus lighting system, a heating system, a great security system, telephony and 1-wire plus an IDRANet network of sensors that all work faultlessly and independently and then I integrate them using xAP. I also have a standalone hardware automation controller (not a PC) that speaks xAP and orchestrates the interactions between these devices. It performs 24/7 dependably. Finally on top of that I layer fancier integration - usually involving richer or more complex data like perhaps TV listings, email or weather forecasts using a PC and a favourite software application - in my case HouseBot and Cortex. Should you lose the fancier layer - eg perhaps one that reads the weather forecast and adapts your heating plan then you still retain the base functionality.

xAP also makes attempts to abstract a device to its functional purpose - we call these schema - so the Sonos system becomes a 'xap-audio' device. The plus here is that your system controls a xap-audio device and not specifically a Sonos system - so actually if you have an Escient , Imerge, Request, Roku / Pinnacle, SqueezeCentre / Logitech , or WinAMP based system - (assuming they have xAP conduits) they look the same to xAP. So you can just swap your music system and your automation setup would still work the same :-) Very powerful for upgrading.

In fact I used to have X10 and I changed to C-Bus and it just worked with no changes - in fact I still mix and match the two whilst I transition as funds and time permit - the system doesn't know which is actually being used. Also just out of interest the Roku and SqueezeCentre devices haveLCD/VFD displays so we expose a xAP display schema for them and when you send such messages in xAP they then display on these - useful for CallerID for example. Even the Logitech Duet colour LCD remote displays these - oh and my iPhone does too . Unfortunately the Sonos controller is pretty closed in this respect.

This 'mix and match' approach applies to controllers too - you can have dual software applications running - and they can be synchronised and interact - and share their plugin devices... plus you can link remote sites eg your vacation cabin over the internet as one system. What you can then do is choose to use a software application for it's features and the devices it supports and mix two applications to get the best of both. HouseBot is a favourite because of its TouchScreen capabilities , it's speed and flexible scripting interactions - and it has the most capable xAP plugin . I also use Cortex however because it links to a really nice, low cost hardware network called IDRANet that has formed a lot of my hardware infrastructure. It has no TouchScreen capability - but by combining the two via xAP I get the best of both systems.

xAP is also very simple (and protocols do not tend to be normally) - it is human readable , lightweight and yet it is expandable and powerful too. Above all its 'free'. This means that home automation enthusiasts with hobby level programming skills can write xAP conduits for their own particular devices and needs very easily. In fact if there is a xAP plugin for an application (like HouseBot) it is usually very much easier to write a connector for your device that speaks xAP than one that uses the specific plugin toolkit offered by application - and your device will work in many other applications too.

So xAP has shown me a way to getting many different systems and devices to all work in harmony , be fairly future proof and achieve reliability - by using it as the 'glue' layer as it's often very appropriately called. Most enjoyably it's allowed me to do what I want and not to totally commit myself to one system or set of devices. However as I said at the start, if you are happily contained within one controller and your specific devices are already supported then xAP offers no benefit, and actually complicates things as it adds another layer to manage (and go wrong).

Kevin

PS Just to answer your first question - I use the HouseBot properties created by your script to expose their status and control via xAP. Then from other xAP hardware and software on my home network I can totally integrate with Sonos. My amp turns on and selects the right inputs when I start Sonos and I can control the volume from my C-Bus wall switches. I can mute when the phone rings and even control the Sonos from my iPhone Touch (even before the iPhone Sonos app emerged)and I can do that remotely via 3G too. My touchscreen designs (well yours) that manage my Sonos music actually also work for both my SqueezeCentre based system here and an Escient system in my other home too (as the music libraries are common). These systems appear to be just zones off the same system, obviously when linked the music doesn't play in synch however.
Osler
HouseBot Guru
Posts: 742
Joined: Fri Feb 03, 2006 11:18 pm

Re: Calling Sonos users

Post by Osler »

In a nutshell, a distributed automation system. However, most standalone devices don't speak xAP, do they? Are you using PIC or Rabbit processors to ethernet/xAP enable devices that would normally function on their own?

Osler
CouchPotatoe
Senior Member
Posts: 103
Joined: Sun Jul 31, 2005 2:43 pm
Location: Yorkshire UK

Re: Calling Sonos users

Post by CouchPotatoe »

Yes... if you want autonomous operation - but most people write small applications on their PC - and then attach to the device via RS232/485 , parallel or Ethernet.

K
vcruz777
Member
Posts: 70
Joined: Sun Jul 08, 2007 9:39 pm

Re: Calling Sonos users

Post by vcruz777 »

Even with the changes in the script to poll for track information only when transportstate = " Play" I was still getting disconnects that was only solved by restarting housebot (restarting the script wouldn't work). I tried playing with different update times but still got eventually disconnected. Since it was suspectd that the culprit was the GetTrackInfo subroutine and calling it constantly I decided not to call the subroutine from the main script loop. The problem is that I really wanted to have the track information updates to see the time elapsed and see the progress bar. I decided to write a separate script to calculate the time elapsed from within housebot without polling the sonos. Of course it is using from sonos the track lenght and the transport state to ensure we calculate the right percentage and count when playing. It is an ugly solution and uglier script but it works and has solved my problem. I am including the script in case you want to tae a look and improve it until a more decent solution is found.

The only change to the original script was to remove from the continuous loop the call to the GetTrackInfo Sub.

I had to create on script device per zone since I am running this script separately from the main script to ensure it is executed every second.

Victor

Code: Select all

' ========================================================================
' Sonos TrackInfo - Living Room Zone
' ========================================================================

Dim currenttrack
Dim changetrack
Dim tracklenght
Dim trackpercent
Dim trackminutes
Dim trackseconds
Dim lseconds
Dim lminutes
Dim totaltime
Dim I
Dim synctrack
Dim trackupdateseconds
Dim trackupdateminutes
Dim trackupdatetotal
Dim ZPCurrentTrack

' Variables Initialization
Sleep (5000)
I=0
tracklenght = GetPropertyValue("ZP_Living Room.ZPTrackLength")
If tracklenght <> "" then 
	changetrack = tracklenght
	lminutes = int(Left(tracklenght,2))
	lseconds = int(Right(tracklenght,2))
	totaltime = (lminutes*60) + lseconds
End If

Do
	ZPCurrentTrack = GetPropertyValue("ZP_Living Room.ZPCurrentTrack") 
	If (GetPropertyValue("ZP_Living Room.ZPTransportState") = "Play") and (ZPCurrentTrack <> "Internet Radio") and (ZPCurrentTrack <> "Streaming") and (ZPCurrentTrack <> "Linked") and (ZPCurrentTrack <> "[no music]") Then
		Main
	Else
		I=0
	End If
	Sleep(1000)
Loop

Private Sub Main

	tracklenght = GetPropertyValue("ZP_Living Room.ZPTrackLength")
	If tracklenght = "" then 
		Exit Sub
	End If

	If I=0 Then
		synctrack = GetPropertyValue("ZP_Living Room.ZPTrackPosition")
		If synctrack = "" Then 
			Exit Sub
		End If
		Sleep (500)
		tracklenght = GetPropertyValue("ZP_Living Room.ZPTrackLength")
		If tracklenght = "" then 
			Exit Sub
		End If
		trackupdateminutes = int(Left(synctrack,2))
		trackupdateseconds = int(Right(synctrack,2))
		trackupdatetotal = (trackupdateminutes)*60 + trackupdateseconds
		currenttrack = trackupdatetotal+1
		I=1
		changetrack = tracklenght
		lminutes = int(Left(tracklenght,2))
		lseconds = int(Right(tracklenght,2))
		totaltime = (lminutes*60) + lseconds
	End If

	If (changetrack <> tracklenght) or (trackpercent >= 100) Then
		currenttrack = 0	
		changetrack = tracklenght
		lminutes = int(Left(tracklenght,2))
		lseconds = int(Right(tracklenght,2))
		totaltime = (lminutes*60) + lseconds
	End If
	currenttrack = currenttrack + 1
	trackminutes = int(currenttrack / 60)
	trackseconds = currenttrack - (trackminutes*60)

	If (trackseconds) < 10 then
		SetPropertyValue "ZP_Living Room.ZPTrackPosition", "0" & trackminutes & ":0" & trackseconds
	Else
		SetPropertyValue "ZP_Living Room.ZPTrackPosition", "0" & trackminutes & ":" & trackseconds
	End If
	trackpercent = int((currenttrack*100) / (totaltime))
	SetPropertyValue "ZP_Living Room.ZPTrackPercent", trackpercent
	SetPropertyValue "ZP_Living Room.ZPTrackPosLen", currenttrack & " / " & tracklenght
	
End Sub	

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

Re: Calling Sonos users

Post by Osler »

Please provide me with the error log data for your zones that are getting lost. Expand the device, select log, and copy/paste it here (please make sure changes to device properties are NOT being logged). Are you seeing this on all zones?

I have a single zone that will do this to me periodically and it is not a problem with the script, but an overheating problem with the ZP. For some reason, when my family room ZP (which lives under the TV in an enclosed cabinet with other equipment and without ventilation) gets too hot, it forgets to send callbacks like it is supposed to. I know it is a ZP issue because if I unplug and replug it without doing anything in HB, callbacks are recieved as they are supposed to be. During all of this the CR100 retains its capability to control the zone.I have a total of 4 zones currently and this is the only one I have had connection issues with so I will need your help in debugging this.

Are you using the most recent script and script component (I have to ask)?

Are the probem zones wired or wireless?

Osler
vcruz777
Member
Posts: 70
Joined: Sun Jul 08, 2007 9:39 pm

Re: Calling Sonos users

Post by vcruz777 »

Yes I am using the latest version of the script and the wsc. It is happening with all the zones at the same time. I can see all my zones with my iphone and the sonos controller but when I lose the connection with housebot a restart is the only thing that works. I think that is more related to the script engine within housebot since noramlly when it happens and I try to restart the script I get an error message saying something like " unable to load or compile the script" or something like that although the state change to running. Since restarting it doesn't do it and only a housebot restart is able to fix it I was thinking it was more related to housebot or my configuration and not to Sonos. I will try to get some log info.

Thanks for the response,

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

Re: Calling Sonos users

Post by Osler »

Hmmm...very strange. Try to get me a log. If that doesn't point to something I can add some additional tracing info to try and track this down.

So if you don't poll the ZP, the disconnect does NOT happen....am I correct?

The log should show ping results every 10 minutes to ensure the ZP is online and accepting messages. These are the messages I am most interested in at the moment. Perhaps you could log to a file instead of or in addition to the window for a 24-hour period and zip it up and post it for me.

How many zones?

Also, make sure you have the property ZPBrowseReturn (alphanumeric - value of 14 is optimal with the new theme) added to your devices. I may not have listed this as a new property to add and if it's not there it could cause problems.

Osler
vcruz777
Member
Posts: 70
Joined: Sun Jul 08, 2007 9:39 pm

Re: Calling Sonos users

Post by vcruz777 »

Normally it happens when I am playing songs for a period of time (> 1hr). I will get log data and will post it. Although I had defined the ZPBrowseReturn property in all three zones, in two of them I didn't have any value in. I am not sure if not having a value would have caused problems.

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

Re: Calling Sonos users

Post by Osler »

A lack of value shouldn't cause a problem.

Your use pattern is different than mine. We typically use the ZP's in short time-spans, less than an hour in length. Let me set one of my ZP's to play on mute today and see what comes of it.

Osler
Post Reply