Event source in new SmartThings app

Hi guys,

I’m trying to get the event source in a smart app to see if it’s made by a user manually triggering something, or from the smart app.

I’m subscribing as follows:

subscribe(s, "switch", manualSwitchHandler)

I’m then trying to figure out from info held in the evt object. The old SmartThings doco indicates evt.source should do the trick, but it only ever contains DEVICE.

def manualSwitchHandler(evt) {
    log.info "SRC: ${evt.source}, DESC: ${evt.description}, DESCT: ${evt.descriptionText}, SA: ${evt.installedSmartAppId}, DIG: ${evt.isDigital()}, PHY: ${evt.isPhysical()}"
}

Is this possible in the new ST app?

Thanks, James.

That is because the events you are subscribing to are DEVICE events. There are plenty of other types events around, some of which used to appear in the event history, like APP_COMMAND, though I suspect they might not appear any more as there have been a lot of changes lately.

The sort of thing you are after sounds like the evt.isPhysical() v evt.isDigital(). I’m not sure of the state of play with these, be they withdrawn, unsupported, deprecated or what. The bottom line was that they could not be relied upon in general.

1 Like

They stopped including digital versus physical information about three years ago, at least for Z wave devices, because if the message went through a repeater it was not always reported correctly.

Switch Events Stopped Working, Help?

One way to do it is to create a virtual device that triggers the physical device And then only have app users use the virtual device.

1 Like

Thanks - this doesn’t work for what I’m after. It looks like a lot of functionality has been removed from ST of late.

I appreciate the responses, all. Thanks.

I’m not sure I would consider August 2017 “of late”.

1 Like

It’s not just that feature - it’s a compound of things. At this point I’m surprised that there is switch.on and switch.off capability remaining.

The route I’m going down is to create a map in atomicState and stick the deviceId in there each time the app triggers an event. Then, in the method handling the event I’ll check if the triggering deviceId is in the map and remove it if it is. This will indicate that the app triggered the event. If the deviceId isn’t in the map then it indicates the event has been triggered by something outside of the app.

It’s annoying, and I’d expect that it won’t be 100% perfect (you can’t do any locking, for example, to make sure timings are correct and that events don’t slip in at the wrong time) but I’m hoping it will be good enough.