Sonos Lock Smart App with Delay


There are a few default SmartApps out there for Sonos, but for some reason the trigger for Lock is not included. Is there any reason for this?

I’d like to have the ability to see a lock being unopened to trigger my Sonos; however since the Lock could be unlocked any time up to 60 seconds before actually opening the door; I’d like there to be a default delay before the action is carried out.

For example: Unlock Door, Wait 10 seconds (or even wait until door is relocked); Play TTS message ‘Welcome Home’, Play Music.

Getting even more advanced; I’d like to be able to determine which code ‘slot’ was used to unlock the door to play personalised messages; i.e. ‘Welcome Home Mike’ if it was my code that was entered; or a generic message if I just used my phone widget to directly open the door.

Thoughts / discussion welcome :smile:

Quick follow up as I took the plunge and started to try coding a new SmartApp; I managed to add a new Preference so that it would also work on the lock.

Now I think I’ve worked out why the functionality doesn’t exist by default…

  1. If the door is unlocked, how does it know that it was unlocked from outside - coming in or from inside - going out?

  2. If the door is unlocked from outside, you may want to put a delay on the notification message playing to allow time for the person to get in the door

  3. You could try to work around 2 by basing it on the door being locked but you run into the same challenge as 1

This needs a bit more thought I think; but good to know it’s possible technically…It needs some kind of combination with presence / motion sensor (or just relying completely on motion sensor) but I have 2 dogs to work around, hence why I was trying to get it working based on lock; and the presence sensors seem to be massively malfunctioning at the moment!

Any ideas though; please chime in :smile:

Can you base it on the mode of the house?

For example if the house is set to away and the door is locked : when you unlock then your unlock routine can occur

If the house isn’t set to away and the door is just locked then unlocking it won’t trigger your routine?

What type of lock do you have ? I am fairly certain that the enhanced Sclage lock control app has the ability to trigger events depending which code is used. I know it was discussed. Not sure

Thanks for the suggestion @Foosh; I did have a similar idea but just need to figure out how best to change the mode of the house.

If the Presence Sensors were actually working then this would probably be perfect; would probably check for a recent change in presence state for each of the sensors (and phones) to determine who has left/arrived and change status.

I’ll give this some more thought; but can’t really implement it until the bugs in the detectors are all fixed :frowning:

@RLDreams I have a Yale Smart Connected Lock; I’ll take a look at that thread and report back :slight_smile: Thanks