Highlighted
Strident Supporter
  • 48
  • 51
  • 3
Registered since

Oct 6, 2016

Re: HOWTO: Make your own SoundTouch sleep timer and alarm clock with IFTTT and Microsoft Flow

I just tried to make my own IFTTT recipie but unfortunately the IFTTT Maker channel doesn't allow you to send XML requests, only JSON or form data 😞

 

Not sure if @JasonG reads this - I wonder if its possible to contact the devs to find out if there is a way to get the Bose to understand HTTP POST requests in form or JSON format..probably not. But it would be quite trivial to tweak to allow the receival of form data in the format:

 

xml=<my_xml_command><member= "abc123" ipaddress=123></member></my_xml_command>

 

This would easily open up the speakers to integration with everything via IFTTT. Please make it happen! 🙂

 

Update: Wooo I made it happen! I realised you CAN get the IFTTT Maker channel to send XML if you format it like a crazy person and escape everything with lots of additional brackets. I just made a recipe that takes a Logitech POP button and allows me to simply press the physical button to turn on "Play All"! I will try and document it for people this weekend but in theory you can do tons of cool stuff..like turn on Bose when your Nest home device realises you're home etc.

Highlighted
Wistful Whiz
  • 179
  • 232
  • 21
Registered since

Jan 9, 2016

Re: HOWTO: Make your own SoundTouch sleep timer and alarm clock with IFTTT and Microsoft Flow

@TimDonovan Can you share how you escaped the XML so that IFTTT likes it? 

 

Basically I initially intended only to use IFTTT in my solution, but I ended up using Microsoft Flow in my solution for two reasons - 1) IFTTT's Maker channel not playing nice with XML, and 2) IFTTT's inability to do two actions (like two maker channel executions) sequentially from a single triggering event, whereas MS Flow can do that - for button presses, the SoundTouch API requires two distinct actions (i.e. press the button and release it as separate API calls) so IFTTT won't work by itself for that.  If you know how to escape the XML so that IFTTT likes it, however, I could at least get past limitation 1.

Highlighted
Strident Supporter
  • 48
  • 51
  • 3
Registered since

Oct 6, 2016

Re: HOWTO: Make your own SoundTouch sleep timer and alarm clock with IFTTT and Microsoft Flow

Hi - sorry I didn't get chance to document over the weekend. My findings below:

 

1) Most importantly, how to escape in IFTTT. So each '<' and '>' in your XML has to be escaped using the Maker escape marks of <<< and >>>. This looks a little confusing but here are some example:

 

Set your speakers to "Play All":

<<<<>>>zone master='ABC123'<<<>>>><<<<>>>member ipaddress='192.168.1.2'<<<>>>>ABC123<<<<>>>/member<<<>>>><<<<>>>member ipaddress='192.168.1.3'<<<>>>>ZXF567<<<<>>>/member<<<>>>><<<<>>>/zone<<<>>>>

 

Switch a speaker off:

<<<<>>>key state="press" sender="Gabbo"<<<>>>>POWER<<<<>>>/key<<<>>>>

 

I set the content type to text/plain. Here is a screenshot:

 

 

2) Button presses don't seem to need the release command send, meaning only one command is necessary (such as above). However I seem to recall that getting the Bose to switch to a preset required sending the key state = release but sending power requred key state = press. Not 100% sure about that though. 

 

3) I now have a physical button (Logitech POP) where 1 press sends the "Play All" command. A second press will switch all my Boses off - this is possible because I use the same Bose as the audio sauce to all slaves, and send the power off command also to this same Bose. It seems all slave Boses switch off when the master is powered off too. 

 

Very happy with the solution - Bose should have included a "play all" button on their remotes but at least I no longer have to fiddle about within an app!

Highlighted
Strident Supporter
  • 48
  • 51
  • 3
Registered since

Oct 6, 2016

Re: HOWTO: Make your own SoundTouch sleep timer and alarm clock with IFTTT and Microsoft Flow

Oh, and on the topic of IFTTT triggering multiple actions - yep this is the massive limitation in IFTTT. HOWEVER this is changing this year - they are finally allowing multiple actions. However you need to pitch to them why, as access to this is limited at first:

 

https://www.cnet.com/uk/news/your-ifttt-recipes-are-about-to-change/

 

...I have already pitched a Bose channel to them Man Happy

Highlighted
Wistful Whiz
  • 179
  • 232
  • 21
Registered since

Jan 9, 2016

Re: HOWTO: Make your own SoundTouch sleep timer and alarm clock with IFTTT and Microsoft Flow

Thanks for the info on escaping XML at IFTTT, Tim, I will give it a try in the next day or two.  I'm also aware of IFTTT's forthcoming beta of their feature to allow multiple actions in an applet and have signed up to their waiting list, but so far no news on it.

 

Oh, and as far as button pressing and releasing via the API are concerned, I know for sure that if something is playing on the speaker and you "press" a preset button without a "release" within a second or so, then your preset gets reprogrammed.  As for other buttons I'm not sure as I haven't tried, but I suspect that if, for instance, you "press" the volume up button without a "release" you'll soon find your speaker at full blast.

Highlighted
Audible Advocate
  • 2
  • 3
  • 0
Registered since

Dec 26, 2016

Re: HOWTO: Make your own SoundTouch sleep timer and alarm clock with IFTTT and Microsoft Flow

Marty - that was great information.  I've got my Bose speaker in the bedroom waking me up every morning.  Is it possible to have another speaker added (the kitchen) or a "play all" script?

Highlighted
Wistful Whiz
  • 179
  • 232
  • 21
Registered since

Jan 9, 2016

Re: HOWTO: Make your own SoundTouch sleep timer and alarm clock with IFTTT and Microsoft Flow

bb98 - yes, it should be possible to basically fire off a "play everywhere" command (or just play on more than one speaker but not necessarily all of them) at the end of the alarm clock.  I'll try to put some instructions together for how to do that and post them soon.

Highlighted
Wistful Whiz
  • 179
  • 232
  • 21
Registered since

Jan 9, 2016

Re: HOWTO: Make your own SoundTouch sleep timer and alarm clock with IFTTT and Microsoft Flow

bb98 - So I went through and modified my Alarm Clock flow in Microsoft Flow to do this.  Basically, you add one step to the end of the Alarm Clock flow as I've documented it in the first or second post in this thread.

 

First, you need to gather the MAC addresses of all your speakers.  Do that by going in to the "About" section of the Bose app, then open the page for each speaker and write down its MAC address - note - for most SoundTouch speakers, two MAC addresses will be displayed, we want the first one.

 

Now, go in to your Alarm Clock flow in MS Flow and edit it.  Click on the "New Step" button at the bottom of the flow and then select "HTTP" from the available flow types.  This step will have a bunch of fields we need to fill in:

 

Method: choose POST from the drop down

 

URL: basically the URL of the speaker you're already using for the alarm, with /setZone at the end - example, http://marty.hopto.org:11220/setZone 

 

Headers:  Just set it to this:  { "Content-Type": "application/xml" }

 

Body:  This is where it gets a little tricky, but here's an example of what to put:

 

<zone master="11AA11AA11AA" senderIPAddress="127.0.0.1"> <member>22BB22BB22BB</member> <member>33CC33CC33CC</member> <member>11AA11AA11AA</member> </zone>

 

Basically, here I am assuming I have three speakers, with MAC addresses 11:AA:11:AA:11:AA, 22:BB:22:BB:22:BB and 33:CC:33:CC:33:CC  

 

Note that I remove the colons from the MAC addresses.

 

 

 

Basically in this case I am assuming that the Alarm Clock flow is already set up to start playing a preset on the first speaker, MAC address 11:AA:11:AA:11:AA, so I will make that preset my "master" since I want my other speakers to play what the first speaker will be playing.  In your case, use the MAC address for the master of whichever speaker you are already using for the alarm clock.  So that's why I use the first speaker's MAC address in this part:  <zone master="11AA11AA11AA" senderIPAddress="127.0.0.1">

 

Then, you'll notice that I am repeating this bit a few times:  <member>22BB22BB22BB</member>

 

Each time, I use the MAC address of one of the speakers that I want to play.  If you want to play the alarm on all your speakers, repeat this bit once for each of them.  If you only want to play on some of your speakers, only do this for the ones you want the alarm to play on.  Note that you must always include the master speaker here, even though its the master.   

 

And that's about it. Here is what it looks like, and here is what the overall flow looks like.  After this, you can save your flow and test it out.  Feel free to let me know if you run in to any issues and I'll do my best to help.

 

 

 

Audible Advocate
  • 2
  • 3
  • 0
Registered since

Dec 26, 2016

Re: HOWTO: Make your own SoundTouch sleep timer and alarm clock with IFTTT and Microsoft Flow

Hi Marty,

 

Thanks for the instructions on how to make the alarm trigger and play on multiple speakers.  I have been able to enhance the basic configuration by having the speaker come on at a low volume, delay a few minutes and increase the volume, delay a few more minutes and increase the volume and start playing in the den and kitchen.  Starting to act like a intelligient, home automated applicance! 

Thanks again for your help and clear, concise instructions.

 

Bob

Highlighted
Animated Arbiter
  • 29
  • 56
  • 1
Registered since

Mar 16, 2017

Re: HOWTO: Make your own SoundTouch sleep timer and alarm clock with IFTTT and Microsoft Flow

I've used a Raspberry Pi I have connected to my network doing other stuff to act as the alarm clock for my Bose SoundTouch speakers - the following simple BASH script is launched at a given time by a CRON job. I know this is a bit techy for some but until Bose can come up with a "proper" solution (come on Bose, just how hard is it?) this might be of some use to you.

 

#!/bin/bash
# Script to turn on the SoundTouch speaker

# Run this with ./stWake.sh your.speaker.ip.address 25 .2

# where 25 is the target volume and .2 is the delay
# Set volume to level 1 (don't want to deafen anyone)
# Set to play BBC Radio 5 Live
# Increase the volume in steps of 3 up to 25
if [ "$1" = "" ]; then
echo "parameter1 is device IP address minus the port number"
echo "parameter2 is target volume level between 1 and 100 - 100 is VERY LOUD"
echo "parameter3 is the time value for the volume ramp up"
exit
fi
if [ "$2" = "" ]; then
echo "parameter2 is target volume"
exit
fi
if [ "$3" = "" ]; then
echo "Parameter3 is the time value"
exit
fi

echo "IP Address is $1"
echo "Target Volume is $2"
echo " Rampup value is $3"

#SoundTouch is listening on port 8090
host=$1:8090
targetvol=$2
rampup=$3
vol=0
#Set the volume to level 1 (just in case someone left it on loud!)
curl --request POST --header "Content-Type: application/xml" --data ' <volume>1</volume> ' $host/volume
#Send command to play a specific station (my choice is BBC Radio 5 live) You can find out the relevant details about your favourite station
#playing it through the speaker and then browsing to http://your.speaker.ip.addtess:8090/now_playing - the details will be displayed in your browser
#simply replace the location and itemName data in the line below
curl --request POST --header "Content-Type: application/xml" --data ' <ContentItem source="INTERNET_RADIO" sourceAccount="" location="76505"> <itemName>BBC Radio 5 Live - UK Only</itemName></ContentItem> ' $host/select
#Sleep to allow the speaker to connect
sleep 2
#the following loop takes the last two parameters and slowly ramps up the volume to your desired level (parameter 2)
#the delay is parameter 3 which can be a whole number or a fraction as .5 or .2 - the smaller the number the quicker the volume ramps up.
until [ $vol -ge $targetvol ]; do
let vol+=1
curl --request POST --header "Content-Type: application/xml" --data " <volume>$vol</volume> " $host/volume
sleep $rampup
echo volume $vol
done

 

If you want to choose your own station (and why not?) comments in the script above will tell you how to do this.

 

If you want to turn it off then the following script will do it

#!/bin/bash
#Parameter 1 is the IP address of your speaker

# Run this with ./stShutdown.sh your.speaker.ip.address
if [ "$1" = "" ]; then
echo "Parameter1 is the IP address of your speaker"
exit
fi
host=$1:8090
curl --request POST --header "Content-Type: application/xml" --data ' <key state="press" sender="Gabbo">POWER</key> ' http://$host/key