Trigger on mode change

I have been searching but I couldn’t find anything.

I found “changeMode” which seems to tigger based on any mode change but I am trying to trigger two different actions based on two different modes ( home and away)

Can this be done?

Thanks!

I too am wondering if this is possible? I am developing an app that would basically interact with my AirVision camera system to change the recording mode of the system based on the state of the SmartThings location. I have built the app today to use presence sensors (and plan to use time based as well), but it would be much simpler if I could simply subscribe to mode changes and trigger my AirVision interaction based on that.

Sure, you subscribe to mode change events like so:

subscribe(location, modeChangeHandler)

Then in your modeChangeHandler, you can check which mode is being switched to like so:

def modeChangeHandler(evt) {
    if (evt.value == "Home")
    {
	// Do stuff you want when mode changes to "Home"
    }
}

That solution worked like a charm! Thanks for the pointer!

Well spoke too soon. It works, however it gets triggered twice for each mode change, once for the old mode and once for the new mode. Any thoughts on how to only trigger once with the new mode value?

Thanks,

And spoke too soon once again, the duplicates were caused by the fact I had the app installed on my smart phone as well as the simulator. Learned something new there, always uninstall from the simulator when testing via the app!

There is also an issue, either in the docs or the ST core: