Inter App Communication

Is it possible for 2 smart apps, installed on the same system, to communicate with each other? I know that they can expose a web service and have another app contact the web service endpoint, but is there something else? I was wondering whether I could create a device handler that has no physical device underneath (a virtual device) whose only purpose is to serve as a pipe between 2 smartapps?

Yes, this is possible using a device type in between. Just subscribe to both.

Just curious why you might need to do this?

Thanks. I am just studying the SmartApps model for some research I am working on. Other IoT platforms have some form of inter-app communication (e.g. ISY has state variables) and I was curious about what SmartApps support.

Yeah, hub or location based variables has been on my wish list for a long time. Many ways to accomplish this, either via web endpoints or a virtual device.

Frankly both give you practically unlimited potential, just nothing official.

1 Like

Whether intentional or unintentional, the architecture of using “Device Instances” for inter-SmartApp communication has various advantages (even though these could be handled via other architectures too).

For example, SmartApps must be explicitly granted access to each and every individual Device Instance (“Thing”) that the user wishes to allow the SmartApp to read and/or control. The granularity is all or nothing at the Device Instance level. The most common example of this that the user can easily not select “Lock” devices when installing a SmartApp that he only trusts to turn Light Switches on and off, or installing a SmartApp report a Window Contact Sensor open. (NB: Higher granularity here would be beneficial, as perhaps the user wants to grant read access to the Lock open/closed State, but not write/command access to actually lock/unlock the Lock… but that’s another story).

So if we have a piece of data or an event that allows two or more SmartApps to interact, and we implement this via a Virtual Device Instance, we must also let (and instruct) the user to select that same Virtual Device Instance in each of the related SmartApps. This, therefore, protects that set of data from all other SmartApps which have no business messing with it.

Since external REST-API access to SmartThings is via special “End-Point Mappings” in SmartApps, the above architecture helps to provide security from misbehaving external services and applications as well. (i.e., When a user authorizes an external service to access his account, they get the same opportunity to explicitly select only the desired Device Instances.)

1 Like