[HSSCRIPT] Squeezebox Server Message Display

Forum over Homeseer scripts (DUTCH forum)

Moderators: TANE, Ruud

Post Reply
Jeffrey
Member
Member
Posts: 136
Joined: Tue Jun 09, 2009 3:34 pm
Location: Netherlands

[HSSCRIPT] Squeezebox Server Message Display

Post by Jeffrey »

At the Homeseer workshop I've mentioned that I've created a script which makes it possible to display a custom message to all Squeezeboxes/Transporters/etc. devices connected to a Squeezecenter server. As people where interested in this script here it is.

---------------------------------------
Installation
---------------------------------------
Extract .zip file and place "SBMessage.vb" in the script folder of Homeseer
(example script folder for HS3: C:\Program Files\HomeSeer HS3\scripts)

---------------------------------------
Upgrade
---------------------------------------
Simply replace the old SBMessage.vb with the new one. The versions are backwards compatible.

---------------------------------------
Usage
---------------------------------------
1. Create an Event in Homeseer with an "Run Script" Action
2. Select the "SBMessage.vb" script
3. Fil in at "Optional parameters": ("Main","<IPADDRESS>;<MESSAGELINE1>;<MESSAGELINE2>;<DURATION>;<BRIGHTNESS>")

---------------------------------------
Mandatory Parameters
---------------------------------------
<IPADDRESS> IPAddress of Squeezecenter host (Use "localhost" or "127.0.0.1" is the Squeezecenter is installed where the script will run)
<MESSAGELINE1> Message to display on the 1st line (small font)
<MESSAGELINE2> Message to display on the 2nd line (normal font)

---------------------------------------
Optional Parameters
---------------------------------------
<DURATION> The time the message will be displayed in seconds
<BRIGHTNESS> Brightnesslevel of the player(s). Supported values: 0 - 4

---------------------------------------
Replacement variables
---------------------------------------
$time Will be replaced with the current time
$date Will be replaced with the current date

---------------------------------------
Example
---------------------------------------
SBMessage.vb("Main","localhost;My first message on line 1;My first message on the second line;3;4")

SBMessage.vb("Main","localhost;The date of today is $date;The current time is $time;3;4")

---------------------------------------
Usage Scenario's
---------------------------------------
- Notify when the dryer is finished
- Notify when the washingmachine is finished
- Display measurements when the weightscale is used (not sure if everyone will what to use this [;)])
- Display the telephonenumber or callername when the phone rings

[18-07-2015 Update: version 0.3, tested with HS3 and added replacement variables for $time and $date]
Attachments
SBMessage_v03.zip
SBMessage v0.3
(3.06 KiB) Downloaded 367 times
drmacchi
Advanced Member
Advanced Member
Posts: 827
Joined: Wed Aug 08, 2007 5:48 pm
Location: Italy

[HSSCRIPT] Squeezebox Server Message Display

Post by drmacchi »

Very interesting, but i need a lttle help: let's say i need to monitor my drier or any other appliance , what would be the code to monitor that, keep status and insert it in "message line 1 " and "message line2" ?
Jeffrey
Member
Member
Posts: 136
Joined: Tue Jun 09, 2009 3:34 pm
Location: Netherlands

[HSSCRIPT] Squeezebox Server Message Display

Post by Jeffrey »

<blockquote id="quote"><font size="1" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote"><i>Originally posted by drmacchi</i>
<br />Very interesting, but i need a lttle help: let's say i need to monitor my drier or any other appliance , what would be the code to monitor that, keep status and insert it in "message line 1 " and "message line2" ?
<hr height="1" noshade id="quote"></font id="quote"></blockquote id="quote">

That's more than this script but I will explain it. It's a long description but you've asked for it [:p].

- What you need -
Physical modules:
1. Plugwise module to monitor power usage which can be controlled from Homeseer (2nd device in the picture under Device List)
2. Squeezecenter enabled device (Squeezebox, Transporter)

<i><b>NOTE: You can also use SoftSqueeze on a PC if you not yet have a physical device but want to test with Squeezecenter and the script (download the software here --> http://www.logitechsqueezebox.com/suppo ... erver.html). Softsqueeze will emulate an squeezebox in this case. I use it as musicplayer on my PC)</b></i>

Homeseer events:
1. 1 Virtual device to keep track of the status (so it will not continue to repeat the message). It acts as a counter.
<i>NOTE: 1st device in the picture under Device List</i>
2. 1 event to create the message and handle a messagecounter (virtual device) when the dryer is finished
<i>NOTE: 2nd event in the picture under Device Value Change</i>
3. 1 event to reset the counter when the dryer is turned off (load = 0 Watt)
<i>NOTE: 1st event in the picture under Device Value Change</i>

Imagetranslation from Dutch to English [:D]:
Droger: Uitgezet - Reset Teller = Dryer: Turned Off - Reset Counter
Droger: Drogerprogramma afgelopen = Dryer: Dryerprogram Finished

How it works:
When the dyer is finished it will use something between 2 and 30 Watt. This is when it triggers the "Droger: Drogerprogramma afgelopen" event.

This event will however only run (condition) if the messagecounter (Virtual Device Z2) is in the range of 0 to 3. This means the message will be displayed only 3 times (if you want to change the number of times displayed and the deplay this is the place to be).

The messageinterval is set by configuring the "Cannot retrigger for X seconds" property which can be set on the Name tab of the event. In my case it is set to 300 seconds (5 minutes). In this configuration the message will be displayed 3 times with an interval of 5 minutes.

This event will do 3 actions:
1. Use the SBMessage.vb script to display on the first line "Droger" (=dryer) and on the second line "Drogerprogramma afgelopen" (=Dryerprogram finished) to all Squeezecenter connected devices.
2. Increment the messagecounter (virtual device Z2) with 1. This is de displayvalue of the virtual device as can be seen in the "Device List" (in the picture the current value under Status is 0).
3. Set the Virtual Device value to the match the displayed value. This is to keep track how many times the message is displayed on the squeezecenter devices.

When the dyer is switched off the usage changes to 0 Watt. This is when it triggers the "Droger: Uitgezet - Reset Teller" (=Dryer: Switched Off - Counter Reset) event.

This event has 2 actions:
1. Set the messagecounter (virtual device Z2) to 0. This is the displayvalue of the virtual device as can be seen in the "Device List" (in the picture the current value under Status is 0).
2. Set the Virtual Device value to the match the displayed value.

<u>Important note: It's importent that you set the initial value of the virtual device to 0 after you've created it. This can be done by creating the "Droger: Uitgezet - Reset Teller" and manually run it.</u>

Image
drmacchi
Advanced Member
Advanced Member
Posts: 827
Joined: Wed Aug 08, 2007 5:48 pm
Location: Italy

[HSSCRIPT] Squeezebox Server Message Display

Post by drmacchi »

Amazing! i have to learn so many things from you. Thanks for explanations. Lorenzo
User avatar
Snelvuur
Forum Moderator
Forum Moderator
Posts: 3156
Joined: Fri Apr 06, 2007 11:01 pm
Location: Netherlands
Contact:

[HSSCRIPT] Squeezebox Server Message Display

Post by Snelvuur »

can you also make it play a sound like "wasdryer is ready" which would be better then only the message itself no?

p.s. for some odd reason this topic was not in my mailbox (subscribed to all)

// Erik (binkey.nl)
Jeffrey
Member
Member
Posts: 136
Joined: Tue Jun 09, 2009 3:34 pm
Location: Netherlands

[HSSCRIPT] Squeezebox Server Message Display

Post by Jeffrey »

Sure you can.

The reason I don't do that is because my amp is not always on and not always set to the Squeezebox input so I will miss announcements. I also don't want to automatically let the amp switch on for just an announcement.

If you always have your amp on or want to turn it on when an announcement is to be made than this will work for you.

You need to make an flac or mp3 (quality doesn't matter in this case so go the MP3 way bandwidth wise) which will say the announcement. Then use cli commands (just adjust my script) to do the following:

1. Determine if each player is switched on and playing or not
2. If playing get the songname and the position where the song is right now
<s>3. Save the current playing playlist (nowplaying)</s>
3. Insert the song in the current playlist
4. Start the announcement MP3 (NOTE: you can put all your announcements in an announcementsplaylist for easy grouping)
<s>4. Restore the playlist</s>
5. Resume the song at the position saved earlier

<b>If you want to know the commands to do this using the CLI --> Go to your Squeezecenter/Squeezebox Server (http://<squeezecenter_ip>:9000) --> Click Help --> Technical Information --> Command Line Interface</b>

<i><font color="green">Update:</font id="green"> I'm busy looking into this. I will be posting a script tonight or tomorrow.</i>
Edwin2008
Advanced Member
Advanced Member
Posts: 721
Joined: Fri Nov 28, 2008 4:14 pm
Location: Netherlands

[HSSCRIPT] Squeezebox Server Message Display

Post by Edwin2008 »

This is really nice! I love the squeezebox devices!
Jeffrey
Member
Member
Posts: 136
Joined: Tue Jun 09, 2009 3:34 pm
Location: Netherlands

[HSSCRIPT] Squeezebox Server Message Display

Post by Jeffrey »

Short update on the (to-be) Speak script.

I currently have a problem to return to the playing song. Let me explain.

I wanted to disable repeat (if it's on) and then add the announcement audio file to the end of the current playlist. Then let the announcement play and return to the song that was playing.

I can retrieve the trackname of the playing song, but do not see a command to jump back to that song.

The only thing I see is the index possibility, but that doesn't work because the index will change as soon as I jump to the end of the playlist so I don't know what the relative position is to jump back.

Another option is to add the announcement song after the current playing song, that way I can jump +1 position using the index. The disadvantage is that when the announcement is finished the next song will play an I maybe to late to switch it back (timing issue, especially when there are more players and players have to poweron). This can be resolved if I can change the playmode to stop when the announcement is played. I know this is a option, but haven't found a way of setting this using the CLI (yet).

The most simple way of doing all of this is to save the playlist, play the announcement and restore the playlist. The problem with this is that it costs time to save/load the playlist (2 seconds alone to save) as it has to write/read from disk. Therefor this is my last resort if all else fail.

I'm really taking into account that it has to work lightning fast as with much announcements it gets annoying if the announcements proces is to slow. Another side effect is that the announcements can shift between players so you get a "kano" (uhmm..don't know the english term) like echoing effect.

<s>If someone wants to help I have 2 questions:
<b>1. How do I change the playermode that it stops after playing the current playing song?
2. How do I jump to a song in the current playlist based on the tracktitle?</b>

p.s. you can look in the CLI documentation as described earlier to help me find a command</s>

<font color="green">Update:</font id="green"> Found a solution, actually it was easy. It's possible to simulate button presses so I skip back to the original playing file. Unfortunatelly I ran into a performance issue. It turned out that the response from the CLI interface is kind of slow, which messed up the execution of the script. This means I have to include a 300 ms delay before reading the response to make it work. This realllllly slows down things. This is something I have to think about. The good thing is that the whole script is finished ... in theory that is. I just ran into the response issue during initial testing (I first coded the whole script and am now testing it as a whole).
Conclusion: The response issue has to be looked into before I can continue testing. I thought this would be easy, but it's more work than I anticipated. I hope it's worth it in the end. It would be a shame if only snelvuur will use it.

Jeffrey
Edwin2008
Advanced Member
Advanced Member
Posts: 721
Joined: Fri Nov 28, 2008 4:14 pm
Location: Netherlands

[HSSCRIPT] Squeezebox Server Message Display

Post by Edwin2008 »

give me more time in a day and i will try/use it. So many things waiting on the shelf :)
I've been using SB since 2005, that's way before logitech discovered it
Jeffrey
Member
Member
Posts: 136
Joined: Tue Jun 09, 2009 3:34 pm
Location: Netherlands

[HSSCRIPT] Squeezebox Server Message Display

Post by Jeffrey »

The script is finished. However...to keep things organized I made a new topic for it.

You can find it here --> http://www.domoticaforum.eu/topic.asp?TOPIC_ID=3768
Jeffrey
Member
Member
Posts: 136
Joined: Tue Jun 09, 2009 3:34 pm
Location: Netherlands

[HSSCRIPT] Squeezebox Server Message Display

Post by Jeffrey »

I've just posted a new version of the SBMessage script (version 0.2).

The problem I encountered was that when a device is used which does not have a display, the CLI server will not respond if you send the text. This results in a timeout and therefor a error message in the HomeSeer log. I had this problem because I've switched from SoftSqueeze to Squeezeplay and Squeezeplay does not have a display.

The changes are (just copied from the changelog in the script):
0.2 21-10-2009 Bugfixes
- Updated the PrepText4SBCLI Function
- Implemented the extended ReadString function from SBPlay.VB

The latest version is included in the startpost.

<hr noshade size="1">
<font size="1">Why Tailwind? Because Jeffrey was already registered ...</font id="size1">
Jeffrey
Member
Member
Posts: 136
Joined: Tue Jun 09, 2009 3:34 pm
Location: Netherlands

[HSSCRIPT] Squeezebox Server Message Display

Post by Jeffrey »

--- Display the Sunset time uhmm...at sunset ---

Background and problems:
------------------------
Yesterday I was busy with my lighting scene adjusting it for the sunset parameter. Then I thought it would be handy to let the sunset time display on my Squeezebox at that time. So I created an event to do so using the SBMessage.vb script.

The problem however was to give the sunset as parameter to the script. After starting a thread on the homeseer forum and exchanging overly difficult possible solutions with jon (jon00), Jim posted the most simple answer, so I will share it here off course. I you want to view the topic its here --> http://board.homeseer.com/showthread.ph ... post892011

Solution:
---------

Here's the event:
Image

The trick is to start the script from the "OR Script Statement" so an HomeSeer command (in this case: hs.sunset) will get processed.

This is how the action looks like:
Image

<i><b>NOTE:</b> It may look like the screen above is not finished, but it is! Do not select a script at the top as that will result in parameters getting lost.</i>

That's it. It's all so simple if you know the tricks [;)]

<hr noshade size="1">
<font size="1">Why Tailwind? Because Jeffrey was already registered ...</font id="size1">
Post Reply

Return to “Homeseer Scripts Forum”