Trigger on mode change

(Jim) #1

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?


(Bmayer01) #2

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.

(Steve S) #3

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"

Trigger actions on mode change
(Bmayer01) #4

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

(Bmayer01) #5

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?


(Bmayer01) #6

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!

(Tony Gutierrez) #8

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