Building a SmartThings Automation
I’ve been digging into the SmartThings Automation platform a bit. Admittedly, I’m fumbling around a bit. 😊
According to the definitions in the documentation, I think I want to build a WebHook automation. As per the documentation, one should consider an “when the end-user configures the Automation to monitor an open/close sensor, the Automation subscribes to open/close sensor events. SmartThings Cloud waits on these open/close sensor events. Anytime an open/close event occurs, it is first noticed by SmartThings Cloud, which then calls back the SmartApp.”
This is pretty much what I would like to do. I’d like to be able to track the batteries that need replaced on my some 200+ devices in my house.
So I’m going through the process to setup an Automation.
Select automations from the side menu.
Then select new.
Now, on the automation setup screen this appears to be relatively familiar for an OAuth-enabled WebHook type integration with some additional meta-data for use in the Human Interface.
I couldn’t find the documentation for what the WebHook interface should be to meet the contract of the interface. According to the documentation, I’m supposed to support taking in a JSON payload. So maybe I should just create a HTTP Post endpoint that takes a single string as a parameter? Wish there was better documentation.
So just to hack around, I created a vanilla ASP.NET Core Web API and deployed it to Azure App service just to see what would happen when I plugged in the target URL and it failed (as expected).
I think I found the documentation that explains the data contracts I need to handle. It looks like you need to handle various lifecycle events. Starting with the first one, “PING”, that I assume is only used when the SmartApp is registered. I’ll updated my WebAPI and post again when I make progress.