I’m looking to play a sound through my sonos speakers when my ecolink door/window sensors are tripped. Any help will be appreciated. I’d even be willing to learn how to turn a light on when it’s tripped. All I can figure out now is to send me a notification when it’s tripped. I’m looking for a little more control from it.
Am I missing something obvious?
There’s a simple way to have Sonos announce an event. Just create a scene with a trigger from your door sensor. Don’t set any actions using the scene GUI but add this code on the LUUP tab:
local dID = 123 -- Device ID of Sonos
local sayText = "Door opened." -- Required announcement
luup.call_action("urn:micasaverde-com:serviceId:Sonos1","Say",{Text=sayText, Language="en", Volume=50},dID)
You could use a similar process to play a sound using the Alert action. I have not tried this but the template for the action is:
luup.call_action("urn:micasaverde-com:serviceId:Sonos1","Alert",{URI= ,Volume= ,SameVolumeForAll= ,Duration= ,GroupDevices= ,GroupZones= },dID)
Thank you! I will try this out this afternoon! question about the code…
Option 1. Line 3. - Where it says “serviceId:Sonos1” is that telling it the model of speaker? I have a playbar, and play 3. So would I put “serviceId:Sonos3”?
Option 2. Do I need lines 1 + 2 from above in place along with the line provided?
I would like to try both and see how they work.
The service ID urn:micasaverde-com:serviceId:Sonos1 covers all types of Sonos units. Do not change it.
Lines 1 & 2 define variables that are used in line 3. You need all three lines - unless you hard-code the device ID and announcement text as in:
luup.call_action("urn:micasaverde-com:serviceId:Sonos1","Say",{Text="Door opened.", Language="en", Volume=50},123)