Bose SoundTouch

With my Vera hub, I am able to make my Bose SoundTouch speakers play pre-recorded mp3 files from my NAS, using their http api. I had to write some lua code to make this happen. How can I do this in Hubitat?

Do you have a link to their API? Is it just an HTTP GET request?

A simple driver could be written based on that information. Depending on their api there might be a good starting point vs writing it from scratch.

https://developer.bose.com/

I had to create an account to get access. Looking at the docs, the “select” is a post. Thanks for looking into this! I have 3 speakers and eventually want to have the mp3 played on all 3. There was a person on the Bose forum that suggested I try this when I posted a question about notifications from my home automation hub.

Here is the lua code that I wrote…it’s not real user friendly, as I had to run a “now_playing” command to see the response when I played the file via the Bose app to get the ContentItem to play, but at least it works to notify us when the doors are opened.

local request_body = ‘’
local http = require(‘socket.http’)
http.TIMEOUT = 5
local result, status = http.request(“http://xxxx:8090/select”, request_body)

def request_body = ""    
httpPost("http://xxxx:8090/select", request_body) resp ->
        log.debug "data: ${resp.data}"
        log.debug "contentType: ${resp.contentType}"
    }

This would be the actual code to send the http Post to that URL and handling the response. Would need to wrap that into a driver and something to trigger it. Like a custom command or a switch capability. This code hasn’t been tested, so use at own risk…

Not sure where your at with driver development. We are working on providing some template / simple drivers to start from.

Let me know if this is enough to get you started, or if you are looking for a more robust example of a full driver?

Part of my post got cut off, I guess from the XML…in the request body should be (substitute parenthesis for gt/lt):

(ContentItem source=“STORED_MUSIC” sourceAccount=“xxx” location=“1$@1072 TRACK”)(/ContentItem)

So, would the XML go between the double quotes?

I noticed that Bose also has a new notification API, but it requires a URL to a file to play. This might be a good opportunity to integrate once you get TTS working. It’s not clear to me if I could use that to play files on my PC, I don’t have a web server running. Possibly the NAS can serve up files via http? Something for me to investigate, but any words of wisdom would be great :slight_smile:

I’ve never done a device driver, when I had a SmartThings hub I copied a few apps and changed them and that was the extent of my programming. If you have a device driver template that would be a good start. Also I would need to know how using a custom command to interface with the device driver would work, if you can point me to some examples or something.

Does it specifically need a http URL or could you call a network share directly via SMB or NFS?

I don’t think so.

Here is an example they show in the docs:

curl -d \ “<play_info><app_key>your_app_key_here</app_key><url>http://www.example.com/notification.mp3</url><service>service text</service><reason>reason text</reason><message>message text</message><volume>25</volume></play_info>” http://[SoundTouch product LAN IP Address]:8090/speaker

For the URL parameter, the docs say:

Element. A fully qualified, web hosted stream URL. The URL should include the ‘http://’ prefix as well as a stream suffix (‘mp3’, …) for proper playback.

If you have a nas, it’s usually pretty simple to set it up as a http host, depending on your nas and if it’s got apps. If you’re just locally hosting mp3s, it’s not a lot of overhead.

Thank you for the info! I set up a web server on the NAS, put one of my notification mp3’s on there, and using RESTClient extension on Firefox, sent the notification request to the SoundTouch 10, and it worked!!

Now the fun part is to get this functionality working in Hubitat :).

3 Likes

Has anyone gotten their Bose SoundTouch connected to hubitat?

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.