Start Sonos when door opens... but get a handle on frequency

I have a Reactor sensor set up to start my Sonos when the door opens and when Home Mode = Home. However, there are situations in which I open this door many times within a short period of time. Since I don’t want the music to start each time I open the door, I added a dependency that requires the music to have been stopped (or, not playing) for at least 10 minutes when the door opens for the group to be true.

This doesn’t really do what I want, though. If I open the door every minute for 10 minutes, the music will start on the first and the 10th time. What I really want is for that “timer” to reset each time the door is open. If I open the door every five minutes for an hour (or more), the music should not start after the first time. But if I’ve not opened the door for at least 10 minutes, the music should start.

I added a logic summary, showing some activity from yesterday, when I was going in & out and manually stopped the music once or twice upon entry. What changes do I need to make to support this requirement? Thanks! :+1:t2:

*************************************************** REACTOR LOGIC SUMMARY REPORT ***************************************************
   Version: 3.0 config 301 cdata 19082 ui 19125 pluginDevice 9
    System: Vera version 1.7.1040 on Sercomm NA900; loadtime 1557958062; systemReady 1557958108; Lua 5.1
Local time: 2019-05-16T09:34:36-0400; DST=1
House mode: plugin 1; system 1; tracking on
  Sun data: { "stamp": 2019136, "civdawn": 1558001682, "nautdawn": 1557999847, "sunset": 1558051969, "nautdusk": 1558055338, "latitude": 27.9110297, "astrodusk": 1558057254, "longitude": -82.5219683, "civdusk": 1558053503, "astrodawn": 1557997931, "sunrise": 1558003216 }
  Geofence: running in quick mode, last update 07:38:00, data version 2
            User 2035691 ishome=0 inlist= since=07:38:00
            Raw: { "updated": 1558013640, "users_settings": [ { "id": 2035691, "ishome": 0 } ], "mode": 1 }
====================================================================================================================================
Shed Music (#32)
    Version 19082.1558013520 05/16/19 09:32:00
    Message/status: Not tripped
    Condition group "Mode = H, Shed Music not playing , Shed Door opened" (AND) false as of 19:53:07 <root>
      &-T-housemode in 1 [2 => 1 at 08:41:31; T/T as of 08:41:31/08:41:31] <condcbvr6z9>
      &-T-service Sonos - Shed (29) urn:upnp-org:serviceId:AVTransport/TransportState <> PLAYING for ge 600s [paused_playback => stopped at 20:54:27; T/T as of 19:54:27/09:06:06] <condcbwwws8>
      &-F-service Shed Door (12) urn:micasaverde-com:serviceId:SecuritySensor1/Tripped = 1 after condcbwwws8 [1 => 0 at 19:58:53; F/F as of 19:58:53/19:53:07] <condcbvrluh>
    Activity root.true
        Device 29 (Sonos - Shed) action urn:micasaverde-com:serviceId:Sonos1/PlayURI( URIToPlay=SF:Chris Stapleton Radio, Volume=40 )
    Events
        05/15/19 18:07:53 start: 
        05/15/19 18:09:18 devicewatch: device=29, old="PLAYING", name=Sonos - Shed, var=urn:upnp-org:serviceId:AVTransport/TransportState, new="STOPPED"
        05/15/19 18:09:19 condchange: newState=true, cond=condcbwwws8, oldState=false
        05/15/19 18:19:19 evalchange: newState=true, cond=condcbwwws8, oldState=false
        05/15/19 19:53:04 devicewatch: device=12, old="0", name=Shed Door, var=urn:micasaverde-com:serviceId:SecuritySensor1/Tripped, new="1"
        05/15/19 19:53:05 condchange: newState=true, cond=condcbvrluh, oldState=false
        05/15/19 19:53:05 evalchange: newState=true, cond=condcbvrluh, oldState=false
        05/15/19 19:53:05 condchange: newState=true, cond=root, oldState=false
        05/15/19 19:53:05 evalchange: newState=true, cond=root, oldState=false
        05/15/19 19:53:05 sensorstate: state=true
        05/15/19 19:53:05 startscene: scene=root.true, sceneName=tripactions
        05/15/19 19:53:05 runscene: scene=root.true, sceneName=tripactions, group=1, notice=Starting scene group 1
        05/15/19 19:53:06 devicewatch: device=29, old="STOPPED", name=Sonos - Shed, var=urn:upnp-org:serviceId:AVTransport/TransportState, new="TRANSITIONING"
        05/15/19 19:53:06 endscene: scene=root.true, sceneName=tripactions
        05/15/19 19:53:06 devicewatch: device=12, old="1", name=Shed Door, var=urn:micasaverde-com:serviceId:SecuritySensor1/Tripped, new="0"
        05/15/19 19:53:07 condchange: newState=false, cond=condcbvrluh, oldState=true
        05/15/19 19:53:07 evalchange: newState=false, cond=condcbvrluh, oldState=true
        05/15/19 19:53:07 condchange: newState=false, cond=root, oldState=true
        05/15/19 19:53:07 evalchange: newState=false, cond=root, oldState=true
        05/15/19 19:53:07 sensorstate: state=false
        05/15/19 19:53:11 devicewatch: device=29, old="TRANSITIONING", name=Sonos - Shed, var=urn:upnp-org:serviceId:AVTransport/TransportState, new="PLAYING"
        05/15/19 19:53:12 condchange: newState=false, cond=condcbwwws8, oldState=true
        05/15/19 19:53:12 evalchange: newState=false, cond=condcbwwws8, oldState=true
        05/15/19 19:53:48 devicewatch: device=12, old="0", name=Shed Door, var=urn:micasaverde-com:serviceId:SecuritySensor1/Tripped, new="1"
        05/15/19 19:53:49 condchange: newState=true, cond=condcbvrluh, oldState=false
        05/15/19 19:54:16 devicewatch: device=12, old="1", name=Shed Door, var=urn:micasaverde-com:serviceId:SecuritySensor1/Tripped, new="0"
        05/15/19 19:54:17 condchange: newState=false, cond=condcbvrluh, oldState=true
        05/15/19 19:54:26 devicewatch: device=29, old="PLAYING", name=Sonos - Shed, var=urn:upnp-org:serviceId:AVTransport/TransportState, new="PAUSED_PLAYBACK"
        05/15/19 19:54:27 condchange: newState=true, cond=condcbwwws8, oldState=false
        05/15/19 19:58:26 devicewatch: device=12, old="0", name=Shed Door, var=urn:micasaverde-com:serviceId:SecuritySensor1/Tripped, new="1"
        05/15/19 19:58:27 condchange: newState=true, cond=condcbvrluh, oldState=false
        05/15/19 19:58:52 devicewatch: device=12, old="1", name=Shed Door, var=urn:micasaverde-com:serviceId:SecuritySensor1/Tripped, new="0"
        05/15/19 19:58:53 condchange: newState=false, cond=condcbvrluh, oldState=true
        05/15/19 20:04:27 evalchange: newState=true, cond=condcbwwws8, oldState=false
        05/15/19 20:54:26 devicewatch: device=29, old="PAUSED_PLAYBACK", name=Sonos - Shed, var=urn:upnp-org:serviceId:AVTransport/TransportState, new="STOPPED"
        05/16/19 07:37:43 devicewatch: name=Reactor, var=HouseMode, device=9
        05/16/19 07:37:44 condchange: newState=false, cond=condcbvr6z9, oldState=true
        05/16/19 07:37:44 evalchange: newState=false, cond=condcbvr6z9, oldState=true
        05/16/19 08:41:30 devicewatch: name=Reactor, var=HouseMode, device=9
        05/16/19 08:41:31 condchange: newState=true, cond=condcbvr6z9, oldState=false
        05/16/19 08:41:31 evalchange: newState=true, cond=condcbvr6z9, oldState=false
        05/16/19 09:00:29 configchange: 
        05/16/19 09:00:30 evalchange: newState=false, cond=condcbwwws8, oldState=true
        05/16/19 09:01:07 configchange: 
        05/16/19 09:06:05 configchange: 
        05/16/19 09:06:06 evalchange: newState=true, cond=condcbwwws8, oldState=false
        05/16/19 09:31:56 configchange: 

Then the timer (sustained for) needs to go on the door sensor condition, not the Sonos.

Would that not require the door to be left open for 10 minutes for that condition to be true? I don’t leave the door open when I enter.

I am doing a lot of similar things without reactor but just using lua code. What I do is I run a conditional on the sonos start scene with a check on current time - the last trip variable of the sensor… pretty simple.

Yes. But in looking at your original explanation, why not just do an AND group: if the door is opened and music is not playing, start it playing. Subsequent openings of the door will have no effect because music is already playing.

[quote=“rigpapa”]
Yes. But in looking at your original explanation, why not just do an AND group: if the door is opened and music is not playing, start it playing. Subsequent openings of the door will have no effect because music is already playing.[/quote]
The bolded text is why I originally put the “not playing” condition in place; when I opened the door while the music was playing, it would restart the music channel, interrupt the song, and start a new one. That was annoying.

What I want is to set the time between door openings that starts the music. With the configuration above, music starts based on the time since the music last stopped… and the door is opened.

I would try it again. It should work as I described. No timer needed. From what you showed in the logic summary, just remove the sustain on the Sonos. Watch the Status tab carefully while experimenting, make sure everything is in a known state.

I’ll give it a try, thanks.

I really do appreciate having the current state right on the condition add/edit screen.

By the way, Sonos has an interim playing state that you should count as playing: TRANSITIONING. To test both, you could use the NOT IN operator with “TRANSITIONING,PLAYING” as the value in your not-playing condition.

Interesting. I saw that state in the log, but I didn’t know what it meant (and still don’t).

It’s a UPnP thing. I imagine it’s meant to reflect the status when the player has been directed to play but the media is loading… tape or CD autochanger, etc. I see it in my system for most media I play, which is network-based.