Mode Change Subscription Help


(Jon) #1

I have run into a bit of a roadblock when trying to solve some mode issues that it appears others are having on here as well. (I didn’t want to hijack someone else’s thread so I made a new one).

Basically I have four modes that I think will provide for everything I need on a daily basis (excluding a “party” mode or something that wouldn’t be a regular occurrence).

4 modes - Day Home, Day Away, Night Home and Night Away

So I have scheduled based on the sunrise-sunset app changes to modes such as at night it would change to “Night Home”, BUT if I am not there I would like for when a mode is change to “Night Home” that it looks to see if any presence sensors are at home, and then it could do some actions, or if you arent home, make sure that the porch lights are on etc.

Same goes for day and day away.

People have had issues with the sunrise/sunset app (myself included) which is ok, for the time being I would just schedule a time that is year-round a good time I would call “night” ex 8 pm. BUT I would still like for when the mode gets changed to check to see if anyone is home etc.

I know I need to subscribe somehow to the changing of the modes, but Im kind of a newbie to this and haven’t found anywhere that I can reference to start building from.

Also I know this could be complicated by incorporating the presence changing of someone arriving home and changing the mode to “day home” or" night home" but I kind of would like to create an all in one solution.

Thanks for all the help.


(Jon) #2

So is there no way to “subscribe” to a mode change?


(Brian Steere) #3

@jhh87 It is possible. You can see it in this app: https://github.com/smartthings-users/smartapp.security-night-light/blob/master/security-night-light.smartapp.groovy

Specifically
subscribe(location)

and

def changedLocationMode(evt) {
    log.debug "Mode: ${location.currentMode}"
    if(location.currentMode == startMode) {
        modeStartThings()
    }
    else if(state.modeStarted) {
        modeStopThings()
    }
    else if(state.motionStarted) {
        motionStopThings()
    }
}