Design Concept: SmartApp and Azure EventHub communication

Hi All,

I’m looking at developing an SmartApps and EventHub integration. I essentially want to be able to pass event information from Smartthings (via a SmartApp) to an Azure EventHub.It would be ideal to have this ‘event-driven’, so every time something happens, a message is sent.

This is all good and well, for posting directly to an EventHub, but if this is to be a publicly available app, I don’t want my EventHub available to the public.

So what I’m suggesting is a few design concept ideas. Could anyone provide feedback?

-Stream data from SmartApp to EventHub, using HTTP POST. This would be fine, except for controlling access to this. I’ve heard talk of being able to publish a SmartApp, but control who has access to it? ie a secret link? Also, I need to add some data that is specific to each SmartThings ‘site’, so this approach might be problematic

-Stream data from SmartApp to proxy (in house), which will then monitor incoming streams, and only forward accepted streams to the EventHub. Could potentially have unwanted users streaming data to this proxy though, and it also exposes an endpoint. However, this does allow me to append data onto the incoming streams, as I pointed out in the first point.

-Create an endpoint within a SmartApp, as per this. The downside of this is that I would have to poll the data at a regular interval, instead of having a real-time stream, but it would be safer. As I would be polling from my side, I would be able to add this extra ‘site’ data that I mentioned, which is good.

Does anyone have any comments on the above or other suggestions?

Big thanks in advance, power to the forums!

I think you want to put your secret into App settings, these won’t then be deployed when you publish your app. I’m trying to figure out how to do the same thing but I can’t even get authenticated in the first place!

Hi, sorry about the late reply, but found this information about doing this.

Might wanna take a look at it. He wrote a SmartThings App that will collect specific events, forward them up to an Azure Event Hub. Then he wrote some Azure functions that will move that into a Cosmos DB in Azure. I’m struggling with a few steps here and there (and am very new to Azure) but you might wanna take a look… maybe you’ll get stuck at the same spot and we can work together to figure out why it’s not working 100% :slight_smile:

Did anyone deploy this? Managed to get it working although I would like to have additional events logged. Still having problems with Power BI expanding the Documents created in Core DB. Getting a lot of them with null content. Any insight would be appreciated.

Check you have data in cosmosdb first by using Azure Storage Explorer or the Data Explorer (Preview) from the Azure portal. I run through this sample yesterday and I have a report in PowerBI

I do have data in the dB. Clearly power i is not expanding the Json structure properly