Hi All,
I am trying to keep a set of switches in the same on/off state. In order to do that, I need to not act on events that come from my own app or else suffer from an infinite loop storm of on/off events… I’m betting someone out there has a simple way to do this.
if( !evt.installedSmartAppId || evt.installedSmartAppId != app.id){
//do this thing
}
This should effectively say if the app that sent the command does not equal this apps ID then continue on… If the ID that sent the command is the same as the current App’s ID then don’t. But it also checks to see if there is an app ID passed with the evt… incase this comes from the physical switch or something like that.
I haven’t tested this, so it may not work as I expect but on paper the logic seems sound.
Thanks Tim. I saw the Event.installedSmartAppId field but it always seems to be null. Further the documentation says the signature is actually String installedSmartApp. Mistake??
Event.installedSmartApp however seems to always have the name of the app (not the GUID) no matter where the event came from… I get the feeling there are a few bugs in the API here.
So I tried an unsubscribe/subscribe work around, but it did not work. The true order of operations is still such that the events from the app’s own .on() and .off() commands are still being received.
For now I am just doing evt.isPhysical() until the API’s app.id detection is working properly. I hope an ST developer sees this and throws it on the tail end of a backlog for me.
tgauchat
(ActionTiles.com co-founder Terry @ActionTiles; GitHub: @cosmicpuppy)
9
I guess I should simulate this to try to understand. I know that SmartThings spins up multiple threads for each callback, so they really need to provide some more real-time sync options (semaphores, queues) to facilitate these complex scenarios.
Thanks for the discussion here, I have been looking for the same answer. I made some progress and figured a write up needed a new thread as this one seems pretty stale. Please take a look at what I have found here as it may help you: