Got the Bose SoundTouch 10 to do announcements

It’s kind of clunky, but it works for what I need…thought I would post for others that may want to give it a try.

Currently the Bose API doesn’t allow for you to send it a file to play, hope it may in the future. But you can set 6 presets via the Bose app (which BTW has a Windows version, yay!) and the preset can be a file, playlist, etc. I created mp3 files to announce “front door”, “back door”, “garage door” and “patio door” and set each one to a preset in the Bose app. I used the “music library on computer” option for the music service.

Then I created a scene per sensor for when the sensor reports open, and put the following lua code in the scene:

local request_body = ‘<?xml version=\'1.0\' ?><key state="press" sender="Gabbo">PRESET_1’
local http = require(‘socket.http’)
http.TIMEOUT = 5
local result, status = http.request(“http://bose_ip:8090/key”, request_body)
request_body = ‘<?xml version=\'1.0\' ?><key state="release" sender="Gabbo">PRESET_1’
result, status = http.request(“http://bose_ip:8090/key”, request_body)
return true

You would put this code (substitute your bose_ip in the code) in your desired scenes and just change the PRESET_1 to the proper preset number for the announcement you want to play.

Improvements/additions would be greatly appreciated! I noticed during testing that if I am already playing music and then the announcement comes in, the music doesn’t restart, so eventually I will see if I can save off the currently playing music and start it back up again.

this works great! thanks! my first lua code, haha. also got it to turn off by replacing PRESET_1 with POWER

this solution has been working fine for months (using Power cmd to use as an alarm clock in vera), but has stoped working overnight. Has Bose changed APIs??

Thanks for the code above.
Used this as a starting point and managed to get my 4 x Soundtouch devices to do multiiroom play as part of a VERA scene

Is there a way to have TTS for Bose using LUA codes or other means?