Reducing SmartApp latency

Hi all,

Something similar was also asked here, but there was no answer:

I recently purchased a Smart Things Hub and was setting it up at home. I wanted a doorbell sound to play via my Sonos when a button was pressed (using the Iris Smart Button).

It all works fine using the Speaker Companion app, however I noticed the latency is quite bad from when the button is pressed to when the Sonos plays the sound (4-5 seconds or more). However, looking in the Smart Things app, I see the button press registered almost instantly. Therefore the latency must be somewhere within the SmartApp calls, however where exactly I have no idea :slight_smile:

-how would I go about seeing where the latency is? eg. all the network requests that happen to make the sound play and the time each takes.
-would creating a Smart App that accesses a sound file on the local network help with latency? or does the Hub cache any binary files it fetches over the network anyway?
-how is playback on Sonos actually accomplished? does this also route via the cloud or does it send playback locally to the device?



I’m sure that’s very frustrating. :disappointed_relieved: That’s a lot of different questions, but the first thing to note is that in the last week or so a number of community members have reported latency problems:

So it could be that you’re just caught up in that.

As far as Sonos, the cloud is always involved in that.

Here’s the FAQ on reading the Logs, which you may find interesting anyway, but again I’m not sure they’re going to apply in this case as the problem may be in the cloud.

1 Like

Thanks for the response and the pointers, very helpful for someone like me just getting started.

FWIW, I did a bunch of experimentation tonight and it appears the largest chunk of latency is fetching the MP3 file from AWS. I’m guessing it always has to do the network request and does not do any local caching of the MP3 file (after all, how can it know if the file needs to be fresh each time).

What I did was host a bunch of MP3 files locally on my own home server, and then create a copy of the Speaker Notify SmartApp from github and modify the MP3 links to point to my local server.

This actually works fine because Sonos is passed this URL and it can access the local network without issue (vs a SmartApp which can’t get to the local network).

After that, the latency is down to ~1 second which is very workable :+1: :smiley:

As a side note, it would be nice if the SmartApp APIs for network requests could somehow route to the hub and make a local network request instead of only being able to connect to public hosts. That would make it a lot more flexible for accessing local resources and avoid network requests.